shadow.wgsl (970B)
1 // Shadow depth pass: renders scene from light's perspective (depth only) 2 3 struct Globals { 4 time: f32, 5 _pad0: f32, 6 resolution: vec2<f32>, 7 8 cam_pos: vec3<f32>, 9 _pad3: f32, 10 11 light_dir: vec3<f32>, 12 _pad1: f32, 13 14 light_color: vec3<f32>, 15 _pad2: f32, 16 17 fill_light_dir: vec3<f32>, 18 _pad4: f32, 19 20 fill_light_color: vec3<f32>, 21 _pad5: f32, 22 23 view_proj: mat4x4<f32>, 24 inv_view_proj: mat4x4<f32>, 25 light_view_proj: mat4x4<f32>, 26 }; 27 28 struct Object { 29 model: mat4x4<f32>, 30 normal: mat4x4<f32>, 31 }; 32 33 @group(0) @binding(0) var<uniform> globals: Globals; 34 @group(1) @binding(0) var<uniform> object: Object; 35 36 struct VSIn { 37 @location(0) pos: vec3<f32>, 38 @location(1) normal: vec3<f32>, 39 @location(2) uv: vec2<f32>, 40 @location(3) tangent: vec4<f32>, 41 }; 42 43 @vertex 44 fn vs_main(v: VSIn) -> @builtin(position) vec4<f32> { 45 let world4 = object.model * vec4<f32>(v.pos, 1.0); 46 return globals.light_view_proj * world4; 47 }