From 11aadb806ad9c78a6f36e1da2c1ce15cafbac039 Mon Sep 17 00:00:00 2001 From: kris temmerman Date: Tue, 14 Nov 2023 12:11:51 +0100 Subject: [PATCH] blittest --- frontend/src/CanvasRenderPass.ts | 16 +- frontend/src/{lib/loaders => }/GLFTLoader.ts | 20 +-- frontend/src/Main.ts | 4 +- frontend/src/lib/Blit.ts | 46 +++++ frontend/src/{ => lib}/UI/GL/DrawBatchGL.ts | 0 frontend/src/{ => lib}/UI/GL/FBO.ts | 0 frontend/src/{ => lib}/UI/GL/FillBatchGL.ts | 0 frontend/src/{ => lib}/UI/GL/FillRenderer.ts | 0 frontend/src/{ => lib}/UI/GL/FontTexture.ts | 0 frontend/src/{ => lib}/UI/GL/Program.ts | 0 frontend/src/{ => lib}/UI/GL/Quad.ts | 0 frontend/src/{ => lib}/UI/GL/RendererGL.ts | 0 frontend/src/{ => lib}/UI/GL/TextBatchGL.ts | 0 frontend/src/{ => lib}/UI/GL/TextRenderer.ts | 0 .../src/{ => lib}/UI/GL/TextureRenderer.ts | 0 frontend/src/{ => lib}/UI/GPU/DrawBatchGPU.ts | 0 frontend/src/{ => lib}/UI/GPU/FillBatchGPU.ts | 0 .../src/{ => lib}/UI/GPU/FillBatchMaterial.ts | 0 frontend/src/{ => lib}/UI/GPU/RendererGPU.ts | 0 frontend/src/{ => lib}/UI/GPU/TextBatchGPU.ts | 0 .../src/{ => lib}/UI/GPU/TextBatchMaterial.ts | 0 frontend/src/{ => lib}/UI/UI.ts | 4 +- frontend/src/{ => lib}/UI/UIUtils.ts | 0 frontend/src/{ => lib}/UI/UI_Enums.ts | 0 frontend/src/{ => lib}/UI/UI_I.ts | 2 +- frontend/src/{ => lib}/UI/UI_IC.ts | 0 frontend/src/{ => lib}/UI/UI_Style.ts | 0 frontend/src/{ => lib}/UI/UI_Types.ts | 0 frontend/src/{ => lib}/UI/UI_Vars.ts | 0 .../src/{ => lib}/UI/components/Component.ts | 0 frontend/src/{ => lib}/UI/components/Group.ts | 0 .../src/{ => lib}/UI/components/LBoolean.ts | 0 .../src/{ => lib}/UI/components/LButton.ts | 0 .../src/{ => lib}/UI/components/LColor.ts | 0 .../src/{ => lib}/UI/components/LComponent.ts | 0 frontend/src/{ => lib}/UI/components/LList.ts | 0 .../src/{ => lib}/UI/components/LListItem.ts | 0 .../src/{ => lib}/UI/components/LNumber.ts | 0 .../src/{ => lib}/UI/components/LSelect.ts | 0 .../src/{ => lib}/UI/components/LSlider.ts | 0 frontend/src/{ => lib}/UI/components/LText.ts | 0 .../src/{ => lib}/UI/components/LTextInput.ts | 0 .../src/{ => lib}/UI/components/LTexture.ts | 0 .../src/{ => lib}/UI/components/LVector.ts | 0 frontend/src/{ => lib}/UI/components/Layer.ts | 0 frontend/src/{ => lib}/UI/components/Panel.ts | 0 .../src/{ => lib}/UI/components/Separator.ts | 0 .../{ => lib}/UI/components/VerticalLayout.ts | 0 .../src/{ => lib}/UI/components/Viewport.ts | 0 .../src/{ => lib}/UI/components/WindowComp.ts | 0 .../UI/components/internal/ButtonBase.ts | 0 .../UI/components/internal/CheckBox.ts | 0 .../UI/components/internal/ColorButton.ts | 0 .../UI/components/internal/ColorPicker.ts | 0 .../UI/components/internal/DirtyButton.ts | 0 .../UI/components/internal/DockDivider.ts | 0 .../UI/components/internal/DockIndicator.ts | 0 .../components/internal/DockPanelIndicator.ts | 0 .../UI/components/internal/DockingPanel.ts | 0 .../UI/components/internal/DragBase.ts | 0 .../{ => lib}/UI/components/internal/Event.ts | 0 .../UI/components/internal/EventCenter.ts | 0 .../UI/components/internal/GroupTitle.ts | 0 .../UI/components/internal/IconButton.ts | 0 .../UI/components/internal/InputBase.ts | 0 .../UI/components/internal/SelectButton.ts | 0 .../UI/components/internal/SettingsButton.ts | 0 .../UI/components/internal/SliderBase.ts | 0 .../UI/components/internal/TabButton.ts | 0 .../UI/components/internal/Texture.ts | 0 .../UI/components/internal/ToggleIcon.ts | 0 .../internal/popUps/ColorPickerPopUp.ts | 0 .../components/internal/popUps/DragPopUp.ts | 0 .../UI/components/internal/popUps/PopUp.ts | 0 .../components/internal/popUps/PopUpWindow.ts | 0 .../components/internal/popUps/SelectPopUp.ts | 0 .../components/internal/popUps/SliderPopUp.ts | 0 .../internal/popUps/ViewportPopUp.ts | 0 .../src/{ => lib}/UI/docking/DockManager.ts | 0 frontend/src/{ => lib}/UI/docking/DockNode.ts | 0 .../src/{ => lib}/UI/docking/DockTabData.ts | 0 frontend/src/{ => lib}/UI/docking/DockType.ts | 0 frontend/src/{ => lib}/UI/draw/DrawBatch.ts | 0 frontend/src/{ => lib}/UI/draw/FillBatch.ts | 0 frontend/src/{ => lib}/UI/draw/Font.ts | 0 .../src/{ => lib}/UI/draw/FontTextureData.ts | 0 frontend/src/{ => lib}/UI/draw/TextBatch.ts | 0 .../src/{ => lib}/UI/draw/TextureBatch.ts | 0 .../src/{ => lib}/UI/draw/UIRenderTexture.ts | 0 frontend/src/{ => lib}/UI/draw/UITexture.ts | 0 .../{ => lib}/UI/input/KeyboardListener.ts | 0 .../src/{ => lib}/UI/input/MouseListener.ts | 0 frontend/src/{ => lib}/UI/local/Local.ts | 0 frontend/src/{ => lib}/UI/math/Box.ts | 0 frontend/src/{ => lib}/UI/math/Color.ts | 0 frontend/src/{ => lib}/UI/math/Rect.ts | 0 frontend/src/{ => lib}/UI/math/SelectItem.ts | 0 frontend/src/{ => lib}/UI/math/Utils.ts | 0 frontend/src/{ => lib}/UI/math/Vec2.ts | 0 frontend/src/lib/WebGPUConstants.ts | 60 +++---- frontend/src/lib/core/Material.ts | 39 +++-- frontend/src/lib/core/Shader.ts | 76 ++++---- frontend/src/lib/loaders/OBJLoader.ts | 165 ------------------ frontend/src/lib/textures/ColorAttachment.ts | 2 +- .../lib/textures/DepthStencilAttachment.ts | 2 +- frontend/src/lib/textures/Texture.ts | 2 +- frontend/src/shaders/BlitShader.ts | 70 ++++++++ frontend/src/shaders/TestShader.ts | 5 +- 108 files changed, 251 insertions(+), 262 deletions(-) rename frontend/src/{lib/loaders => }/GLFTLoader.ts (92%) create mode 100644 frontend/src/lib/Blit.ts rename frontend/src/{ => lib}/UI/GL/DrawBatchGL.ts (100%) rename frontend/src/{ => lib}/UI/GL/FBO.ts (100%) rename frontend/src/{ => lib}/UI/GL/FillBatchGL.ts (100%) rename frontend/src/{ => lib}/UI/GL/FillRenderer.ts (100%) rename frontend/src/{ => lib}/UI/GL/FontTexture.ts (100%) rename frontend/src/{ => lib}/UI/GL/Program.ts (100%) rename frontend/src/{ => lib}/UI/GL/Quad.ts (100%) rename frontend/src/{ => lib}/UI/GL/RendererGL.ts (100%) rename frontend/src/{ => lib}/UI/GL/TextBatchGL.ts (100%) rename frontend/src/{ => lib}/UI/GL/TextRenderer.ts (100%) rename frontend/src/{ => lib}/UI/GL/TextureRenderer.ts (100%) rename frontend/src/{ => lib}/UI/GPU/DrawBatchGPU.ts (100%) rename frontend/src/{ => lib}/UI/GPU/FillBatchGPU.ts (100%) rename frontend/src/{ => lib}/UI/GPU/FillBatchMaterial.ts (100%) rename frontend/src/{ => lib}/UI/GPU/RendererGPU.ts (100%) rename frontend/src/{ => lib}/UI/GPU/TextBatchGPU.ts (100%) rename frontend/src/{ => lib}/UI/GPU/TextBatchMaterial.ts (100%) rename frontend/src/{ => lib}/UI/UI.ts (99%) rename frontend/src/{ => lib}/UI/UIUtils.ts (100%) rename frontend/src/{ => lib}/UI/UI_Enums.ts (100%) rename frontend/src/{ => lib}/UI/UI_I.ts (99%) rename frontend/src/{ => lib}/UI/UI_IC.ts (100%) rename frontend/src/{ => lib}/UI/UI_Style.ts (100%) rename frontend/src/{ => lib}/UI/UI_Types.ts (100%) rename frontend/src/{ => lib}/UI/UI_Vars.ts (100%) rename frontend/src/{ => lib}/UI/components/Component.ts (100%) rename frontend/src/{ => lib}/UI/components/Group.ts (100%) rename frontend/src/{ => lib}/UI/components/LBoolean.ts (100%) rename frontend/src/{ => lib}/UI/components/LButton.ts (100%) rename frontend/src/{ => lib}/UI/components/LColor.ts (100%) rename frontend/src/{ => lib}/UI/components/LComponent.ts (100%) rename frontend/src/{ => lib}/UI/components/LList.ts (100%) rename frontend/src/{ => lib}/UI/components/LListItem.ts (100%) rename frontend/src/{ => lib}/UI/components/LNumber.ts (100%) rename frontend/src/{ => lib}/UI/components/LSelect.ts (100%) rename frontend/src/{ => lib}/UI/components/LSlider.ts (100%) rename frontend/src/{ => lib}/UI/components/LText.ts (100%) rename frontend/src/{ => lib}/UI/components/LTextInput.ts (100%) rename frontend/src/{ => lib}/UI/components/LTexture.ts (100%) rename frontend/src/{ => lib}/UI/components/LVector.ts (100%) rename frontend/src/{ => lib}/UI/components/Layer.ts (100%) rename frontend/src/{ => lib}/UI/components/Panel.ts (100%) rename frontend/src/{ => lib}/UI/components/Separator.ts (100%) rename frontend/src/{ => lib}/UI/components/VerticalLayout.ts (100%) rename frontend/src/{ => lib}/UI/components/Viewport.ts (100%) rename frontend/src/{ => lib}/UI/components/WindowComp.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/ButtonBase.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/CheckBox.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/ColorButton.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/ColorPicker.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/DirtyButton.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/DockDivider.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/DockIndicator.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/DockPanelIndicator.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/DockingPanel.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/DragBase.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/Event.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/EventCenter.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/GroupTitle.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/IconButton.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/InputBase.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/SelectButton.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/SettingsButton.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/SliderBase.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/TabButton.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/Texture.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/ToggleIcon.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/popUps/ColorPickerPopUp.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/popUps/DragPopUp.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/popUps/PopUp.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/popUps/PopUpWindow.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/popUps/SelectPopUp.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/popUps/SliderPopUp.ts (100%) rename frontend/src/{ => lib}/UI/components/internal/popUps/ViewportPopUp.ts (100%) rename frontend/src/{ => lib}/UI/docking/DockManager.ts (100%) rename frontend/src/{ => lib}/UI/docking/DockNode.ts (100%) rename frontend/src/{ => lib}/UI/docking/DockTabData.ts (100%) rename frontend/src/{ => lib}/UI/docking/DockType.ts (100%) rename frontend/src/{ => lib}/UI/draw/DrawBatch.ts (100%) rename frontend/src/{ => lib}/UI/draw/FillBatch.ts (100%) rename frontend/src/{ => lib}/UI/draw/Font.ts (100%) rename frontend/src/{ => lib}/UI/draw/FontTextureData.ts (100%) rename frontend/src/{ => lib}/UI/draw/TextBatch.ts (100%) rename frontend/src/{ => lib}/UI/draw/TextureBatch.ts (100%) rename frontend/src/{ => lib}/UI/draw/UIRenderTexture.ts (100%) rename frontend/src/{ => lib}/UI/draw/UITexture.ts (100%) rename frontend/src/{ => lib}/UI/input/KeyboardListener.ts (100%) rename frontend/src/{ => lib}/UI/input/MouseListener.ts (100%) rename frontend/src/{ => lib}/UI/local/Local.ts (100%) rename frontend/src/{ => lib}/UI/math/Box.ts (100%) rename frontend/src/{ => lib}/UI/math/Color.ts (100%) rename frontend/src/{ => lib}/UI/math/Rect.ts (100%) rename frontend/src/{ => lib}/UI/math/SelectItem.ts (100%) rename frontend/src/{ => lib}/UI/math/Utils.ts (100%) rename frontend/src/{ => lib}/UI/math/Vec2.ts (100%) delete mode 100644 frontend/src/lib/loaders/OBJLoader.ts create mode 100644 frontend/src/shaders/BlitShader.ts diff --git a/frontend/src/CanvasRenderPass.ts b/frontend/src/CanvasRenderPass.ts index 56a7de2c..b481fc33 100644 --- a/frontend/src/CanvasRenderPass.ts +++ b/frontend/src/CanvasRenderPass.ts @@ -5,13 +5,19 @@ import DepthStencilAttachment from "./lib/textures/DepthStencilAttachment"; import RenderPass from "./lib/core/RenderPass"; import Renderer from "./lib/Renderer"; import ModelRenderer from "./lib/model/ModelRenderer"; -import UI from "./UI/UI"; +import UI from "./lib/UI/UI"; +import Blit from "./lib/Blit"; +import Material from "./lib/core/Material"; +import BlitShader from "./shaders/BlitShader"; +import ImagePreloader from "./ImagePreloader"; export default class extends RenderPass { private canvasColorTarget: RenderTexture; public canvasColorAttachment: ColorAttachment; private canvasDepthTarget: RenderTexture; public modelRenderer: ModelRenderer; + private blitMaterial: Material; + private blitTest: Blit; @@ -30,7 +36,7 @@ export default class extends RenderPass { this.canvasColorAttachment = new ColorAttachment(this.canvasColorTarget); this.colorAttachments =[this.canvasColorAttachment]; - this.canvasDepthTarget = new RenderTexture(renderer, "canvasDepth", { + this.canvasDepthTarget = new RenderTexture(renderer, "canvasDepth", { format: TextureFormat.Depth16Unorm, sampleCount: 4, scaleToCanvas: true, @@ -38,10 +44,16 @@ export default class extends RenderPass { }); this.depthStencilAttachment = new DepthStencilAttachment(this.canvasDepthTarget); + this.blitMaterial =new Material(this.renderer,"blit", new BlitShader(this.renderer,"blit")) + this.blitMaterial.uniforms.setTexture("colorTexture",ImagePreloader.getTexture("chair_Color")) + this.blitTest =new Blit(renderer,'blit',this.blitMaterial) + } draw() { + this.blitTest.draw(this); this.modelRenderer.draw(this); + UI.drawGPU(this.passEncoder,true) } diff --git a/frontend/src/lib/loaders/GLFTLoader.ts b/frontend/src/GLFTLoader.ts similarity index 92% rename from frontend/src/lib/loaders/GLFTLoader.ts rename to frontend/src/GLFTLoader.ts index 40fdf3de..0560b148 100644 --- a/frontend/src/lib/loaders/GLFTLoader.ts +++ b/frontend/src/GLFTLoader.ts @@ -1,12 +1,12 @@ -import PreLoader from "../PreLoader"; -import Mesh from "../core/Mesh"; -import Renderer from "../Renderer"; -import Object3D from "../core/Object3D"; -import Model from "../model/Model"; -import TestShader from "../../shaders/TestShader"; -import Material from "../core/Material"; -import ImagePreloader from "../../ImagePreloader"; -import Texture from "../textures/Texture"; +import PreLoader from "./lib/PreLoader"; +import Mesh from "./lib/core/Mesh"; +import Renderer from "./lib/Renderer"; +import Object3D from "./lib/core/Object3D"; +import Model from "./lib/model/Model"; +import TestShader from "./shaders/TestShader"; +import Material from "./lib/core/Material"; +import ImagePreloader from "./ImagePreloader"; + type Accessor = { accessor: any; @@ -35,7 +35,7 @@ export default class GLFTLoader { this.root = new Object3D(renderer, "sceneRoot"); this.mainShader =new TestShader(this.renderer,"testShader"); - // this.material =new Material(this.renderer,"testmaterial",testShader); + preLoader.startLoad(); this.loadURL(url).then(() => { diff --git a/frontend/src/Main.ts b/frontend/src/Main.ts index 38181573..1ff86e0d 100644 --- a/frontend/src/Main.ts +++ b/frontend/src/Main.ts @@ -5,7 +5,7 @@ import Renderer from "./lib/Renderer"; import PreLoader from "./lib/PreLoader"; import Camera from "./lib/Camera"; -import GLFTLoader from "./lib/loaders/GLFTLoader"; +import GLFTLoader from "./GLFTLoader"; import ImagePreloader from "./ImagePreloader"; import {Vector2, Vector3} from "math.gl"; @@ -13,7 +13,7 @@ import MouseListener from "./lib/MouseListener"; import Object3D from "./lib/core/Object3D"; import CanvasRenderPass from "./CanvasRenderPass"; import TimeStampQuery from "./lib/TimeStampQuery"; -import UI from "./UI/UI"; +import UI from "./lib/UI/UI"; export default class Main { diff --git a/frontend/src/lib/Blit.ts b/frontend/src/lib/Blit.ts new file mode 100644 index 00000000..6553e865 --- /dev/null +++ b/frontend/src/lib/Blit.ts @@ -0,0 +1,46 @@ +import Renderer from "./Renderer"; +import RenderPass from "./core/RenderPass"; +import Material from "./core/Material"; +import Quad from "./meshes/Quad"; +import {CompareFunction} from "./WebGPUConstants"; + +export default class Blit{ + private material: Material; + private mesh: Quad; + + + constructor(renderer:Renderer,label:string, material:Material) + { + this.material =material; + this.material.depthWrite =false + this.material.depthCompare=CompareFunction.Always + this.mesh=new Quad(renderer) + } + draw(pass:RenderPass) + { + const passEncoder =pass.passEncoder; + this.material.makePipeLine(pass); + + passEncoder.setPipeline(this.material.pipeLine); + + + passEncoder.setBindGroup(0,this.material.uniforms.bindGroup); + + for (let attribute of this.material.shader.attributes) { + passEncoder.setVertexBuffer( + attribute.slot, + this.mesh.getBufferByName(attribute.name) + ); + } + + + passEncoder.setIndexBuffer(this.mesh.indexBuffer, this.mesh.indexFormat); + passEncoder.drawIndexed( + this.mesh.numIndices, + 1, + 0, + 0 + ); + + } +} diff --git a/frontend/src/UI/GL/DrawBatchGL.ts b/frontend/src/lib/UI/GL/DrawBatchGL.ts similarity index 100% rename from frontend/src/UI/GL/DrawBatchGL.ts rename to frontend/src/lib/UI/GL/DrawBatchGL.ts diff --git a/frontend/src/UI/GL/FBO.ts b/frontend/src/lib/UI/GL/FBO.ts similarity index 100% rename from frontend/src/UI/GL/FBO.ts rename to frontend/src/lib/UI/GL/FBO.ts diff --git a/frontend/src/UI/GL/FillBatchGL.ts b/frontend/src/lib/UI/GL/FillBatchGL.ts similarity index 100% rename from frontend/src/UI/GL/FillBatchGL.ts rename to frontend/src/lib/UI/GL/FillBatchGL.ts diff --git a/frontend/src/UI/GL/FillRenderer.ts b/frontend/src/lib/UI/GL/FillRenderer.ts similarity index 100% rename from frontend/src/UI/GL/FillRenderer.ts rename to frontend/src/lib/UI/GL/FillRenderer.ts diff --git a/frontend/src/UI/GL/FontTexture.ts b/frontend/src/lib/UI/GL/FontTexture.ts similarity index 100% rename from frontend/src/UI/GL/FontTexture.ts rename to frontend/src/lib/UI/GL/FontTexture.ts diff --git a/frontend/src/UI/GL/Program.ts b/frontend/src/lib/UI/GL/Program.ts similarity index 100% rename from frontend/src/UI/GL/Program.ts rename to frontend/src/lib/UI/GL/Program.ts diff --git a/frontend/src/UI/GL/Quad.ts b/frontend/src/lib/UI/GL/Quad.ts similarity index 100% rename from frontend/src/UI/GL/Quad.ts rename to frontend/src/lib/UI/GL/Quad.ts diff --git a/frontend/src/UI/GL/RendererGL.ts b/frontend/src/lib/UI/GL/RendererGL.ts similarity index 100% rename from frontend/src/UI/GL/RendererGL.ts rename to frontend/src/lib/UI/GL/RendererGL.ts diff --git a/frontend/src/UI/GL/TextBatchGL.ts b/frontend/src/lib/UI/GL/TextBatchGL.ts similarity index 100% rename from frontend/src/UI/GL/TextBatchGL.ts rename to frontend/src/lib/UI/GL/TextBatchGL.ts diff --git a/frontend/src/UI/GL/TextRenderer.ts b/frontend/src/lib/UI/GL/TextRenderer.ts similarity index 100% rename from frontend/src/UI/GL/TextRenderer.ts rename to frontend/src/lib/UI/GL/TextRenderer.ts diff --git a/frontend/src/UI/GL/TextureRenderer.ts b/frontend/src/lib/UI/GL/TextureRenderer.ts similarity index 100% rename from frontend/src/UI/GL/TextureRenderer.ts rename to frontend/src/lib/UI/GL/TextureRenderer.ts diff --git a/frontend/src/UI/GPU/DrawBatchGPU.ts b/frontend/src/lib/UI/GPU/DrawBatchGPU.ts similarity index 100% rename from frontend/src/UI/GPU/DrawBatchGPU.ts rename to frontend/src/lib/UI/GPU/DrawBatchGPU.ts diff --git a/frontend/src/UI/GPU/FillBatchGPU.ts b/frontend/src/lib/UI/GPU/FillBatchGPU.ts similarity index 100% rename from frontend/src/UI/GPU/FillBatchGPU.ts rename to frontend/src/lib/UI/GPU/FillBatchGPU.ts diff --git a/frontend/src/UI/GPU/FillBatchMaterial.ts b/frontend/src/lib/UI/GPU/FillBatchMaterial.ts similarity index 100% rename from frontend/src/UI/GPU/FillBatchMaterial.ts rename to frontend/src/lib/UI/GPU/FillBatchMaterial.ts diff --git a/frontend/src/UI/GPU/RendererGPU.ts b/frontend/src/lib/UI/GPU/RendererGPU.ts similarity index 100% rename from frontend/src/UI/GPU/RendererGPU.ts rename to frontend/src/lib/UI/GPU/RendererGPU.ts diff --git a/frontend/src/UI/GPU/TextBatchGPU.ts b/frontend/src/lib/UI/GPU/TextBatchGPU.ts similarity index 100% rename from frontend/src/UI/GPU/TextBatchGPU.ts rename to frontend/src/lib/UI/GPU/TextBatchGPU.ts diff --git a/frontend/src/UI/GPU/TextBatchMaterial.ts b/frontend/src/lib/UI/GPU/TextBatchMaterial.ts similarity index 100% rename from frontend/src/UI/GPU/TextBatchMaterial.ts rename to frontend/src/lib/UI/GPU/TextBatchMaterial.ts diff --git a/frontend/src/UI/UI.ts b/frontend/src/lib/UI/UI.ts similarity index 99% rename from frontend/src/UI/UI.ts rename to frontend/src/lib/UI/UI.ts index 37140ec2..726b0748 100644 --- a/frontend/src/UI/UI.ts +++ b/frontend/src/lib/UI/UI.ts @@ -27,8 +27,8 @@ import { UI_COLOR, UI_VEC2, UI_VEC3, UI_VEC4 } from "./UI_Types"; import LVector, { LVectorSettings } from "./components/LVector"; import LList, { LListSettings } from "./components/LList"; import LListItem, { LListItemSettings } from "./components/LListItem"; -import WebGPU from "../../components/WebGPU"; -import Renderer from "../lib/Renderer"; +import WebGPU from "../../../components/WebGPU"; +import Renderer from "../Renderer"; export default class UI { private static viewPort: Viewport | null; diff --git a/frontend/src/UI/UIUtils.ts b/frontend/src/lib/UI/UIUtils.ts similarity index 100% rename from frontend/src/UI/UIUtils.ts rename to frontend/src/lib/UI/UIUtils.ts diff --git a/frontend/src/UI/UI_Enums.ts b/frontend/src/lib/UI/UI_Enums.ts similarity index 100% rename from frontend/src/UI/UI_Enums.ts rename to frontend/src/lib/UI/UI_Enums.ts diff --git a/frontend/src/UI/UI_I.ts b/frontend/src/lib/UI/UI_I.ts similarity index 99% rename from frontend/src/UI/UI_I.ts rename to frontend/src/lib/UI/UI_I.ts index 7514f607..a3750f7c 100644 --- a/frontend/src/UI/UI_I.ts +++ b/frontend/src/lib/UI/UI_I.ts @@ -17,7 +17,7 @@ import EventCenter, { } from "./components/internal/EventCenter"; import RendererGPU from "./GPU/RendererGPU"; import Rect from "./math/Rect"; -import Renderer from "../lib/Renderer"; +import Renderer from "../Renderer"; export default class UI_I { public static currentComponent: Component; diff --git a/frontend/src/UI/UI_IC.ts b/frontend/src/lib/UI/UI_IC.ts similarity index 100% rename from frontend/src/UI/UI_IC.ts rename to frontend/src/lib/UI/UI_IC.ts diff --git a/frontend/src/UI/UI_Style.ts b/frontend/src/lib/UI/UI_Style.ts similarity index 100% rename from frontend/src/UI/UI_Style.ts rename to frontend/src/lib/UI/UI_Style.ts diff --git a/frontend/src/UI/UI_Types.ts b/frontend/src/lib/UI/UI_Types.ts similarity index 100% rename from frontend/src/UI/UI_Types.ts rename to frontend/src/lib/UI/UI_Types.ts diff --git a/frontend/src/UI/UI_Vars.ts b/frontend/src/lib/UI/UI_Vars.ts similarity index 100% rename from frontend/src/UI/UI_Vars.ts rename to frontend/src/lib/UI/UI_Vars.ts diff --git a/frontend/src/UI/components/Component.ts b/frontend/src/lib/UI/components/Component.ts similarity index 100% rename from frontend/src/UI/components/Component.ts rename to frontend/src/lib/UI/components/Component.ts diff --git a/frontend/src/UI/components/Group.ts b/frontend/src/lib/UI/components/Group.ts similarity index 100% rename from frontend/src/UI/components/Group.ts rename to frontend/src/lib/UI/components/Group.ts diff --git a/frontend/src/UI/components/LBoolean.ts b/frontend/src/lib/UI/components/LBoolean.ts similarity index 100% rename from frontend/src/UI/components/LBoolean.ts rename to frontend/src/lib/UI/components/LBoolean.ts diff --git a/frontend/src/UI/components/LButton.ts b/frontend/src/lib/UI/components/LButton.ts similarity index 100% rename from frontend/src/UI/components/LButton.ts rename to frontend/src/lib/UI/components/LButton.ts diff --git a/frontend/src/UI/components/LColor.ts b/frontend/src/lib/UI/components/LColor.ts similarity index 100% rename from frontend/src/UI/components/LColor.ts rename to frontend/src/lib/UI/components/LColor.ts diff --git a/frontend/src/UI/components/LComponent.ts b/frontend/src/lib/UI/components/LComponent.ts similarity index 100% rename from frontend/src/UI/components/LComponent.ts rename to frontend/src/lib/UI/components/LComponent.ts diff --git a/frontend/src/UI/components/LList.ts b/frontend/src/lib/UI/components/LList.ts similarity index 100% rename from frontend/src/UI/components/LList.ts rename to frontend/src/lib/UI/components/LList.ts diff --git a/frontend/src/UI/components/LListItem.ts b/frontend/src/lib/UI/components/LListItem.ts similarity index 100% rename from frontend/src/UI/components/LListItem.ts rename to frontend/src/lib/UI/components/LListItem.ts diff --git a/frontend/src/UI/components/LNumber.ts b/frontend/src/lib/UI/components/LNumber.ts similarity index 100% rename from frontend/src/UI/components/LNumber.ts rename to frontend/src/lib/UI/components/LNumber.ts diff --git a/frontend/src/UI/components/LSelect.ts b/frontend/src/lib/UI/components/LSelect.ts similarity index 100% rename from frontend/src/UI/components/LSelect.ts rename to frontend/src/lib/UI/components/LSelect.ts diff --git a/frontend/src/UI/components/LSlider.ts b/frontend/src/lib/UI/components/LSlider.ts similarity index 100% rename from frontend/src/UI/components/LSlider.ts rename to frontend/src/lib/UI/components/LSlider.ts diff --git a/frontend/src/UI/components/LText.ts b/frontend/src/lib/UI/components/LText.ts similarity index 100% rename from frontend/src/UI/components/LText.ts rename to frontend/src/lib/UI/components/LText.ts diff --git a/frontend/src/UI/components/LTextInput.ts b/frontend/src/lib/UI/components/LTextInput.ts similarity index 100% rename from frontend/src/UI/components/LTextInput.ts rename to frontend/src/lib/UI/components/LTextInput.ts diff --git a/frontend/src/UI/components/LTexture.ts b/frontend/src/lib/UI/components/LTexture.ts similarity index 100% rename from frontend/src/UI/components/LTexture.ts rename to frontend/src/lib/UI/components/LTexture.ts diff --git a/frontend/src/UI/components/LVector.ts b/frontend/src/lib/UI/components/LVector.ts similarity index 100% rename from frontend/src/UI/components/LVector.ts rename to frontend/src/lib/UI/components/LVector.ts diff --git a/frontend/src/UI/components/Layer.ts b/frontend/src/lib/UI/components/Layer.ts similarity index 100% rename from frontend/src/UI/components/Layer.ts rename to frontend/src/lib/UI/components/Layer.ts diff --git a/frontend/src/UI/components/Panel.ts b/frontend/src/lib/UI/components/Panel.ts similarity index 100% rename from frontend/src/UI/components/Panel.ts rename to frontend/src/lib/UI/components/Panel.ts diff --git a/frontend/src/UI/components/Separator.ts b/frontend/src/lib/UI/components/Separator.ts similarity index 100% rename from frontend/src/UI/components/Separator.ts rename to frontend/src/lib/UI/components/Separator.ts diff --git a/frontend/src/UI/components/VerticalLayout.ts b/frontend/src/lib/UI/components/VerticalLayout.ts similarity index 100% rename from frontend/src/UI/components/VerticalLayout.ts rename to frontend/src/lib/UI/components/VerticalLayout.ts diff --git a/frontend/src/UI/components/Viewport.ts b/frontend/src/lib/UI/components/Viewport.ts similarity index 100% rename from frontend/src/UI/components/Viewport.ts rename to frontend/src/lib/UI/components/Viewport.ts diff --git a/frontend/src/UI/components/WindowComp.ts b/frontend/src/lib/UI/components/WindowComp.ts similarity index 100% rename from frontend/src/UI/components/WindowComp.ts rename to frontend/src/lib/UI/components/WindowComp.ts diff --git a/frontend/src/UI/components/internal/ButtonBase.ts b/frontend/src/lib/UI/components/internal/ButtonBase.ts similarity index 100% rename from frontend/src/UI/components/internal/ButtonBase.ts rename to frontend/src/lib/UI/components/internal/ButtonBase.ts diff --git a/frontend/src/UI/components/internal/CheckBox.ts b/frontend/src/lib/UI/components/internal/CheckBox.ts similarity index 100% rename from frontend/src/UI/components/internal/CheckBox.ts rename to frontend/src/lib/UI/components/internal/CheckBox.ts diff --git a/frontend/src/UI/components/internal/ColorButton.ts b/frontend/src/lib/UI/components/internal/ColorButton.ts similarity index 100% rename from frontend/src/UI/components/internal/ColorButton.ts rename to frontend/src/lib/UI/components/internal/ColorButton.ts diff --git a/frontend/src/UI/components/internal/ColorPicker.ts b/frontend/src/lib/UI/components/internal/ColorPicker.ts similarity index 100% rename from frontend/src/UI/components/internal/ColorPicker.ts rename to frontend/src/lib/UI/components/internal/ColorPicker.ts diff --git a/frontend/src/UI/components/internal/DirtyButton.ts b/frontend/src/lib/UI/components/internal/DirtyButton.ts similarity index 100% rename from frontend/src/UI/components/internal/DirtyButton.ts rename to frontend/src/lib/UI/components/internal/DirtyButton.ts diff --git a/frontend/src/UI/components/internal/DockDivider.ts b/frontend/src/lib/UI/components/internal/DockDivider.ts similarity index 100% rename from frontend/src/UI/components/internal/DockDivider.ts rename to frontend/src/lib/UI/components/internal/DockDivider.ts diff --git a/frontend/src/UI/components/internal/DockIndicator.ts b/frontend/src/lib/UI/components/internal/DockIndicator.ts similarity index 100% rename from frontend/src/UI/components/internal/DockIndicator.ts rename to frontend/src/lib/UI/components/internal/DockIndicator.ts diff --git a/frontend/src/UI/components/internal/DockPanelIndicator.ts b/frontend/src/lib/UI/components/internal/DockPanelIndicator.ts similarity index 100% rename from frontend/src/UI/components/internal/DockPanelIndicator.ts rename to frontend/src/lib/UI/components/internal/DockPanelIndicator.ts diff --git a/frontend/src/UI/components/internal/DockingPanel.ts b/frontend/src/lib/UI/components/internal/DockingPanel.ts similarity index 100% rename from frontend/src/UI/components/internal/DockingPanel.ts rename to frontend/src/lib/UI/components/internal/DockingPanel.ts diff --git a/frontend/src/UI/components/internal/DragBase.ts b/frontend/src/lib/UI/components/internal/DragBase.ts similarity index 100% rename from frontend/src/UI/components/internal/DragBase.ts rename to frontend/src/lib/UI/components/internal/DragBase.ts diff --git a/frontend/src/UI/components/internal/Event.ts b/frontend/src/lib/UI/components/internal/Event.ts similarity index 100% rename from frontend/src/UI/components/internal/Event.ts rename to frontend/src/lib/UI/components/internal/Event.ts diff --git a/frontend/src/UI/components/internal/EventCenter.ts b/frontend/src/lib/UI/components/internal/EventCenter.ts similarity index 100% rename from frontend/src/UI/components/internal/EventCenter.ts rename to frontend/src/lib/UI/components/internal/EventCenter.ts diff --git a/frontend/src/UI/components/internal/GroupTitle.ts b/frontend/src/lib/UI/components/internal/GroupTitle.ts similarity index 100% rename from frontend/src/UI/components/internal/GroupTitle.ts rename to frontend/src/lib/UI/components/internal/GroupTitle.ts diff --git a/frontend/src/UI/components/internal/IconButton.ts b/frontend/src/lib/UI/components/internal/IconButton.ts similarity index 100% rename from frontend/src/UI/components/internal/IconButton.ts rename to frontend/src/lib/UI/components/internal/IconButton.ts diff --git a/frontend/src/UI/components/internal/InputBase.ts b/frontend/src/lib/UI/components/internal/InputBase.ts similarity index 100% rename from frontend/src/UI/components/internal/InputBase.ts rename to frontend/src/lib/UI/components/internal/InputBase.ts diff --git a/frontend/src/UI/components/internal/SelectButton.ts b/frontend/src/lib/UI/components/internal/SelectButton.ts similarity index 100% rename from frontend/src/UI/components/internal/SelectButton.ts rename to frontend/src/lib/UI/components/internal/SelectButton.ts diff --git a/frontend/src/UI/components/internal/SettingsButton.ts b/frontend/src/lib/UI/components/internal/SettingsButton.ts similarity index 100% rename from frontend/src/UI/components/internal/SettingsButton.ts rename to frontend/src/lib/UI/components/internal/SettingsButton.ts diff --git a/frontend/src/UI/components/internal/SliderBase.ts b/frontend/src/lib/UI/components/internal/SliderBase.ts similarity index 100% rename from frontend/src/UI/components/internal/SliderBase.ts rename to frontend/src/lib/UI/components/internal/SliderBase.ts diff --git a/frontend/src/UI/components/internal/TabButton.ts b/frontend/src/lib/UI/components/internal/TabButton.ts similarity index 100% rename from frontend/src/UI/components/internal/TabButton.ts rename to frontend/src/lib/UI/components/internal/TabButton.ts diff --git a/frontend/src/UI/components/internal/Texture.ts b/frontend/src/lib/UI/components/internal/Texture.ts similarity index 100% rename from frontend/src/UI/components/internal/Texture.ts rename to frontend/src/lib/UI/components/internal/Texture.ts diff --git a/frontend/src/UI/components/internal/ToggleIcon.ts b/frontend/src/lib/UI/components/internal/ToggleIcon.ts similarity index 100% rename from frontend/src/UI/components/internal/ToggleIcon.ts rename to frontend/src/lib/UI/components/internal/ToggleIcon.ts diff --git a/frontend/src/UI/components/internal/popUps/ColorPickerPopUp.ts b/frontend/src/lib/UI/components/internal/popUps/ColorPickerPopUp.ts similarity index 100% rename from frontend/src/UI/components/internal/popUps/ColorPickerPopUp.ts rename to frontend/src/lib/UI/components/internal/popUps/ColorPickerPopUp.ts diff --git a/frontend/src/UI/components/internal/popUps/DragPopUp.ts b/frontend/src/lib/UI/components/internal/popUps/DragPopUp.ts similarity index 100% rename from frontend/src/UI/components/internal/popUps/DragPopUp.ts rename to frontend/src/lib/UI/components/internal/popUps/DragPopUp.ts diff --git a/frontend/src/UI/components/internal/popUps/PopUp.ts b/frontend/src/lib/UI/components/internal/popUps/PopUp.ts similarity index 100% rename from frontend/src/UI/components/internal/popUps/PopUp.ts rename to frontend/src/lib/UI/components/internal/popUps/PopUp.ts diff --git a/frontend/src/UI/components/internal/popUps/PopUpWindow.ts b/frontend/src/lib/UI/components/internal/popUps/PopUpWindow.ts similarity index 100% rename from frontend/src/UI/components/internal/popUps/PopUpWindow.ts rename to frontend/src/lib/UI/components/internal/popUps/PopUpWindow.ts diff --git a/frontend/src/UI/components/internal/popUps/SelectPopUp.ts b/frontend/src/lib/UI/components/internal/popUps/SelectPopUp.ts similarity index 100% rename from frontend/src/UI/components/internal/popUps/SelectPopUp.ts rename to frontend/src/lib/UI/components/internal/popUps/SelectPopUp.ts diff --git a/frontend/src/UI/components/internal/popUps/SliderPopUp.ts b/frontend/src/lib/UI/components/internal/popUps/SliderPopUp.ts similarity index 100% rename from frontend/src/UI/components/internal/popUps/SliderPopUp.ts rename to frontend/src/lib/UI/components/internal/popUps/SliderPopUp.ts diff --git a/frontend/src/UI/components/internal/popUps/ViewportPopUp.ts b/frontend/src/lib/UI/components/internal/popUps/ViewportPopUp.ts similarity index 100% rename from frontend/src/UI/components/internal/popUps/ViewportPopUp.ts rename to frontend/src/lib/UI/components/internal/popUps/ViewportPopUp.ts diff --git a/frontend/src/UI/docking/DockManager.ts b/frontend/src/lib/UI/docking/DockManager.ts similarity index 100% rename from frontend/src/UI/docking/DockManager.ts rename to frontend/src/lib/UI/docking/DockManager.ts diff --git a/frontend/src/UI/docking/DockNode.ts b/frontend/src/lib/UI/docking/DockNode.ts similarity index 100% rename from frontend/src/UI/docking/DockNode.ts rename to frontend/src/lib/UI/docking/DockNode.ts diff --git a/frontend/src/UI/docking/DockTabData.ts b/frontend/src/lib/UI/docking/DockTabData.ts similarity index 100% rename from frontend/src/UI/docking/DockTabData.ts rename to frontend/src/lib/UI/docking/DockTabData.ts diff --git a/frontend/src/UI/docking/DockType.ts b/frontend/src/lib/UI/docking/DockType.ts similarity index 100% rename from frontend/src/UI/docking/DockType.ts rename to frontend/src/lib/UI/docking/DockType.ts diff --git a/frontend/src/UI/draw/DrawBatch.ts b/frontend/src/lib/UI/draw/DrawBatch.ts similarity index 100% rename from frontend/src/UI/draw/DrawBatch.ts rename to frontend/src/lib/UI/draw/DrawBatch.ts diff --git a/frontend/src/UI/draw/FillBatch.ts b/frontend/src/lib/UI/draw/FillBatch.ts similarity index 100% rename from frontend/src/UI/draw/FillBatch.ts rename to frontend/src/lib/UI/draw/FillBatch.ts diff --git a/frontend/src/UI/draw/Font.ts b/frontend/src/lib/UI/draw/Font.ts similarity index 100% rename from frontend/src/UI/draw/Font.ts rename to frontend/src/lib/UI/draw/Font.ts diff --git a/frontend/src/UI/draw/FontTextureData.ts b/frontend/src/lib/UI/draw/FontTextureData.ts similarity index 100% rename from frontend/src/UI/draw/FontTextureData.ts rename to frontend/src/lib/UI/draw/FontTextureData.ts diff --git a/frontend/src/UI/draw/TextBatch.ts b/frontend/src/lib/UI/draw/TextBatch.ts similarity index 100% rename from frontend/src/UI/draw/TextBatch.ts rename to frontend/src/lib/UI/draw/TextBatch.ts diff --git a/frontend/src/UI/draw/TextureBatch.ts b/frontend/src/lib/UI/draw/TextureBatch.ts similarity index 100% rename from frontend/src/UI/draw/TextureBatch.ts rename to frontend/src/lib/UI/draw/TextureBatch.ts diff --git a/frontend/src/UI/draw/UIRenderTexture.ts b/frontend/src/lib/UI/draw/UIRenderTexture.ts similarity index 100% rename from frontend/src/UI/draw/UIRenderTexture.ts rename to frontend/src/lib/UI/draw/UIRenderTexture.ts diff --git a/frontend/src/UI/draw/UITexture.ts b/frontend/src/lib/UI/draw/UITexture.ts similarity index 100% rename from frontend/src/UI/draw/UITexture.ts rename to frontend/src/lib/UI/draw/UITexture.ts diff --git a/frontend/src/UI/input/KeyboardListener.ts b/frontend/src/lib/UI/input/KeyboardListener.ts similarity index 100% rename from frontend/src/UI/input/KeyboardListener.ts rename to frontend/src/lib/UI/input/KeyboardListener.ts diff --git a/frontend/src/UI/input/MouseListener.ts b/frontend/src/lib/UI/input/MouseListener.ts similarity index 100% rename from frontend/src/UI/input/MouseListener.ts rename to frontend/src/lib/UI/input/MouseListener.ts diff --git a/frontend/src/UI/local/Local.ts b/frontend/src/lib/UI/local/Local.ts similarity index 100% rename from frontend/src/UI/local/Local.ts rename to frontend/src/lib/UI/local/Local.ts diff --git a/frontend/src/UI/math/Box.ts b/frontend/src/lib/UI/math/Box.ts similarity index 100% rename from frontend/src/UI/math/Box.ts rename to frontend/src/lib/UI/math/Box.ts diff --git a/frontend/src/UI/math/Color.ts b/frontend/src/lib/UI/math/Color.ts similarity index 100% rename from frontend/src/UI/math/Color.ts rename to frontend/src/lib/UI/math/Color.ts diff --git a/frontend/src/UI/math/Rect.ts b/frontend/src/lib/UI/math/Rect.ts similarity index 100% rename from frontend/src/UI/math/Rect.ts rename to frontend/src/lib/UI/math/Rect.ts diff --git a/frontend/src/UI/math/SelectItem.ts b/frontend/src/lib/UI/math/SelectItem.ts similarity index 100% rename from frontend/src/UI/math/SelectItem.ts rename to frontend/src/lib/UI/math/SelectItem.ts diff --git a/frontend/src/UI/math/Utils.ts b/frontend/src/lib/UI/math/Utils.ts similarity index 100% rename from frontend/src/UI/math/Utils.ts rename to frontend/src/lib/UI/math/Utils.ts diff --git a/frontend/src/UI/math/Vec2.ts b/frontend/src/lib/UI/math/Vec2.ts similarity index 100% rename from frontend/src/UI/math/Vec2.ts rename to frontend/src/lib/UI/math/Vec2.ts diff --git a/frontend/src/lib/WebGPUConstants.ts b/frontend/src/lib/WebGPUConstants.ts index 322e9444..cbe6b2f1 100644 --- a/frontend/src/lib/WebGPUConstants.ts +++ b/frontend/src/lib/WebGPUConstants.ts @@ -6,25 +6,25 @@ export const GPUPrimitiveTopology = { TriangleStrip: 'triangle-strip', }; -export const GPUCompareFunction = { - Never: 'never', - Less: 'less', - Equal: 'equal', - LessEqual: 'less-equal', - Greater: 'greater', - NotEqual: 'not-equal', - GreaterEqual: 'greater-equal', - Always: 'always' +export const CompareFunction = { + Never: 'never' as GPUCompareFunction, + Less: 'less' as GPUCompareFunction, + Equal: 'equal' as GPUCompareFunction, + LessEqual: 'less-equal' as GPUCompareFunction, + Greater: 'greater' as GPUCompareFunction, + NotEqual: 'not-equal' as GPUCompareFunction, + GreaterEqual: 'greater-equal' as GPUCompareFunction, + Always: 'always' as GPUCompareFunction, }; export const StoreOp = { - Store: 'store'as GPUStoreOp, - Discard: 'discard'as GPUStoreOp + Store: 'store' as GPUStoreOp, + Discard: 'discard' as GPUStoreOp }; export const LoadOp = { Load: 'load' as GPULoadOp, - Clear: 'clear'as GPULoadOp + Clear: 'clear' as GPULoadOp }; export const GPUFrontFace = { @@ -40,7 +40,7 @@ export const GPUCullMode = { export const IndexFormat = { Uint16: 'uint16' as GPUIndexFormat, - Uint32: 'uint32'as GPUIndexFormat + Uint32: 'uint32' as GPUIndexFormat }; export const GPUVertexFormat = { @@ -81,19 +81,19 @@ export const TextureFormat = { // 8-bit formats R8Unorm: 'r8unorm' as GPUTextureFormat, - R8Snorm: 'r8snorm'as GPUTextureFormat, - R8Uint: 'r8uint'as GPUTextureFormat, - R8Sint: 'r8sint'as GPUTextureFormat, + R8Snorm: 'r8snorm' as GPUTextureFormat, + R8Uint: 'r8uint' as GPUTextureFormat, + R8Sint: 'r8sint' as GPUTextureFormat, // 16-bit formats - R16Uint: 'r16uint'as GPUTextureFormat, - R16Sint: 'r16sint'as GPUTextureFormat, - R16Float: 'r16float'as GPUTextureFormat, - RG8Unorm: 'rg8unorm'as GPUTextureFormat, - RG8Snorm: 'rg8snorm'as GPUTextureFormat, - RG8Uint: 'rg8uint'as GPUTextureFormat, - RG8Sint: 'rg8sint'as GPUTextureFormat, + R16Uint: 'r16uint' as GPUTextureFormat, + R16Sint: 'r16sint' as GPUTextureFormat, + R16Float: 'r16float' as GPUTextureFormat, + RG8Unorm: 'rg8unorm' as GPUTextureFormat, + RG8Snorm: 'rg8snorm' as GPUTextureFormat, + RG8Uint: 'rg8uint' as GPUTextureFormat, + RG8Sint: 'rg8sint' as GPUTextureFormat, // 32-bit formats @@ -114,7 +114,7 @@ export const TextureFormat = { // Packed 32-bit formats RGB9E5UFloat: 'rgb9e5ufloat' as GPUTextureFormat,//hdr RGB10A2Unorm: 'rgb10a2unorm' as GPUTextureFormat, - RG11B10uFloat: 'rgb10a2unorm'as GPUTextureFormat, + RG11B10uFloat: 'rgb10a2unorm' as GPUTextureFormat, // 64-bit formats @@ -289,12 +289,12 @@ export const TextureDimension = { }; export const TextureViewDimension = { - OneD: '1d' as GPUTextureViewDimension, - TwoD: '2d' as GPUTextureViewDimension, - TwoDArray: '2d-array' as GPUTextureViewDimension, - Cube: 'cube' as GPUTextureViewDimension, - CubeArray: 'cube-array' as GPUTextureViewDimension, - ThreeD: '3d' as GPUTextureViewDimension + OneD: '1d' as GPUTextureViewDimension, + TwoD: '2d' as GPUTextureViewDimension, + TwoDArray: '2d-array' as GPUTextureViewDimension, + Cube: 'cube' as GPUTextureViewDimension, + CubeArray: 'cube-array' as GPUTextureViewDimension, + ThreeD: '3d' as GPUTextureViewDimension }; export const GPUTextureAspect = { diff --git a/frontend/src/lib/core/Material.ts b/frontend/src/lib/core/Material.ts index 71eff894..48b859e2 100644 --- a/frontend/src/lib/core/Material.ts +++ b/frontend/src/lib/core/Material.ts @@ -2,7 +2,7 @@ import ObjectGPU from "./ObjectGPU"; import Renderer from "../Renderer"; import Shader from "./Shader"; import RenderPass from "./RenderPass"; -import {TextureFormat} from "../WebGPUConstants"; +import {CompareFunction} from "../WebGPUConstants"; import UniformGroup from "./UniformGroup"; import ModelTransform from "../model/ModelTransform"; import Camera from "../Camera"; @@ -11,10 +11,14 @@ export default class Material extends ObjectGPU { shader: Shader; pipeLine: GPURenderPipeline; private pipeLineLayout: GPUPipelineLayout; - //private renderPass: RenderPass; + private colorTargets:Array=[]; + private depthStencilState:GPUDepthStencilState; private needsDepth: boolean =true; public uniforms:UniformGroup; + public depthWrite: boolean =true; + public depthCompare: GPUCompareFunction=CompareFunction.Less; + constructor(renderer: Renderer, label: string, shader: Shader) { super(renderer, label); this.shader = shader; @@ -29,7 +33,19 @@ export default class Material extends ObjectGPU { if(this.pipeLine)return; this.colorTargets =[] - this.colorTargets.push({ format: TextureFormat.BGRA8Unorm as GPUTextureFormat }); + + for(let a of pass.colorAttachments){ + + this.colorTargets.push({ format: a.renderTexture.options.format }); + } + if(pass.depthStencilAttachment){ + this.needsDepth =true; + this.depthStencilState={ + depthWriteEnabled: this.depthWrite, + depthCompare: this.depthCompare, + format: pass.depthStencilAttachment.renderTexture.options.format, + } + } this.makePipeLineLayout() @@ -64,23 +80,22 @@ export default class Material extends ObjectGPU { }, }; if (this.needsDepth) { - desc.depthStencil = { - depthWriteEnabled: true, - depthCompare: "less", - format: "depth16unorm", - }; + desc.depthStencil =this.depthStencilState; } return desc; } private makePipeLineLayout() { + let layouts =[] + if(this.shader.needsCamera)layouts.push(Camera.getBindGroupLayout()) + if(this.shader.needsTransform)layouts.push(ModelTransform.getBindGroupLayout()) + layouts.push(this.uniforms.bindGroupLayout) + this.pipeLineLayout= this.device.createPipelineLayout({ label: "Material_pipelineLayout_" + this.label, - bindGroupLayouts: [Camera.getBindGroupLayout(),ModelTransform.getBindGroupLayout(),this.uniforms.bindGroupLayout], + bindGroupLayouts: layouts, }); } - /*setRenderPass(renderPass: RenderPass) { - this.renderPass =renderPass; - }*/ + } diff --git a/frontend/src/lib/core/Shader.ts b/frontend/src/lib/core/Shader.ts index af5f67f8..922484cf 100644 --- a/frontend/src/lib/core/Shader.ts +++ b/frontend/src/lib/core/Shader.ts @@ -3,64 +3,72 @@ import Renderer from "../Renderer"; import Attribute from "./Attribute"; import UniformGroup from "./UniformGroup"; import MathArray from "@math.gl/core/src/classes/base/math-array"; -import Camera from "../Camera"; import Material from "./Material"; import Texture from "../textures/Texture"; import {TextureDimension} from "../WebGPUConstants"; import {ShaderType} from "./ShaderTypes"; -export default class Shader extends ObjectGPU -{ +export default class Shader extends ObjectGPU { attributes: Array = []; shader: GPUShaderModule; tempMaterial: Material - constructor(renderer:Renderer,label="") { - super(renderer,label); + + public needsTransform: boolean = false; + public needsCamera: boolean = false; + public logShaderCode = false; + + constructor(renderer: Renderer, label = "") { + super(renderer, label); + + } + + init() { } - init(){} - public addUniform(name:string, value:MathArray | number,usage:GPUShaderStageFlags =GPUShaderStage.FRAGMENT,format=ShaderType.auto,arraySize=1) - { - if(!this.tempMaterial.uniforms) this.tempMaterial.uniforms =new UniformGroup(this.renderer,this.label,"uniforms") + public addUniform(name: string, value: MathArray | number, usage: GPUShaderStageFlags = GPUShaderStage.FRAGMENT, format = ShaderType.auto, arraySize = 1) { + if (!this.tempMaterial.uniforms) this.tempMaterial.uniforms = new UniformGroup(this.renderer, this.label, "uniforms") - this.tempMaterial.uniforms.addUniform(name,value) + this.tempMaterial.uniforms.addUniform(name, value) } - public addTexture(name:string, value:Texture,dimension:GPUTextureViewDimension=TextureDimension.TwoD,usage:GPUShaderStageFlags =GPUShaderStage.FRAGMENT) - { - if(!this.tempMaterial.uniforms) this.tempMaterial.uniforms =new UniformGroup(this.renderer,this.label,"uniforms") - this.tempMaterial.uniforms.addTexture(name,value,dimension,usage); + + public addTexture(name: string, value: Texture, dimension: GPUTextureViewDimension = TextureDimension.TwoD, usage: GPUShaderStageFlags = GPUShaderStage.FRAGMENT) { + if (!this.tempMaterial.uniforms) this.tempMaterial.uniforms = new UniformGroup(this.renderer, this.label, "uniforms") + this.tempMaterial.uniforms.addTexture(name, value, dimension, usage); } - public addSampler(name:string) - { - if(!this.tempMaterial.uniforms) this.tempMaterial.uniforms =new UniformGroup(this.renderer,this.label,"uniforms") + + public addSampler(name: string) { + if (!this.tempMaterial.uniforms) this.tempMaterial.uniforms = new UniformGroup(this.renderer, this.label, "uniforms") this.tempMaterial.uniforms.addSampler(name); } - public addVertexOutput(name:string,length: number){ + + public addVertexOutput(name: string, length: number) { } - public addAttribute(name: string, type:string,arrayLength=1) { - let at = new Attribute(name, type,arrayLength); + + public addAttribute(name: string, type: string, arrayLength = 1) { + let at = new Attribute(name, type, arrayLength); at.slot = this.attributes.length; this.attributes.push(at); } - public getShaderUniforms() - { - let a ="" - if(this.tempMaterial.uniforms){ - a =this.tempMaterial.uniforms.getShaderText(2) + + public getShaderUniforms(index: number) { + let a = "" + if (this.tempMaterial.uniforms) { + a = this.tempMaterial.uniforms.getShaderText(index) } return a; } + public getShaderAttributes() { let a = ""; @@ -72,26 +80,22 @@ export default class Shader extends ObjectGPU } public getShader() { - if(this.shader) return this.shader -console.log(this.getShaderCode()) + if (this.shader) return this.shader + if (this.logShaderCode) console.log(this.getShaderCode()) this.shader = this.device.createShaderModule({ label: "shader_" + this.label, code: this.getShaderCode(), }); - return this.shader - } - - protected getShaderCode(): string { - return ``; + return this.shader } getVertexBufferLayout() { - let bufferLayout:Array = []; + let bufferLayout: Array = []; for (let atr of this.attributes) { - let vertexAtr:GPUVertexAttribute={ + let vertexAtr: GPUVertexAttribute = { shaderLocation: atr.slot, offset: 0, format: atr.format } @@ -105,4 +109,8 @@ console.log(this.getShaderCode()) } return bufferLayout; } + + protected getShaderCode(): string { + return ``; + } } diff --git a/frontend/src/lib/loaders/OBJLoader.ts b/frontend/src/lib/loaders/OBJLoader.ts deleted file mode 100644 index 661e9490..00000000 --- a/frontend/src/lib/loaders/OBJLoader.ts +++ /dev/null @@ -1,165 +0,0 @@ -import Mesh from "../core/Mesh"; -import Renderer from "../Renderer"; -import PreLoader from "../PreLoader"; -import {Vector2, Vector3} from "math.gl"; - -class Triangle{ - p0:Vector3; - p1:Vector3; - p2:Vector3; - - n0:Vector3; - n1:Vector3; - n2:Vector3; - - u0:Vector2; - u1:Vector2; - u2:Vector2; -} - - -export default class OBJLoader extends Mesh -{ - - private triangles: Array=[]; - constructor(renderer:Renderer,url:string,preLoader:PreLoader) { - super(renderer,url) - - preLoader.startLoad(); - this.loadURL(url).then(() => { - preLoader.stopLoad(); - }); - } - - - async loadURL(url: any) { - const response = await fetch(url) - let text = await response.text() - this.parseOBJ(text); - - let vertices: Float32Array =new Float32Array(3*3*this.triangles.length) - let normals: Float32Array =new Float32Array(3*3*this.triangles.length) - let uvs: Float32Array =new Float32Array(2*3*this.triangles.length) - let indices: Uint32Array = new Uint32Array(3*this.triangles.length); - let vCount =0; - let nCount =0; - let uCount =0; - let indexCount =0; - for(let t of this.triangles) - { - - indices [indexCount]=indexCount++ - indices [indexCount]=indexCount++ - indices [indexCount]=indexCount++ - - vertices[vCount++] = t.p0.x; - vertices[vCount++] = t.p0.y; - vertices[vCount++] = t.p0.z; - - vertices[vCount++] = t.p1.x; - vertices[vCount++] = t.p1.y; - vertices[vCount++] = t.p1.z; - - vertices[vCount++] = t.p2.x; - vertices[vCount++] = t.p2.y; - vertices[vCount++] = t.p2.z; - - - normals[nCount++] = t.n0.x; - normals[nCount++] = t.n0.y; - normals[nCount++] = t.n0.z; - - normals[nCount++] = t.n1.x; - normals[nCount++] = t.n1.y; - normals[nCount++] = t.n1.z; - - normals[nCount++] = t.n2.x; - normals[nCount++] = t.n2.y; - normals[nCount++] = t.n2.z; - - uvs[uCount++] = t.u0.x; - uvs[uCount++] = t.u0.y; - - uvs[uCount++] = t.u1.x; - uvs[uCount++] = t.u1.y; - - uvs[uCount++] = t.u2.x; - uvs[uCount++] = t.u2.y; - - - } - this.setVertices(vertices); - this.setNormals(normals); - this.setUV0(uvs); - - this.setIndices32(indices); - } - - public parseOBJ(text:string) - { - const lines = text.split('\n'); - // v float float float - const vertex_pattern = /v( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/; - - // vn float float float - - const normal_pattern = /vn( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/; - - // vt float float - - const uv_pattern = /vt( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/; - - // f vertex/uv/normal vertex/uv/normal vertex/uv/normal ... - - const face_pattern3 = /f( +(-?\d+)\/(-?\d+)\/(-?\d+))( +(-?\d+)\/(-?\d+)\/(-?\d+))( +(-?\d+)\/(-?\d+)\/(-?\d+))( +(-?\d+)\/(-?\d+)\/(-?\d+))?/; - - const vertices:Array = []; - const normals:Array = []; - const uvs:Array = []; - - for (let i = 0; i < lines.length; i++) { - let line = lines[i]; - line = line.trim(); - let result; - - if (line.length === 0 || line.charAt(0) === '#') { - - } - else if ((result = vertex_pattern.exec(line)) !== null) { - // ["v 1.0 2.0 3.0", "1.0", "2.0", "3.0"] - - vertices.push(new Vector3(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3]))); - } else if ((result = normal_pattern.exec(line)) !== null) { - // ["vn 1.0 2.0 3.0", "1.0", "2.0", "3.0"] - - normals.push(new Vector3(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3]))); - } else if ((result = uv_pattern.exec(line)) !== null) { - // ["vt 0.1 0.2", "0.1", "0.2"] - - uvs.push(new Vector2(parseFloat(result[1]), parseFloat(result[2]))); - }else if ((result = face_pattern3.exec(line)) !== null) { - result = face_pattern3.exec(line) - let p1 =vertices[parseInt(result[2])] - - let t =new Triangle(); - t.p0=vertices[parseInt(result[2])-1]; - t.p1=vertices[parseInt(result[6])-1]; - t.p2=vertices[parseInt(result[10])-1]; - - t.u0=uvs[parseInt(result[3])-1]; - t.u1=uvs[parseInt(result[7])-1]; - t.u2=uvs[parseInt(result[11])-1]; - - - t.n0=normals[parseInt(result[4])-1]; - t.n1=normals[parseInt(result[8])-1]; - t.n2=normals[parseInt(result[12])-1]; - - - this.triangles.push(t) - - } - } - - } -} diff --git a/frontend/src/lib/textures/ColorAttachment.ts b/frontend/src/lib/textures/ColorAttachment.ts index f2d4209d..8cd9d3d7 100644 --- a/frontend/src/lib/textures/ColorAttachment.ts +++ b/frontend/src/lib/textures/ColorAttachment.ts @@ -15,7 +15,7 @@ export const ColorAttachmentOptionsDefault: ColorAttachmentOptions = { } export default class ColorAttachment { public options: ColorAttachmentOptions - private renderTexture: RenderTexture; + public renderTexture: RenderTexture; private target: GPUTextureView =null; private dirty: boolean; diff --git a/frontend/src/lib/textures/DepthStencilAttachment.ts b/frontend/src/lib/textures/DepthStencilAttachment.ts index 5217ec34..51c0b8d1 100644 --- a/frontend/src/lib/textures/DepthStencilAttachment.ts +++ b/frontend/src/lib/textures/DepthStencilAttachment.ts @@ -25,7 +25,7 @@ export const DepthStencilAttachmentOptionsDefault: DepthStencilAttachmentOptions } export default class DepthStencilAttachment { public options: DepthStencilAttachmentOptions - private renderTexture: RenderTexture; + public renderTexture: RenderTexture; constructor(renderTexture: RenderTexture, options: Partial=DepthStencilAttachmentOptionsDefault) { this.renderTexture =renderTexture; diff --git a/frontend/src/lib/textures/Texture.ts b/frontend/src/lib/textures/Texture.ts index ebac382b..33627b7b 100644 --- a/frontend/src/lib/textures/Texture.ts +++ b/frontend/src/lib/textures/Texture.ts @@ -29,7 +29,7 @@ export const TextureOptionsDefault:TextureOptions ={ export default class Texture extends ObjectGPU{ public textureGPU!: GPUTexture; - protected options:TextureOptions; + public options:TextureOptions; public isDirty:boolean =true; constructor(renderer:Renderer,label:string ="",options: Partial ) { super(renderer,label); diff --git a/frontend/src/shaders/BlitShader.ts b/frontend/src/shaders/BlitShader.ts new file mode 100644 index 00000000..67c7bce5 --- /dev/null +++ b/frontend/src/shaders/BlitShader.ts @@ -0,0 +1,70 @@ +import Shader from "../lib/core/Shader"; +import {ShaderType} from "../lib/core/ShaderTypes"; +import DefaultTextures from "../lib/textures/DefaultTextures"; +import Camera from "../lib/Camera"; +import ModelTransform from "../lib/model/ModelTransform"; + +export default class BlitShader extends Shader{ + + + init(){ + + if(this.attributes.length==0) { + this.addAttribute("aPos", ShaderType.vec3); + this.addAttribute("aUV0", ShaderType.vec2); + + } +this.addUniform("test",1) + this.addTexture("colorTexture",DefaultTextures.getWhite(this.renderer)) + this.addSampler("mySampler"); + + } + getShaderCode(): string { + return /* wgsl */ ` +/////////////////////////////////////////////////////////// +struct VertexOutput +{ + @location(0) uv0 : vec2f, + + @builtin(position) position : vec4f + +} + +${this.getShaderUniforms(0)} + +@vertex +fn mainVertex( ${this.getShaderAttributes()} ) -> VertexOutput +{ + var output : VertexOutput; + + + + output.position =vec4( aPos,1.0); + + + output.uv0 =aUV0; + + return output; +} + + +@fragment +fn mainFragment(@location(0) uv0: vec2f) -> @location(0) vec4f +{ + return textureSample(colorTexture, mySampler, uv0) ; +} +/////////////////////////////////////////////////////////// + + + + + + + + + ` + } + + + +} diff --git a/frontend/src/shaders/TestShader.ts b/frontend/src/shaders/TestShader.ts index 93066413..28b8dfd4 100644 --- a/frontend/src/shaders/TestShader.ts +++ b/frontend/src/shaders/TestShader.ts @@ -7,6 +7,7 @@ import ModelTransform from "../lib/model/ModelTransform"; export default class TestShader extends Shader{ + init(){ if(this.attributes.length==0) { @@ -23,6 +24,8 @@ export default class TestShader extends Shader{ this.addSampler("mySampler") // this.addVertexOutput("normal",3); // this.addVertexOutput("uv0",2); + this.needsTransform =true; + this.needsCamera=true; } getShaderCode(): string { return /* wgsl */ ` @@ -39,7 +42,7 @@ struct VertexOutput } ${Camera.getShaderText(0)} ${ModelTransform.getShaderText(1)} -${this.getShaderUniforms()} +${this.getShaderUniforms(2)} const PI = 3.14159265359; fn fresnelSchlick(cosTheta:f32, F0:vec3f)-> vec3f