Pass light matrix as separate uniform, fix matrices
This commit is contained in:
parent
2676b841fe
commit
010e4dedeb
4 changed files with 81 additions and 41 deletions
|
@ -13,5 +13,5 @@ fn vs_main(
|
|||
);
|
||||
|
||||
let world_position = model_matrix * vec4<f32>(model.position, 1.0);
|
||||
return light.matrices[light.active_matrix] * world_position;
|
||||
return light.matrices[light_matrix_index] * world_position;
|
||||
}
|
||||
|
|
|
@ -12,11 +12,13 @@ struct Light {
|
|||
position: vec3<f32>,
|
||||
color: vec4<f32>,
|
||||
matrices: array<mat4x4<f32>, 6>,
|
||||
active_matrix: u32,
|
||||
}
|
||||
@group(1) @binding(0)
|
||||
var<uniform> light: Light;
|
||||
|
||||
@group(1) @binding(1)
|
||||
var<uniform> light_matrix_index: u32;
|
||||
|
||||
struct VertexInput {
|
||||
@location(0) position: vec3<f32>,
|
||||
@location(1) tex_coords: vec2<f32>,
|
||||
|
@ -46,7 +48,7 @@ struct VertexOutput {
|
|||
|
||||
// Fragment shader
|
||||
|
||||
@group(1)@binding(1)
|
||||
@group(1)@binding(2)
|
||||
var t_light_depth: binding_array<texture_depth_2d>;
|
||||
@group(1) @binding(2)
|
||||
@group(1) @binding(3)
|
||||
var s_light_depth: binding_array<sampler_comparison>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue