UNPKG

matrix-engine-wgpu

Version:

obj sequence anim +HOTFIX raycast, webGPU powered pwa application. Crazy fast rendering with AmmoJS physics support. Simple raycaster hit object added.

49 lines (40 loc) 1.19 kB
export let vertexWGSL = `struct Scene { lightViewProjMatrix: mat4x4f, cameraViewProjMatrix: mat4x4f, lightPos: vec3f, } struct Model { modelMatrix: mat4x4f, } @group(0) @binding(0) var<uniform> scene : Scene; @group(1) @binding(0) var<uniform> model : Model; struct VertexOutput { @location(0) shadowPos: vec3f, @location(1) fragPos: vec3f, @location(2) fragNorm: vec3f, @location(3) uv : vec2f, @builtin(position) Position: vec4f, } @vertex fn main( @location(0) position: vec3f, @location(1) normal: vec3f, @location(2) uv : vec2f ) -> VertexOutput { var output : VertexOutput; // XY is in (-1, 1) space, Z is in (0, 1) space let posFromLight = scene.lightViewProjMatrix * model.modelMatrix * vec4(position, 1.0); // Convert XY to (0, 1) // Y is flipped because texture coords are Y-down. output.shadowPos = vec3( posFromLight.xy * vec2(0.5, -0.5) + vec2(0.5), posFromLight.z ); output.Position = scene.cameraViewProjMatrix * model.modelMatrix * vec4(position, 1.0); output.fragPos = output.Position.xyz; output.fragNorm = normal; // nidza output.uv = uv; return output; } `;