ris-framework 0.1.0 → 0.2.0-dev.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -1
- package/README.md +27 -4
- package/dist/Framework.d.ts +34 -10
- package/dist/Framework.d.ts.map +1 -1
- package/dist/api/IFramework.d.ts +50 -6
- package/dist/api/IFramework.d.ts.map +1 -1
- package/dist/api/_export.d.ts +3 -1
- package/dist/api/_export.d.ts.map +1 -1
- package/dist/api/camera/CameraFactory.d.ts +3 -2
- package/dist/api/camera/CameraFactory.d.ts.map +1 -1
- package/dist/api/camera/ICamera.d.ts +5 -0
- package/dist/api/camera/ICamera.d.ts.map +1 -1
- package/dist/api/camera/ICameraFactory.d.ts +5 -6
- package/dist/api/camera/ICameraFactory.d.ts.map +1 -1
- package/dist/api/camera/OrthographicCamera.d.ts +7 -0
- package/dist/api/camera/OrthographicCamera.d.ts.map +1 -1
- package/dist/api/camera/PerspectiveCamera.d.ts +30 -6
- package/dist/api/camera/PerspectiveCamera.d.ts.map +1 -1
- package/dist/api/content/ContentManager.d.ts +15 -2
- package/dist/api/content/ContentManager.d.ts.map +1 -1
- package/dist/api/content/IContentManager.d.ts +35 -1
- package/dist/api/content/IContentManager.d.ts.map +1 -1
- package/dist/api/content/ShaderModuleContent.d.ts.map +1 -1
- package/dist/api/data/Color.d.ts +5 -0
- package/dist/api/data/Color.d.ts.map +1 -1
- package/dist/api/geometry/BaseGeometry.d.ts +9 -0
- package/dist/api/geometry/BaseGeometry.d.ts.map +1 -1
- package/dist/api/geometry/GeometryBuilder.d.ts +3 -1
- package/dist/api/geometry/GeometryBuilder.d.ts.map +1 -1
- package/dist/api/geometry/IGeometryBuilder.d.ts +24 -0
- package/dist/api/geometry/IGeometryBuilder.d.ts.map +1 -1
- package/dist/api/geometry/_export-geometry.d.ts +1 -0
- package/dist/api/geometry/_export-geometry.d.ts.map +1 -1
- package/dist/api/input/InputManager.d.ts +4 -0
- package/dist/api/input/InputManager.d.ts.map +1 -1
- package/dist/api/lights/AmbientLight.d.ts +35 -0
- package/dist/api/lights/AmbientLight.d.ts.map +1 -0
- package/dist/api/lights/DirectionalLight.d.ts +40 -0
- package/dist/api/lights/DirectionalLight.d.ts.map +1 -0
- package/dist/api/lights/LightFactory.d.ts +18 -0
- package/dist/api/lights/LightFactory.d.ts.map +1 -0
- package/dist/api/lights/LightId.d.ts +6 -0
- package/dist/api/lights/LightId.d.ts.map +1 -0
- package/dist/api/lights/LightsBuffer.d.ts +77 -0
- package/dist/api/lights/LightsBuffer.d.ts.map +1 -0
- package/dist/api/lights/PointLight.d.ts +59 -0
- package/dist/api/lights/PointLight.d.ts.map +1 -0
- package/dist/api/lights/_export.d.ts +6 -0
- package/dist/api/lights/_export.d.ts.map +1 -0
- package/dist/api/loaders/ObjGeometryMapper.d.ts +19 -0
- package/dist/api/loaders/ObjGeometryMapper.d.ts.map +1 -0
- package/dist/api/loaders/ObjLoader.d.ts +61 -0
- package/dist/api/loaders/ObjLoader.d.ts.map +1 -0
- package/dist/api/loaders/_export.d.ts +2 -0
- package/dist/api/loaders/_export.d.ts.map +1 -1
- package/dist/api/loaders/obj/ObjParser.d.ts +44 -0
- package/dist/api/loaders/obj/ObjParser.d.ts.map +1 -0
- package/dist/api/loaders/obj/ObjTypes.d.ts +119 -0
- package/dist/api/loaders/obj/ObjTypes.d.ts.map +1 -0
- package/dist/api/loaders/obj/index.d.ts +3 -0
- package/dist/api/loaders/obj/index.d.ts.map +1 -0
- package/dist/api/material/ForwardBlinnPhongMaterial.d.ts +138 -0
- package/dist/api/material/ForwardBlinnPhongMaterial.d.ts.map +1 -0
- package/dist/api/material/ICameraMaterial.d.ts +18 -0
- package/dist/api/material/ICameraMaterial.d.ts.map +1 -0
- package/dist/api/material/ILightsMaterial.d.ts +26 -0
- package/dist/api/material/ILightsMaterial.d.ts.map +1 -0
- package/dist/api/material/IMaterial.d.ts +13 -10
- package/dist/api/material/IMaterial.d.ts.map +1 -1
- package/dist/api/material/IMaterialFactory.d.ts +17 -2
- package/dist/api/material/IMaterialFactory.d.ts.map +1 -1
- package/dist/api/material/InspectTextureMipsMaterial.d.ts +18 -9
- package/dist/api/material/InspectTextureMipsMaterial.d.ts.map +1 -1
- package/dist/api/material/MaterialFactory.d.ts +6 -0
- package/dist/api/material/MaterialFactory.d.ts.map +1 -1
- package/dist/api/material/SpriteMaterial.d.ts +51 -0
- package/dist/api/material/SpriteMaterial.d.ts.map +1 -0
- package/dist/api/material/UnlitMaterial.d.ts +32 -13
- package/dist/api/material/UnlitMaterial.d.ts.map +1 -1
- package/dist/api/material/_export.d.ts +4 -0
- package/dist/api/material/_export.d.ts.map +1 -1
- package/dist/api/meshes/IMesh.d.ts +31 -6
- package/dist/api/meshes/IMesh.d.ts.map +1 -1
- package/dist/api/meshes/IMeshFactory.d.ts +30 -4
- package/dist/api/meshes/IMeshFactory.d.ts.map +1 -1
- package/dist/api/meshes/IRenderableMesh.d.ts +47 -0
- package/dist/api/meshes/IRenderableMesh.d.ts.map +1 -0
- package/dist/api/meshes/Mesh.d.ts +14 -8
- package/dist/api/meshes/Mesh.d.ts.map +1 -1
- package/dist/api/meshes/MeshFactory.d.ts +10 -3
- package/dist/api/meshes/MeshFactory.d.ts.map +1 -1
- package/dist/api/meshes/QuadMesh.d.ts +5 -3
- package/dist/api/meshes/QuadMesh.d.ts.map +1 -1
- package/dist/api/meshes/RenderableMesh.d.ts +95 -0
- package/dist/api/meshes/RenderableMesh.d.ts.map +1 -0
- package/dist/api/meshes/_export.d.ts +2 -0
- package/dist/api/meshes/_export.d.ts.map +1 -1
- package/dist/api/rendering/IGraphicsDeviceFeatures.d.ts +8 -2
- package/dist/api/rendering/IGraphicsDeviceFeatures.d.ts.map +1 -1
- package/dist/api/rendering/IRenderer.d.ts +28 -1
- package/dist/api/rendering/IRenderer.d.ts.map +1 -1
- package/dist/api/rendering/enums.d.ts +7 -0
- package/dist/api/rendering/enums.d.ts.map +1 -1
- package/dist/api/rendering/render-pipelines/IForwardBlinnPhongRenderPipeline.d.ts +56 -0
- package/dist/api/rendering/render-pipelines/IForwardBlinnPhongRenderPipeline.d.ts.map +1 -0
- package/dist/api/rendering/render-pipelines/IRenderPipeline.d.ts +3 -0
- package/dist/api/rendering/render-pipelines/IRenderPipeline.d.ts.map +1 -1
- package/dist/api/rendering/render-pipelines/IRenderPipelineFactory.d.ts +29 -0
- package/dist/api/rendering/render-pipelines/IRenderPipelineFactory.d.ts.map +1 -1
- package/dist/api/rendering/render-pipelines/_export-render-pipelines.d.ts +1 -0
- package/dist/api/rendering/render-pipelines/_export-render-pipelines.d.ts.map +1 -1
- package/dist/api/rendering/renderer-interface.d.ts +1 -31
- package/dist/api/rendering/renderer-interface.d.ts.map +1 -1
- package/dist/api/rendering/renderpass/RenderPassDescriptor.d.ts +2 -6
- package/dist/api/rendering/renderpass/RenderPassDescriptor.d.ts.map +1 -1
- package/dist/api/rendering/swapchain/ISwapChain.d.ts +1 -3
- package/dist/api/rendering/swapchain/ISwapChain.d.ts.map +1 -1
- package/dist/api/rendering/texture/TextureFormat.d.ts +88 -14
- package/dist/api/rendering/texture/TextureFormat.d.ts.map +1 -1
- package/dist/api/rendering/texture/TextureUtilities.d.ts +23 -0
- package/dist/api/rendering/texture/TextureUtilities.d.ts.map +1 -1
- package/dist/api/scene/Scene.d.ts +113 -0
- package/dist/api/scene/Scene.d.ts.map +1 -0
- package/dist/api/scene/SceneMesh.d.ts +27 -0
- package/dist/api/scene/SceneMesh.d.ts.map +1 -0
- package/dist/api/shader/IShaderModuleLoader.d.ts +4 -1
- package/dist/api/shader/IShaderModuleLoader.d.ts.map +1 -1
- package/dist/api/shader/{shader-loader.d.ts → ShaderLoader.d.ts} +1 -1
- package/dist/api/shader/ShaderLoader.d.ts.map +1 -0
- package/dist/api/sprites/SpriteBatchDrawable.d.ts +1 -1
- package/dist/api/sprites/SpriteBatchDrawable.d.ts.map +1 -1
- package/dist/api/sprites/SpriteBatchMesh.d.ts +14 -1
- package/dist/api/sprites/SpriteBatchMesh.d.ts.map +1 -1
- package/dist/api/utilities/AlignUtilities.d.ts.map +1 -1
- package/dist/api/utilities/GeometryUtilities.d.ts.map +1 -1
- package/dist/api/window/WindowManager.d.ts +4 -0
- package/dist/api/window/WindowManager.d.ts.map +1 -1
- package/dist/core/rendering/ARenderer.d.ts +5 -5
- package/dist/core/rendering/ARenderer.d.ts.map +1 -1
- package/dist/core/rendering/vertex-buffer-layout.d.ts +1 -0
- package/dist/core/rendering/vertex-buffer-layout.d.ts.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9238 -4595
- package/dist/webgl/WebGLGraphicsDeviceFeatures.d.ts +4 -0
- package/dist/webgl/WebGLGraphicsDeviceFeatures.d.ts.map +1 -1
- package/dist/webgl/WebGlGraphicsDevice.d.ts.map +1 -1
- package/dist/webgl/WebGlRenderer.d.ts +1 -3
- package/dist/webgl/WebGlRenderer.d.ts.map +1 -1
- package/dist/webgl/lights/WebGlAmbientLightFactory.d.ts +17 -0
- package/dist/webgl/lights/WebGlAmbientLightFactory.d.ts.map +1 -0
- package/dist/webgl/lights/WebGlLightsBuffer.d.ts +59 -0
- package/dist/webgl/lights/WebGlLightsBuffer.d.ts.map +1 -0
- package/dist/webgl/render-pipelines/AWebGlRenderPipeline.d.ts +3 -1
- package/dist/webgl/render-pipelines/AWebGlRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.d.ts +5 -0
- package/dist/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/WebGlRenderPipelineFactory.d.ts +3 -1
- package/dist/webgl/render-pipelines/WebGlRenderPipelineFactory.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/inspect/WebGlInspectTextureMipsRenderPipeline.d.ts +3 -1
- package/dist/webgl/render-pipelines/inspect/WebGlInspectTextureMipsRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/material/WebGlBlinnPhongRenderPipeline.d.ts +88 -0
- package/dist/webgl/render-pipelines/material/WebGlBlinnPhongRenderPipeline.d.ts.map +1 -0
- package/dist/webgl/render-pipelines/material/WebGlUnlitRenderPipeline.d.ts +3 -1
- package/dist/webgl/render-pipelines/material/WebGlUnlitRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/sprite/WebGlSpriteRenderPipeline.d.ts +3 -1
- package/dist/webgl/render-pipelines/sprite/WebGlSpriteRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/shader/WebGlShaderModule.d.ts +4 -1
- package/dist/webgl/shader/WebGlShaderModule.d.ts.map +1 -1
- package/dist/webgl/shader/WebGlShaderModuleLoader.d.ts +16 -5
- package/dist/webgl/shader/WebGlShaderModuleLoader.d.ts.map +1 -1
- package/dist/webgl/swap-chain/WebGlSwapChain.d.ts +3 -2
- package/dist/webgl/swap-chain/WebGlSwapChain.d.ts.map +1 -1
- package/dist/webgl/texture/WebGlTexture2D.d.ts +8 -1
- package/dist/webgl/texture/WebGlTexture2D.d.ts.map +1 -1
- package/dist/webgl/texture/WebGlTextureFactory.d.ts +7 -0
- package/dist/webgl/texture/WebGlTextureFactory.d.ts.map +1 -1
- package/dist/webgl/utilities/WebGlConstants.d.ts +91 -0
- package/dist/webgl/utilities/WebGlConstants.d.ts.map +1 -0
- package/dist/webgl/utilities/WebGlConverter.d.ts +0 -7
- package/dist/webgl/utilities/WebGlConverter.d.ts.map +1 -1
- package/dist/webgl/utilities/WebGlErrorUtilities.d.ts +10 -0
- package/dist/webgl/utilities/WebGlErrorUtilities.d.ts.map +1 -0
- package/dist/webgl/utilities/WebGlTextureUtilities.d.ts.map +1 -1
- package/dist/webgl/utilities/WebGlUtilities.d.ts +3 -0
- package/dist/webgl/utilities/WebGlUtilities.d.ts.map +1 -1
- package/dist/webgl/utilities/webgl-filter-anisotropic-utilities.d.ts +0 -1
- package/dist/webgl/utilities/webgl-filter-anisotropic-utilities.d.ts.map +1 -1
- package/dist/webgpu/WebGpuGpuInfo.d.ts +28 -0
- package/dist/webgpu/WebGpuGpuInfo.d.ts.map +1 -0
- package/dist/webgpu/WebGpuGraphicsDevice.d.ts +80 -0
- package/dist/webgpu/WebGpuGraphicsDevice.d.ts.map +1 -0
- package/dist/webgpu/WebGpuGraphicsDeviceFeatures.d.ts +26 -0
- package/dist/webgpu/WebGpuGraphicsDeviceFeatures.d.ts.map +1 -0
- package/dist/webgpu/WebGpuRenderer.d.ts +26 -0
- package/dist/webgpu/WebGpuRenderer.d.ts.map +1 -0
- package/dist/webgpu/WebGpuTypes.d.ts +355 -0
- package/dist/webgpu/WebGpuTypes.d.ts.map +1 -0
- package/dist/webgpu/blending/WebGpuBlendState.d.ts +30 -0
- package/dist/webgpu/blending/WebGpuBlendState.d.ts.map +1 -0
- package/dist/webgpu/buffers/WebGpuBuffersFactory.d.ts +20 -0
- package/dist/webgpu/buffers/WebGpuBuffersFactory.d.ts.map +1 -0
- package/dist/webgpu/buffers/WebGpuIndexBuffer.d.ts +46 -0
- package/dist/webgpu/buffers/WebGpuIndexBuffer.d.ts.map +1 -0
- package/dist/webgpu/buffers/WebGpuUniformBuffer.d.ts +43 -0
- package/dist/webgpu/buffers/WebGpuUniformBuffer.d.ts.map +1 -0
- package/dist/webgpu/buffers/WebGpuVertexBuffer.d.ts +49 -0
- package/dist/webgpu/buffers/WebGpuVertexBuffer.d.ts.map +1 -0
- package/dist/webgpu/primitive/WebGpuPrimitiveState.d.ts +32 -0
- package/dist/webgpu/primitive/WebGpuPrimitiveState.d.ts.map +1 -0
- package/dist/webgpu/render-pass/WebGpuRenderPass.d.ts +28 -0
- package/dist/webgpu/render-pass/WebGpuRenderPass.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/AWebGpuRenderPipeline.d.ts +50 -0
- package/dist/webgpu/render-pipelines/AWebGpuRenderPipeline.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.d.ts +34 -0
- package/dist/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/WebGpuRenderPipelineFactory.d.ts +26 -0
- package/dist/webgpu/render-pipelines/WebGpuRenderPipelineFactory.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/material/AWebGpuMeshRenderPipeline.d.ts +72 -0
- package/dist/webgpu/render-pipelines/material/AWebGpuMeshRenderPipeline.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/material/WebGpuUnlitRenderPipeline.d.ts +40 -0
- package/dist/webgpu/render-pipelines/material/WebGpuUnlitRenderPipeline.d.ts.map +1 -0
- package/dist/webgpu/sampler/WebGpuSampler.d.ts +39 -0
- package/dist/webgpu/sampler/WebGpuSampler.d.ts.map +1 -0
- package/dist/webgpu/shader/WebGpuShaderModule.d.ts +29 -0
- package/dist/webgpu/shader/WebGpuShaderModule.d.ts.map +1 -0
- package/dist/webgpu/shader/WebGpuShaderModuleLoader.d.ts +21 -0
- package/dist/webgpu/shader/WebGpuShaderModuleLoader.d.ts.map +1 -0
- package/dist/webgpu/shader/WgslShaderContent.d.ts +9 -0
- package/dist/webgpu/shader/WgslShaderContent.d.ts.map +1 -0
- package/dist/webgpu/swap-chain/WebGpuSwapChain.d.ts +41 -0
- package/dist/webgpu/swap-chain/WebGpuSwapChain.d.ts.map +1 -0
- package/dist/webgpu/texture/WebGpuTexture2D.d.ts +47 -0
- package/dist/webgpu/texture/WebGpuTexture2D.d.ts.map +1 -0
- package/dist/webgpu/texture/WebGpuTextureFactory.d.ts +21 -0
- package/dist/webgpu/texture/WebGpuTextureFactory.d.ts.map +1 -0
- package/dist/webgpu/texture/WebGpuTextureView.d.ts +25 -0
- package/dist/webgpu/texture/WebGpuTextureView.d.ts.map +1 -0
- package/dist/webgpu/utilities/WebGpuConverter.d.ts +45 -0
- package/dist/webgpu/utilities/WebGpuConverter.d.ts.map +1 -0
- package/package.json +4 -4
- package/shaders/glsl/forward_blinn_phong_material_fs.glsl +110 -0
- package/shaders/glsl/forward_blinn_phong_material_vs.glsl +32 -0
- package/shaders/glsl/main_render_target_flip_y_fs.glsl +35 -1
- package/shaders/glsl/sprite_fs.glsl +1 -1
- package/shaders/glsl/unlit_material_fs.glsl +1 -1
- package/shaders/wgsl/forward_blinn_phong_material.wgsl +150 -0
- package/shaders/wgsl/inspect_texture_mips.wgsl +51 -0
- package/shaders/wgsl/main_frame_buffer.wgsl +35 -0
- package/shaders/wgsl/main_render_target_flip_y.wgsl +35 -0
- package/shaders/wgsl/sprite.wgsl +40 -0
- package/shaders/wgsl/unlit_material.wgsl +49 -0
- package/src/Framework.ts +156 -48
- package/src/api/IFramework.ts +63 -6
- package/src/api/_export.ts +3 -1
- package/src/api/camera/CameraFactory.ts +6 -6
- package/src/api/camera/ICamera.ts +6 -0
- package/src/api/camera/ICameraFactory.ts +5 -10
- package/src/api/camera/OrthographicCamera.ts +23 -1
- package/src/api/camera/PerspectiveCamera.ts +60 -15
- package/src/api/content/ContentManager.ts +78 -16
- package/src/api/content/IContentManager.ts +37 -1
- package/src/api/content/ShaderModuleContent.ts +9 -0
- package/src/api/data/Color.ts +7 -1
- package/src/api/geometry/BaseGeometry.ts +23 -0
- package/src/api/geometry/GeometryBuilder.ts +14 -2
- package/src/api/geometry/IGeometryBuilder.ts +31 -1
- package/src/api/geometry/_export-geometry.ts +2 -1
- package/src/api/input/InputManager.ts +14 -5
- package/src/api/lights/AmbientLight.ts +53 -0
- package/src/api/lights/DirectionalLight.ts +60 -0
- package/src/api/lights/LightFactory.ts +21 -0
- package/src/api/lights/LightId.ts +9 -0
- package/src/api/lights/LightsBuffer.ts +94 -0
- package/src/api/lights/PointLight.ts +91 -0
- package/src/api/lights/_export.ts +5 -0
- package/src/api/loaders/ObjGeometryMapper.ts +28 -0
- package/src/api/loaders/ObjLoader.ts +126 -0
- package/src/api/loaders/_export.ts +3 -1
- package/src/api/loaders/obj/ObjParser.ts +301 -0
- package/src/api/loaders/obj/ObjTypes.ts +142 -0
- package/src/api/loaders/obj/index.ts +5 -0
- package/src/api/material/ForwardBlinnPhongMaterial.ts +328 -0
- package/src/api/material/ICameraMaterial.ts +22 -0
- package/src/api/material/ILightsMaterial.ts +32 -0
- package/src/api/material/IMaterial.ts +13 -10
- package/src/api/material/IMaterialFactory.ts +19 -2
- package/src/api/material/InspectTextureMipsMaterial.ts +65 -26
- package/src/api/material/MaterialFactory.ts +12 -0
- package/src/api/material/SpriteMaterial.ts +83 -0
- package/src/api/material/UnlitMaterial.ts +105 -32
- package/src/api/material/_export.ts +5 -1
- package/src/api/meshes/IMesh.ts +40 -6
- package/src/api/meshes/IMeshFactory.ts +33 -4
- package/src/api/meshes/IRenderableMesh.ts +58 -0
- package/src/api/meshes/Mesh.ts +50 -43
- package/src/api/meshes/MeshFactory.ts +37 -4
- package/src/api/meshes/QuadMesh.ts +6 -4
- package/src/api/meshes/RenderableMesh.ts +207 -0
- package/src/api/meshes/_export.ts +6 -4
- package/src/api/rendering/IGraphicsDeviceFeatures.ts +28 -21
- package/src/api/rendering/IRenderer.ts +34 -1
- package/src/api/rendering/enums.ts +10 -0
- package/src/api/rendering/render-pipelines/IForwardBlinnPhongRenderPipeline.ts +66 -0
- package/src/api/rendering/render-pipelines/IRenderPipeline.ts +4 -0
- package/src/api/rendering/render-pipelines/IRenderPipelineFactory.ts +39 -0
- package/src/api/rendering/render-pipelines/_export-render-pipelines.ts +2 -1
- package/src/api/rendering/renderer-interface.ts +1 -36
- package/src/api/rendering/renderpass/RenderPassDescriptor.ts +10 -14
- package/src/api/rendering/swapchain/ISwapChain.ts +1 -3
- package/src/api/rendering/texture/TextureFormat.ts +128 -14
- package/src/api/rendering/texture/TextureUtilities.ts +225 -10
- package/src/api/scene/Scene.ts +297 -0
- package/src/api/scene/SceneMesh.ts +61 -0
- package/src/api/shader/IShaderModuleLoader.ts +2 -1
- package/src/api/sprites/SpriteBatchDrawable.ts +12 -16
- package/src/api/sprites/SpriteBatchMesh.ts +22 -3
- package/src/api/utilities/AlignUtilities.ts +2 -1
- package/src/api/utilities/GeometryUtilities.ts +2 -0
- package/src/api/window/WindowManager.ts +23 -3
- package/src/core/rendering/ARenderer.ts +24 -15
- package/src/core/rendering/vertex-buffer-layout.ts +32 -1
- package/src/index.ts +0 -1
- package/src/main.ts +2 -4
- package/src/webgl/WebGLGraphicsDeviceFeatures.ts +12 -2
- package/src/webgl/WebGlGpuInfo.ts +1 -1
- package/src/webgl/WebGlGraphicsDevice.ts +0 -1
- package/src/webgl/WebGlRenderer.ts +2 -5
- package/src/webgl/lights/WebGlAmbientLightFactory.ts +35 -0
- package/src/webgl/lights/WebGlLightsBuffer.ts +225 -0
- package/src/webgl/render-pipelines/AWebGlRenderPipeline.ts +7 -1
- package/src/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.ts +21 -1
- package/src/webgl/render-pipelines/WebGlRenderPipelineFactory.ts +24 -2
- package/src/webgl/render-pipelines/inspect/WebGlInspectTextureMipsRenderPipeline.ts +16 -6
- package/src/webgl/render-pipelines/material/WebGlBlinnPhongRenderPipeline.ts +300 -0
- package/src/webgl/render-pipelines/material/WebGlUnlitRenderPipeline.ts +16 -6
- package/src/webgl/render-pipelines/sprite/WebGlSpriteRenderPipeline.ts +11 -7
- package/src/webgl/shader/WebGlShaderModule.ts +11 -4
- package/src/webgl/shader/WebGlShaderModuleLoader.ts +29 -10
- package/src/webgl/swap-chain/WebGlSwapChain.ts +7 -6
- package/src/webgl/texture/WebGlTexture2D.ts +19 -5
- package/src/webgl/texture/WebGlTextureFactory.ts +49 -7
- package/src/webgl/utilities/WebGlConstants.ts +136 -0
- package/src/webgl/utilities/WebGlConverter.ts +91 -22
- package/src/webgl/utilities/WebGlErrorUtilities.ts +15 -0
- package/src/webgl/utilities/WebGlTextureUtilities.ts +5 -2
- package/src/webgl/utilities/WebGlUtilities.ts +4 -0
- package/src/webgl/utilities/webgl-filter-anisotropic-utilities.ts +9 -6
- package/src/webgpu/WebGpuGpuInfo.ts +61 -0
- package/src/webgpu/WebGpuGraphicsDevice.ts +199 -0
- package/src/webgpu/WebGpuGraphicsDeviceFeatures.ts +41 -0
- package/src/webgpu/WebGpuRenderer.ts +49 -0
- package/src/webgpu/WebGpuTypes.ts +288 -0
- package/src/webgpu/blending/WebGpuBlendState.ts +53 -0
- package/src/webgpu/buffers/WebGpuBuffersFactory.ts +46 -0
- package/src/webgpu/buffers/WebGpuIndexBuffer.ts +118 -0
- package/src/webgpu/buffers/WebGpuUniformBuffer.ts +102 -0
- package/src/webgpu/buffers/WebGpuVertexBuffer.ts +119 -0
- package/src/webgpu/primitive/WebGpuPrimitiveState.ts +52 -0
- package/src/webgpu/render-pass/WebGpuRenderPass.ts +131 -0
- package/src/webgpu/render-pipelines/AWebGpuRenderPipeline.ts +123 -0
- package/src/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.ts +119 -0
- package/src/webgpu/render-pipelines/WebGpuRenderPipelineFactory.ts +66 -0
- package/src/webgpu/render-pipelines/material/AWebGpuMeshRenderPipeline.ts +249 -0
- package/src/webgpu/render-pipelines/material/WebGpuUnlitRenderPipeline.ts +101 -0
- package/src/webgpu/sampler/WebGpuSampler.ts +84 -0
- package/src/webgpu/shader/WebGpuShaderModule.ts +65 -0
- package/src/webgpu/shader/WebGpuShaderModuleLoader.ts +38 -0
- package/src/webgpu/shader/WgslShaderContent.ts +20 -0
- package/src/webgpu/swap-chain/WebGpuSwapChain.ts +93 -0
- package/src/webgpu/texture/WebGpuTexture2D.ts +197 -0
- package/src/webgpu/texture/WebGpuTextureFactory.ts +118 -0
- package/src/webgpu/texture/WebGpuTextureView.ts +43 -0
- package/src/webgpu/utilities/WebGpuConverter.ts +299 -0
- package/src/wgsl-raw.d.ts +4 -0
- package/dist/api/FrameworkConfiguration.d.ts +0 -23
- package/dist/api/FrameworkConfiguration.d.ts.map +0 -1
- package/dist/api/IFrameworkConfiguration.d.ts +0 -25
- package/dist/api/IFrameworkConfiguration.d.ts.map +0 -1
- package/dist/api/shader/shader-loader.d.ts.map +0 -1
- package/src/api/FrameworkConfiguration.ts +0 -29
- package/src/api/IFrameworkConfiguration.ts +0 -30
- /package/src/api/shader/{shader-loader.ts → ShaderLoader.ts} +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#version 300 es
|
|
2
|
+
precision mediump float;
|
|
3
|
+
|
|
4
|
+
#define DIRECTIONAL_LIGHTS_COUNT ##DIRECTIONAL_LIGHTS_COUNT##
|
|
5
|
+
#define POINT_LIGHTS_COUNT ##POINT_LIGHTS_COUNT##
|
|
6
|
+
|
|
7
|
+
in vec4 v_color;
|
|
8
|
+
in vec2 v_texCoords;
|
|
9
|
+
in vec3 v_normal;
|
|
10
|
+
in vec3 v_worldPosition;
|
|
11
|
+
|
|
12
|
+
layout(location = 0) out vec4 o_outputColor;
|
|
13
|
+
|
|
14
|
+
layout(std140) uniform MaterialBuffer
|
|
15
|
+
{
|
|
16
|
+
vec3 u_ambientColor;
|
|
17
|
+
vec3 u_diffuseColor;
|
|
18
|
+
vec3 u_specularColor;
|
|
19
|
+
float u_shininess;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
layout(std140) uniform CameraPositionBuffer
|
|
23
|
+
{
|
|
24
|
+
vec3 u_cameraPosition;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
struct DirectionalLight
|
|
28
|
+
{
|
|
29
|
+
vec3 light;
|
|
30
|
+
vec3 direction;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
struct PointLight
|
|
34
|
+
{
|
|
35
|
+
vec3 light;
|
|
36
|
+
float constant;
|
|
37
|
+
vec3 position;
|
|
38
|
+
float linear;
|
|
39
|
+
float quadratic;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
layout(std140) uniform LightsBuffer
|
|
43
|
+
{
|
|
44
|
+
vec3 u_ambientLight;
|
|
45
|
+
DirectionalLight u_directionalLight[DIRECTIONAL_LIGHTS_COUNT];
|
|
46
|
+
PointLight u_pointLight[POINT_LIGHTS_COUNT];
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
uniform sampler2D u_texture;
|
|
50
|
+
|
|
51
|
+
void main()
|
|
52
|
+
{
|
|
53
|
+
vec3 normal = normalize(v_normal);
|
|
54
|
+
|
|
55
|
+
// Ambient lighting
|
|
56
|
+
vec3 ambient = u_ambientColor * u_ambientLight;
|
|
57
|
+
|
|
58
|
+
vec3 viewDirection = normalize(u_cameraPosition - v_worldPosition);
|
|
59
|
+
|
|
60
|
+
// Directional diffuse and Blinn-Phong specular lighting
|
|
61
|
+
vec3 diffuse = vec3(0.0);
|
|
62
|
+
vec3 specular = vec3(0.0);
|
|
63
|
+
|
|
64
|
+
for (int i = 0; i < DIRECTIONAL_LIGHTS_COUNT; ++i)
|
|
65
|
+
{
|
|
66
|
+
vec3 lightColor = u_directionalLight[i].light;
|
|
67
|
+
vec3 lightDirection = normalize(-u_directionalLight[i].direction);
|
|
68
|
+
|
|
69
|
+
float NdotL = max(dot(normal, lightDirection), 0.0);
|
|
70
|
+
|
|
71
|
+
diffuse += u_diffuseColor * lightColor * NdotL;
|
|
72
|
+
|
|
73
|
+
if (NdotL > 0.0)
|
|
74
|
+
{
|
|
75
|
+
vec3 halfway = normalize(lightDirection + viewDirection);
|
|
76
|
+
float NdotH = max(dot(normal, halfway), 0.0);
|
|
77
|
+
specular += u_specularColor * lightColor * pow(NdotH, u_shininess);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Point lights: same diffuse and specular, scaled by distance attenuation.
|
|
82
|
+
for (int i = 0; i < POINT_LIGHTS_COUNT; ++i)
|
|
83
|
+
{
|
|
84
|
+
vec3 toLight = u_pointLight[i].position - v_worldPosition;
|
|
85
|
+
float lightDistance = length(toLight);
|
|
86
|
+
vec3 lightDirection = toLight / max(lightDistance, 0.0001);
|
|
87
|
+
float attenuation = 1.0 / (u_pointLight[i].constant
|
|
88
|
+
+ u_pointLight[i].linear * lightDistance
|
|
89
|
+
+ u_pointLight[i].quadratic * lightDistance * lightDistance);
|
|
90
|
+
vec3 lightColor = u_pointLight[i].light * attenuation;
|
|
91
|
+
|
|
92
|
+
float NdotL = max(dot(normal, lightDirection), 0.0);
|
|
93
|
+
|
|
94
|
+
diffuse += u_diffuseColor * lightColor * NdotL;
|
|
95
|
+
|
|
96
|
+
if (NdotL > 0.0)
|
|
97
|
+
{
|
|
98
|
+
vec3 halfway = normalize(lightDirection + viewDirection);
|
|
99
|
+
float NdotH = max(dot(normal, halfway), 0.0);
|
|
100
|
+
specular += u_specularColor * lightColor * pow(NdotH, u_shininess);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Apply material lighting, texture, and vertex color
|
|
105
|
+
vec4 texel = texture(u_texture, v_texCoords) * v_color;
|
|
106
|
+
// Specular highlights are not tinted by the texture.
|
|
107
|
+
vec3 finalColor = texel.rgb * (ambient + diffuse) + specular;
|
|
108
|
+
|
|
109
|
+
o_outputColor = vec4(finalColor, texel.a);
|
|
110
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#version 300 es
|
|
2
|
+
|
|
3
|
+
layout(location = 0) in vec3 a_position;
|
|
4
|
+
layout(location = 1) in vec4 a_color;
|
|
5
|
+
layout(location = 2) in vec2 a_texCoord;
|
|
6
|
+
layout(location = 3) in vec3 a_normal;
|
|
7
|
+
|
|
8
|
+
out vec4 v_color;
|
|
9
|
+
out vec2 v_texCoords;
|
|
10
|
+
out vec3 v_normal;
|
|
11
|
+
out vec3 v_worldPosition;
|
|
12
|
+
|
|
13
|
+
layout(std140) uniform CameraBuffer
|
|
14
|
+
{
|
|
15
|
+
mat4 projectionView;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
layout(std140) uniform ModelBuffer
|
|
19
|
+
{
|
|
20
|
+
mat4 model;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
void main()
|
|
24
|
+
{
|
|
25
|
+
vec4 worldPosition = model * vec4(a_position, 1.0);
|
|
26
|
+
gl_Position = projectionView * worldPosition;
|
|
27
|
+
v_color = a_color;
|
|
28
|
+
v_texCoords = a_texCoord;
|
|
29
|
+
// World-space normal through the normal matrix, correct for non-uniform mesh scale.
|
|
30
|
+
v_normal = transpose(inverse(mat3(model))) * a_normal;
|
|
31
|
+
v_worldPosition = worldPosition.xyz;
|
|
32
|
+
}
|
|
@@ -2,8 +2,42 @@
|
|
|
2
2
|
precision highp float;
|
|
3
3
|
in vec2 v_texCoord;
|
|
4
4
|
out vec4 outColor;
|
|
5
|
+
|
|
5
6
|
uniform sampler2D u_texture;
|
|
7
|
+
uniform int u_colorConversion;
|
|
8
|
+
|
|
9
|
+
float linearToSrgb(float c)
|
|
10
|
+
{
|
|
11
|
+
if (c <= 0.0)
|
|
12
|
+
return 0.0;
|
|
13
|
+
|
|
14
|
+
if (c < 0.0031308)
|
|
15
|
+
return 12.92 * c;
|
|
16
|
+
|
|
17
|
+
if (c < 1.0)
|
|
18
|
+
return 1.055 * pow(c, 1.0 / 2.4) - 0.055;
|
|
19
|
+
|
|
20
|
+
return 1.0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// https://registry.khronos.org/OpenGL/specs/gl/glspec46.core.pdf
|
|
24
|
+
// Chapter 17.3.7
|
|
25
|
+
// Page 513
|
|
26
|
+
vec3 linearToSrgb(vec3 c)
|
|
27
|
+
{
|
|
28
|
+
return vec3(
|
|
29
|
+
linearToSrgb(c.r),
|
|
30
|
+
linearToSrgb(c.g),
|
|
31
|
+
linearToSrgb(c.b)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
6
35
|
void main()
|
|
7
36
|
{
|
|
8
|
-
|
|
37
|
+
vec4 color = texture(u_texture, vec2(v_texCoord.x, 1.0 - v_texCoord.y));
|
|
38
|
+
outColor.rgb = color.rgb;
|
|
39
|
+
if(u_colorConversion == 1) {
|
|
40
|
+
outColor.rgb = linearToSrgb(color.rgb);
|
|
41
|
+
}
|
|
42
|
+
outColor.a = color.a;
|
|
9
43
|
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// Forward Blinn-Phong material shader (WebGPU): ambient + directional + point lights, per fragment in world space.
|
|
2
|
+
// Hand-maintained, mirrors slang/forward_blinn_phong_material.slang and glsl_300_es/forward_blinn_phong_material_*.glsl.
|
|
3
|
+
//
|
|
4
|
+
// The light counts must match LightsBuffer.DEFAULT_*_LIGHTS_COUNT (3 directional, 5 point lights;
|
|
5
|
+
// Lights = 4 + 3 * 8 + 5 * 12 = 88 floats = 352 bytes). Every member is a 16 byte aligned vec4.
|
|
6
|
+
// The counts are fixed here because the WebGPU pipeline does not pass a shader config.
|
|
7
|
+
//
|
|
8
|
+
// Bind groups (WebGPUForwardBlinnPhongRenderPipeline), WebGPU guarantees only 4 groups:
|
|
9
|
+
// group 0: binding 0 = projection view matrix, binding 1 = model matrix (vertex)
|
|
10
|
+
// group 1: binding 0 = diffuse texture, binding 1 = sampler (fragment)
|
|
11
|
+
// group 2: binding 2 = material (fragment)
|
|
12
|
+
// group 3: binding 3 = lights, binding 4 = camera position (fragment)
|
|
13
|
+
|
|
14
|
+
const DIRECTIONAL_LIGHTS_COUNT : u32 = 3u;
|
|
15
|
+
const POINT_LIGHTS_COUNT : u32 = 5u;
|
|
16
|
+
|
|
17
|
+
// Material colors (MTL Ka, Kd, Ks) and the specular exponent (MTL Ns).
|
|
18
|
+
struct BlinnPhongMaterial
|
|
19
|
+
{
|
|
20
|
+
ambientColor : vec4<f32>,
|
|
21
|
+
diffuseColor : vec4<f32>,
|
|
22
|
+
specularColorShininess : vec4<f32>, // xyz specular color, w shininess
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
struct DirectionalLight
|
|
26
|
+
{
|
|
27
|
+
light : vec4<f32>, // xyz color * intensity
|
|
28
|
+
direction : vec4<f32>, // xyz direction in which the light travels
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
struct PointLight
|
|
32
|
+
{
|
|
33
|
+
lightConstant : vec4<f32>, // xyz color * intensity, w constant attenuation
|
|
34
|
+
positionLinear : vec4<f32>, // xyz world position, w linear attenuation
|
|
35
|
+
quadratic : vec4<f32>, // x quadratic attenuation
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
struct Lights
|
|
39
|
+
{
|
|
40
|
+
ambientLight : vec4<f32>, // xyz color * intensity
|
|
41
|
+
directionalLights : array<DirectionalLight, DIRECTIONAL_LIGHTS_COUNT>,
|
|
42
|
+
pointLights : array<PointLight, POINT_LIGHTS_COUNT>,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
struct CameraPosition
|
|
46
|
+
{
|
|
47
|
+
position : vec4<f32>, // xyz world-space eye
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
@group(0) @binding(0) var<uniform> projectionView : mat4x4<f32>;
|
|
51
|
+
@group(0) @binding(1) var<uniform> model : mat4x4<f32>;
|
|
52
|
+
|
|
53
|
+
@group(1) @binding(0) var diffuseTexture : texture_2d<f32>;
|
|
54
|
+
@group(1) @binding(1) var diffuseSampler : sampler;
|
|
55
|
+
|
|
56
|
+
@group(2) @binding(2) var<uniform> material : BlinnPhongMaterial;
|
|
57
|
+
|
|
58
|
+
@group(3) @binding(3) var<uniform> lights : Lights;
|
|
59
|
+
@group(3) @binding(4) var<uniform> cameraPosition : CameraPosition;
|
|
60
|
+
|
|
61
|
+
struct VertexInput
|
|
62
|
+
{
|
|
63
|
+
@location(0) position : vec3<f32>,
|
|
64
|
+
@location(1) color : vec4<f32>,
|
|
65
|
+
@location(2) texCoord : vec2<f32>,
|
|
66
|
+
@location(3) normal : vec3<f32>,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
struct VertexOutput
|
|
70
|
+
{
|
|
71
|
+
@builtin(position) position : vec4<f32>,
|
|
72
|
+
@location(0) color : vec4<f32>,
|
|
73
|
+
@location(1) texCoord : vec2<f32>,
|
|
74
|
+
@location(2) normal : vec3<f32>,
|
|
75
|
+
@location(3) worldPosition : vec3<f32>,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
@vertex
|
|
79
|
+
fn main_vs(input : VertexInput) -> VertexOutput
|
|
80
|
+
{
|
|
81
|
+
var output : VertexOutput;
|
|
82
|
+
let worldPosition = model * vec4<f32>(input.position, 1.0);
|
|
83
|
+
output.position = projectionView * worldPosition;
|
|
84
|
+
output.color = input.color;
|
|
85
|
+
output.texCoord = input.texCoord;
|
|
86
|
+
output.worldPosition = worldPosition.xyz;
|
|
87
|
+
|
|
88
|
+
// World-space normal through the normal matrix (inverse transpose of the upper 3x3 of the model matrix),
|
|
89
|
+
// correct for non-uniform scale. For M = [a b c] (columns) the cofactor matrix is [b x c, c x a, a x b];
|
|
90
|
+
// it equals the inverse transpose times det(M). The length is removed in the fragment shader, only the sign matters.
|
|
91
|
+
let a = model[0].xyz;
|
|
92
|
+
let b = model[1].xyz;
|
|
93
|
+
let c = model[2].xyz;
|
|
94
|
+
let cofactor = mat3x3<f32>(cross(b, c), cross(c, a), cross(a, b));
|
|
95
|
+
let determinantSign = select(1.0, -1.0, dot(a, cross(b, c)) < 0.0);
|
|
96
|
+
output.normal = determinantSign * (cofactor * input.normal);
|
|
97
|
+
return output;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
fn blinnPhong(normal : vec3<f32>, lightDirection : vec3<f32>, viewDirection : vec3<f32>, lightColor : vec3<f32>,
|
|
101
|
+
diffuse : ptr<function, vec3<f32>>, specular : ptr<function, vec3<f32>>)
|
|
102
|
+
{
|
|
103
|
+
let NdotL = max(dot(normal, lightDirection), 0.0);
|
|
104
|
+
*diffuse += material.diffuseColor.xyz * lightColor * NdotL;
|
|
105
|
+
|
|
106
|
+
if (NdotL > 0.0)
|
|
107
|
+
{
|
|
108
|
+
let halfway = normalize(lightDirection + viewDirection);
|
|
109
|
+
let NdotH = max(dot(normal, halfway), 0.0);
|
|
110
|
+
*specular += material.specularColorShininess.xyz * lightColor * pow(NdotH, material.specularColorShininess.w);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@fragment
|
|
115
|
+
fn main_fs(input : VertexOutput) -> @location(0) vec4<f32>
|
|
116
|
+
{
|
|
117
|
+
let normal = normalize(input.normal);
|
|
118
|
+
|
|
119
|
+
// Ambient lighting.
|
|
120
|
+
let ambient = material.ambientColor.xyz * lights.ambientLight.xyz;
|
|
121
|
+
|
|
122
|
+
let viewDirection = normalize(cameraPosition.position.xyz - input.worldPosition);
|
|
123
|
+
|
|
124
|
+
// Diffuse and Blinn-Phong specular lighting.
|
|
125
|
+
var diffuse = vec3<f32>(0.0);
|
|
126
|
+
var specular = vec3<f32>(0.0);
|
|
127
|
+
|
|
128
|
+
for (var i = 0u; i < DIRECTIONAL_LIGHTS_COUNT; i++)
|
|
129
|
+
{
|
|
130
|
+
let light = lights.directionalLights[i];
|
|
131
|
+
blinnPhong(normal, normalize(-light.direction.xyz), viewDirection, light.light.xyz, &diffuse, &specular);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Point lights: same diffuse and specular, scaled by distance attenuation.
|
|
135
|
+
for (var i = 0u; i < POINT_LIGHTS_COUNT; i++)
|
|
136
|
+
{
|
|
137
|
+
let light = lights.pointLights[i];
|
|
138
|
+
let toLight = light.positionLinear.xyz - input.worldPosition;
|
|
139
|
+
let lightDistance = length(toLight);
|
|
140
|
+
let lightDirection = toLight / max(lightDistance, 0.0001);
|
|
141
|
+
let attenuation = 1.0 / (light.lightConstant.w
|
|
142
|
+
+ light.positionLinear.w * lightDistance
|
|
143
|
+
+ light.quadratic.x * lightDistance * lightDistance);
|
|
144
|
+
blinnPhong(normal, lightDirection, viewDirection, light.lightConstant.xyz * attenuation, &diffuse, &specular);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Apply material lighting, texture and vertex color. Specular highlights are not tinted by the texture.
|
|
148
|
+
let texel = textureSample(diffuseTexture, diffuseSampler, input.texCoord) * input.color;
|
|
149
|
+
return vec4<f32>(texel.rgb * (ambient + diffuse) + specular, texel.a);
|
|
150
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Inspect texture mips shader (WebGPU): draws a texture at an explicit mip level.
|
|
2
|
+
// Hand-maintained, mirrors slang/inspect_texture_mips.slang and glsl_300_es/inspect_texture_mips_*.glsl.
|
|
3
|
+
// Note: there is no WebGPU inspect pipeline yet; the layout follows the mesh pipelines.
|
|
4
|
+
//
|
|
5
|
+
// Bind groups:
|
|
6
|
+
// group 0: binding 0 = projection view matrix, binding 1 = model matrix (vertex)
|
|
7
|
+
// group 1: binding 0 = texture, binding 1 = sampler (fragment)
|
|
8
|
+
// group 2: binding 2 = texture constants (fragment)
|
|
9
|
+
|
|
10
|
+
struct TextureConstants
|
|
11
|
+
{
|
|
12
|
+
mipLevel : f32,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
@group(0) @binding(0) var<uniform> projectionView : mat4x4<f32>;
|
|
16
|
+
@group(0) @binding(1) var<uniform> model : mat4x4<f32>;
|
|
17
|
+
|
|
18
|
+
@group(1) @binding(0) var diffuseTexture : texture_2d<f32>;
|
|
19
|
+
@group(1) @binding(1) var diffuseSampler : sampler;
|
|
20
|
+
|
|
21
|
+
@group(2) @binding(2) var<uniform> textureConstants : TextureConstants;
|
|
22
|
+
|
|
23
|
+
struct VertexInput
|
|
24
|
+
{
|
|
25
|
+
@location(0) position : vec3<f32>,
|
|
26
|
+
@location(1) color : vec4<f32>,
|
|
27
|
+
@location(2) texCoord : vec2<f32>,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
struct VertexOutput
|
|
31
|
+
{
|
|
32
|
+
@builtin(position) position : vec4<f32>,
|
|
33
|
+
@location(0) color : vec4<f32>,
|
|
34
|
+
@location(1) texCoord : vec2<f32>,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
@vertex
|
|
38
|
+
fn main_vs(input : VertexInput) -> VertexOutput
|
|
39
|
+
{
|
|
40
|
+
var output : VertexOutput;
|
|
41
|
+
output.position = projectionView * model * vec4<f32>(input.position, 1.0);
|
|
42
|
+
output.color = input.color;
|
|
43
|
+
output.texCoord = input.texCoord;
|
|
44
|
+
return output;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@fragment
|
|
48
|
+
fn main_fs(input : VertexOutput) -> @location(0) vec4<f32>
|
|
49
|
+
{
|
|
50
|
+
return textureSampleLevel(diffuseTexture, diffuseSampler, input.texCoord, textureConstants.mipLevel) * input.color;
|
|
51
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Draws the main render target texture to the screen. (WebGPU)
|
|
2
|
+
// Hand-maintained, mirrors slang/main_frame_buffer.slang.
|
|
3
|
+
//
|
|
4
|
+
// Bind groups (WebGPUMainFrameBufferRenderPipeline):
|
|
5
|
+
// group 0: binding 0 = texture, binding 1 = sampler (fragment)
|
|
6
|
+
|
|
7
|
+
@group(0) @binding(0) var diffuseTexture : texture_2d<f32>;
|
|
8
|
+
@group(0) @binding(1) var diffuseSampler : sampler;
|
|
9
|
+
|
|
10
|
+
struct VertexInput
|
|
11
|
+
{
|
|
12
|
+
@location(0) position : vec3<f32>,
|
|
13
|
+
@location(1) texCoord : vec2<f32>,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
struct VertexOutput
|
|
17
|
+
{
|
|
18
|
+
@builtin(position) position : vec4<f32>,
|
|
19
|
+
@location(0) texCoord : vec2<f32>,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
@vertex
|
|
23
|
+
fn main_vs(input : VertexInput) -> VertexOutput
|
|
24
|
+
{
|
|
25
|
+
var output : VertexOutput;
|
|
26
|
+
output.position = vec4<f32>(input.position, 1.0);
|
|
27
|
+
output.texCoord = input.texCoord;
|
|
28
|
+
return output;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@fragment
|
|
32
|
+
fn main_fs(input : VertexOutput) -> @location(0) vec4<f32>
|
|
33
|
+
{
|
|
34
|
+
return textureSample(diffuseTexture, diffuseSampler, input.texCoord);
|
|
35
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Draws the main render target texture to the screen, flipped on Y. (WebGPU)
|
|
2
|
+
// Hand-maintained, mirrors slang/main_render_target_flip_y.slang.
|
|
3
|
+
//
|
|
4
|
+
// Bind groups (WebGPUMainFrameBufferRenderPipeline):
|
|
5
|
+
// group 0: binding 0 = texture, binding 1 = sampler (fragment)
|
|
6
|
+
|
|
7
|
+
@group(0) @binding(0) var diffuseTexture : texture_2d<f32>;
|
|
8
|
+
@group(0) @binding(1) var diffuseSampler : sampler;
|
|
9
|
+
|
|
10
|
+
struct VertexInput
|
|
11
|
+
{
|
|
12
|
+
@location(0) position : vec3<f32>,
|
|
13
|
+
@location(1) texCoord : vec2<f32>,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
struct VertexOutput
|
|
17
|
+
{
|
|
18
|
+
@builtin(position) position : vec4<f32>,
|
|
19
|
+
@location(0) texCoord : vec2<f32>,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
@vertex
|
|
23
|
+
fn main_vs(input : VertexInput) -> VertexOutput
|
|
24
|
+
{
|
|
25
|
+
var output : VertexOutput;
|
|
26
|
+
output.position = vec4<f32>(input.position, 1.0);
|
|
27
|
+
output.texCoord = input.texCoord;
|
|
28
|
+
return output;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@fragment
|
|
32
|
+
fn main_fs(input : VertexOutput) -> @location(0) vec4<f32>
|
|
33
|
+
{
|
|
34
|
+
return textureSample(diffuseTexture, diffuseSampler, vec2<f32>(input.texCoord.x, 1.0 - input.texCoord.y));
|
|
35
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Sprite batch shader (WebGPU). Hand-maintained, mirrors slang/sprite.slang and glsl_300_es/sprite_*.glsl.
|
|
2
|
+
//
|
|
3
|
+
// Bind groups (WebGPUSpriteRenderPipeline):
|
|
4
|
+
// group 0: binding 0 = projection view matrix (vertex)
|
|
5
|
+
// group 1: binding 0 = sprite texture, binding 1 = sampler (fragment)
|
|
6
|
+
|
|
7
|
+
@group(0) @binding(0) var<uniform> projectionView : mat4x4<f32>;
|
|
8
|
+
|
|
9
|
+
@group(1) @binding(0) var diffuseTexture : texture_2d<f32>;
|
|
10
|
+
@group(1) @binding(1) var diffuseSampler : sampler;
|
|
11
|
+
|
|
12
|
+
struct VertexInput
|
|
13
|
+
{
|
|
14
|
+
@location(0) position : vec3<f32>,
|
|
15
|
+
@location(1) color : vec4<f32>,
|
|
16
|
+
@location(2) texCoord : vec2<f32>,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
struct VertexOutput
|
|
20
|
+
{
|
|
21
|
+
@builtin(position) position : vec4<f32>,
|
|
22
|
+
@location(0) color : vec4<f32>,
|
|
23
|
+
@location(1) texCoord : vec2<f32>,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
@vertex
|
|
27
|
+
fn main_vs(input : VertexInput) -> VertexOutput
|
|
28
|
+
{
|
|
29
|
+
var output : VertexOutput;
|
|
30
|
+
output.position = projectionView * vec4<f32>(input.position, 1.0);
|
|
31
|
+
output.color = input.color;
|
|
32
|
+
output.texCoord = input.texCoord;
|
|
33
|
+
return output;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@fragment
|
|
37
|
+
fn main_fs(input : VertexOutput) -> @location(0) vec4<f32>
|
|
38
|
+
{
|
|
39
|
+
return textureSample(diffuseTexture, diffuseSampler, input.texCoord) * input.color;
|
|
40
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Unlit material shader (WebGPU). Hand-maintained, mirrors slang/unlit_material.slang and glsl_300_es/unlit_material_*.glsl.
|
|
2
|
+
//
|
|
3
|
+
// Bind groups (WebGPUUnlitRenderPipeline):
|
|
4
|
+
// group 0: binding 0 = projection view matrix, binding 1 = model matrix (vertex)
|
|
5
|
+
// group 1: binding 0 = diffuse texture, binding 1 = sampler (fragment)
|
|
6
|
+
// group 2: binding 2 = material (fragment)
|
|
7
|
+
|
|
8
|
+
struct Material
|
|
9
|
+
{
|
|
10
|
+
diffuseColor : vec4<f32>,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
@group(0) @binding(0) var<uniform> projectionView : mat4x4<f32>;
|
|
14
|
+
@group(0) @binding(1) var<uniform> model : mat4x4<f32>;
|
|
15
|
+
|
|
16
|
+
@group(1) @binding(0) var diffuseTexture : texture_2d<f32>;
|
|
17
|
+
@group(1) @binding(1) var diffuseSampler : sampler;
|
|
18
|
+
|
|
19
|
+
@group(2) @binding(2) var<uniform> material : Material;
|
|
20
|
+
|
|
21
|
+
struct VertexInput
|
|
22
|
+
{
|
|
23
|
+
@location(0) position : vec3<f32>,
|
|
24
|
+
@location(1) color : vec4<f32>,
|
|
25
|
+
@location(2) texCoord : vec2<f32>,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
struct VertexOutput
|
|
29
|
+
{
|
|
30
|
+
@builtin(position) position : vec4<f32>,
|
|
31
|
+
@location(0) color : vec4<f32>,
|
|
32
|
+
@location(1) texCoord : vec2<f32>,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
@vertex
|
|
36
|
+
fn main_vs(input : VertexInput) -> VertexOutput
|
|
37
|
+
{
|
|
38
|
+
var output : VertexOutput;
|
|
39
|
+
output.position = projectionView * model * vec4<f32>(input.position, 1.0);
|
|
40
|
+
output.color = input.color;
|
|
41
|
+
output.texCoord = input.texCoord;
|
|
42
|
+
return output;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@fragment
|
|
46
|
+
fn main_fs(input : VertexOutput) -> @location(0) vec4<f32>
|
|
47
|
+
{
|
|
48
|
+
return textureSample(diffuseTexture, diffuseSampler, input.texCoord) * material.diffuseColor * input.color;
|
|
49
|
+
}
|