Skip to content

Commit

Permalink
fix: radix sort depth inversion
Browse files Browse the repository at this point in the history
  • Loading branch information
mosure committed Nov 27, 2023
1 parent a3050c3 commit 46a9524
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ impl SpecializedRenderPipeline for GaussianCloudPipeline {
format: TextureFormat::Rgba8UnormSrgb,
blend: Some(BlendState {
color: BlendComponent {
src_factor: BlendFactor::DstAlpha,
dst_factor: BlendFactor::One,
src_factor: BlendFactor::One,
dst_factor: BlendFactor::OneMinusSrcAlpha,
operation: BlendOperation::Add,
},
alpha: BlendComponent {
Expand Down
4 changes: 1 addition & 3 deletions src/render/sort/radix.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ fn radix_sort_a(
let clip_space_pos = world_to_clip(transformed_position);
if(in_frustum(clip_space_pos.xyz)) {
// key = bitcast<u32>(1.0 - clip_space_pos.z);
// key = u32(clip_space_pos.z * 0xFFFF.0) << 16u;
let normalized_depth = (1.0 - clip_space_pos.z) * 0.5;
key = u32(normalized_depth * 0xFFFF.0) << 16u;
key = u32(clip_space_pos.z * 0xFFFF.0) << 16u;
key |= u32((clip_space_pos.x * 0.5 + 0.5) * 0xFF.0) << 8u;
key |= u32((clip_space_pos.y * 0.5 + 0.5) * 0xFF.0);
}
Expand Down

0 comments on commit 46a9524

Please sign in to comment.