Skip to content

Commit

Permalink
vk: rt: fixup accidental translucency for alpha-masked geometries
Browse files Browse the repository at this point in the history
Fixes #721
  • Loading branch information
w23 committed Jan 1, 2024
1 parent 84babdf commit 9088ab3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ref/vk/shaders/ray_primary_hit.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ void primaryRayHit(rayQueryEXT rq, inout RayPayloadPrimary payload) {
payload.base_color_a *= color;
payload.emissive.rgb *= color.rgb;

// α-masked materials leak non-1 alpha values to bounces, leading to weird translucent edges, see
// https://github.com/w23/xash3d-fwgs/issues/721
// Non-translucent materials should be fully opaque
if (model.mode != MATERIAL_MODE_TRANSLUCENT)
payload.base_color_a.a = 1.;

if (ubo.ubo.debug_display_only == DEBUG_DISPLAY_DISABLED) {
// Nop
} else if (ubo.ubo.debug_display_only == DEBUG_DISPLAY_SURFHASH) {
Expand Down

0 comments on commit 9088ab3

Please sign in to comment.