Fix depth texture saving
This commit is contained in:
parent
010e4dedeb
commit
7830d735b8
6 changed files with 131 additions and 82 deletions
|
@ -13,5 +13,5 @@ fn vs_main(
|
|||
);
|
||||
|
||||
let world_position = model_matrix * vec4<f32>(model.position, 1.0);
|
||||
return light.matrices[light_matrix_index] * world_position;
|
||||
return light.matrices[light_matrix_index] * (world_position - vec4<f32>(light.position, 0.0));
|
||||
}
|
||||
|
|
|
@ -45,10 +45,3 @@ struct VertexOutput {
|
|||
@location(3) tangent_view_position: vec3<f32>,
|
||||
@location(4) world_position: vec4<f32>,
|
||||
}
|
||||
|
||||
// Fragment shader
|
||||
|
||||
@group(1)@binding(2)
|
||||
var t_light_depth: binding_array<texture_depth_2d>;
|
||||
@group(1) @binding(3)
|
||||
var s_light_depth: binding_array<sampler_comparison>;
|
||||
|
|
|
@ -46,24 +46,29 @@ fn vs_main(
|
|||
|
||||
// Fragment shader
|
||||
|
||||
@group(2) @binding(0)
|
||||
@group(2)@binding(0)
|
||||
var t_light_depth: binding_array<texture_depth_2d>;
|
||||
@group(2) @binding(1)
|
||||
var s_light_depth: binding_array<sampler_comparison>;
|
||||
|
||||
@group(3) @binding(0)
|
||||
var t_diffuse: texture_2d<f32>;
|
||||
@group(2)@binding(1)
|
||||
@group(3)@binding(1)
|
||||
var s_diffuse: sampler;
|
||||
|
||||
@group(2)@binding(2)
|
||||
@group(3)@binding(2)
|
||||
var t_normal: texture_2d<f32>;
|
||||
@group(2) @binding(3)
|
||||
@group(3) @binding(3)
|
||||
var s_normal: sampler;
|
||||
|
||||
@group(2)@binding(4)
|
||||
@group(3)@binding(4)
|
||||
var t_roughness_metalness: texture_2d<f32>;
|
||||
@group(2) @binding(5)
|
||||
@group(3) @binding(5)
|
||||
var s_roughness_metalness: sampler;
|
||||
|
||||
fn sample_direct_light(index: i32, light_coords: vec4<f32>) -> f32 {
|
||||
if (light_coords.w <= 0.0) {
|
||||
return 1.0;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
let flip_correction = vec2<f32>(0.5, -0.5);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue