Skip to content

Commit

Permalink
Fix edge case in MSAA shader (scp-fs2open#6186)
Browse files Browse the repository at this point in the history
  • Loading branch information
BMagnu authored Jun 11, 2024
1 parent 7f20b9c commit 559a261
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions code/def_files/data/effects/msaa-f.sdr
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ void main()
for(int i = 0; i < samples; i++) {
vec4 localPos = texelFetch(texPos, texel, i);
//Calculate local weight from distance Voxel, but if the distance is 0 (i.e. no model at all), set weight to 1 to allow stuff like background emissive
float localWeight = max(step(-0.001, dist),
//However, if the median distance is 0, only deal with current texel if it's local distance is 0 as well
float localWeight = max(step(-0.001, dist) * step(-0.001, localPos.z),
smoothstep(dist + dist * texelWidthFactor * (voxelDepth + voxelDepthFalloff), dist + dist * texelWidthFactor * voxelDepth, localPos.z) *
smoothstep(dist - dist * texelWidthFactor * voxelDepth, dist + dist * texelWidthFactor * (voxelDepth + voxelDepthFalloff), localPos.z)
);
Expand All @@ -190,7 +191,7 @@ void main()

fragOut0 = color / weight;
fragOut1 = pos / weight;
fragOut2 = normalize(normal);
fragOut2 = vec4(normalize(normal.xyz), normal.a / weight);
fragOut3 = specular / weight;
fragOut4 = emissive / weight;
gl_FragDepth = depth / weight;
Expand Down

0 comments on commit 559a261

Please sign in to comment.