Skip to content

Commit

Permalink
Client: Fix an unintended conversion in the terrain shader
Browse files Browse the repository at this point in the history
This error was concealed by a recent change to wgpu, where it would automatically convert unsigned integers to floats when it deems it "safe" to do so. Previously, it would've given a validation error here because the hardcoded numbers aren't compiled to floats unless explicitly marked as such.

Apparently, this hidden conversion broke the discard logic, leading to black surfaces being discarded in at least one case (c_tower1). This is because the division doesn't have enough precision if using integers. Being explicit fixes the problem.
  • Loading branch information
rdw-software committed Feb 13, 2024
1 parent 9aa1583 commit 4ca3f4d
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn vs_main(in: VertexInput) -> VertexOutput {

// Magenta background pixels should be discarded (but pre-processing on the CPU is expensive)
fn isTransparentBackgroundPixel(diffuseTextureColor : vec4f) -> bool {
return (diffuseTextureColor.r >= 254/255 && diffuseTextureColor.g <= 3/255 && diffuseTextureColor.b >= 254/255);
return (diffuseTextureColor.r >= 254.0/255.0 && diffuseTextureColor.g <= 3.0/255.0 && diffuseTextureColor.b >= 254.0/255.0);
}

@fragment
Expand Down

0 comments on commit 4ca3f4d

Please sign in to comment.