-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix meshlet shaders for bindless mode. #16825
Changes from 2 commits
57af624
185539e
9d71763
ede668c
abd8f14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,7 @@ | |
mesh_bindings::mesh | ||
} | ||
|
||
fn sample_depth_map(uv: vec2<f32>, instance_index: u32) -> f32 { | ||
let slot = mesh[instance_index].material_bind_group_slot; | ||
fn sample_depth_map(uv: vec2<f32>, material_bind_group_slot: u32) -> f32 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did this change? Was it missed in an earlier PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not quite sure what you mean. It changed because we don't use that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah nvm I see that it used to get the slot in the function itself, and all you did was move it outside the function so that the slot could be obtained differently for meshlet meshes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right. |
||
// We use `textureSampleLevel` over `textureSample` because the wgpu DX12 | ||
// backend (Fxc) panics when using "gradient instructions" inside a loop. | ||
// It results in the whole loop being unrolled by the shader compiler, | ||
|
@@ -19,8 +18,8 @@ fn sample_depth_map(uv: vec2<f32>, instance_index: u32) -> f32 { | |
// See https://stackoverflow.com/questions/56581141/direct3d11-gradient-instruction-used-in-a-loop-with-varying-iteration-forcing | ||
return textureSampleLevel( | ||
#ifdef BINDLESS | ||
depth_map_texture[slot], | ||
depth_map_sampler[slot], | ||
depth_map_texture[material_bind_group_slot], | ||
depth_map_sampler[material_bind_group_slot], | ||
#else // BINDLESS | ||
depth_map_texture, | ||
depth_map_sampler, | ||
|
@@ -40,7 +39,7 @@ fn parallaxed_uv( | |
original_uv: vec2<f32>, | ||
// The vector from the camera to the fragment at the surface in tangent space | ||
Vt: vec3<f32>, | ||
instance_index: u32, | ||
material_bind_group_slot: u32, | ||
) -> vec2<f32> { | ||
if max_layer_count < 1.0 { | ||
return original_uv; | ||
|
@@ -68,15 +67,15 @@ fn parallaxed_uv( | |
var delta_uv = depth_scale * layer_depth * Vt.xy * vec2(1.0, -1.0) / view_steepness; | ||
|
||
var current_layer_depth = 0.0; | ||
var texture_depth = sample_depth_map(uv, instance_index); | ||
var texture_depth = sample_depth_map(uv, material_bind_group_slot); | ||
|
||
// texture_depth > current_layer_depth means the depth map depth is deeper | ||
// than the depth the ray would be at this UV offset so the ray has not | ||
// intersected the surface | ||
for (var i: i32 = 0; texture_depth > current_layer_depth && i <= i32(layer_count); i++) { | ||
current_layer_depth += layer_depth; | ||
uv += delta_uv; | ||
texture_depth = sample_depth_map(uv, instance_index); | ||
texture_depth = sample_depth_map(uv, material_bind_group_slot); | ||
} | ||
|
||
#ifdef RELIEF_MAPPING | ||
|
@@ -94,7 +93,7 @@ fn parallaxed_uv( | |
current_layer_depth -= delta_depth; | ||
|
||
for (var i: u32 = 0u; i < max_steps; i++) { | ||
texture_depth = sample_depth_map(uv, instance_index); | ||
texture_depth = sample_depth_map(uv, material_bind_group_slot); | ||
|
||
// Halve the deltas for the next step | ||
delta_uv *= 0.5; | ||
|
@@ -118,7 +117,8 @@ fn parallaxed_uv( | |
// may skip small details and result in writhing material artifacts. | ||
let previous_uv = uv - delta_uv; | ||
let next_depth = texture_depth - current_layer_depth; | ||
let previous_depth = sample_depth_map(previous_uv, instance_index) - current_layer_depth + layer_depth; | ||
let previous_depth = sample_depth_map(previous_uv, material_bind_group_slot) - | ||
current_layer_depth + layer_depth; | ||
|
||
let weight = next_depth / (next_depth - previous_depth); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why were the
#ifndef MESHLET_MESH_MATERIAL_PASS
added here? Did they cause compilation issues?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
mesh
array that's used in those functions isn't present during visbuffer resolution.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but I don't think that causes any actual issues, unless you try and use them? It was never an issue in 0.15. Unless a recent PR changed that. Anyways I'm fine with the ifdef, I was just wondering why it was added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It caused the shaders to fail to compile.