diff --git a/neo/engine/opengl/gl_d3d12shim.cpp b/neo/engine/opengl/gl_d3d12shim.cpp index 65166635..d9346fa0 100644 --- a/neo/engine/opengl/gl_d3d12shim.cpp +++ b/neo/engine/opengl/gl_d3d12shim.cpp @@ -4219,6 +4219,15 @@ float QD3D12_TessellationDisplacementFade(float4 clipPos) return QD3D12_DistanceFadeFromClip(clipPos, QD3D12_TESS_DISTANCE_NEAR, QD3D12_TESS_DISTANCE_FAR); } +float QD3D12_TessellationPatchEdgeFade(float3 bary) +{ + // Keep original patch edges on the undisplaced mesh. Brush seams and room + // corners often meet only at those edges; moving both sides along different + // normals can open real gaps that show the background. + float edgeDistance = min(bary.x, min(bary.y, bary.z)); + return smoothstep(0.0, 0.08, edgeDistance); +} + float QD3D12_ComputeNormalMapTessEdgeFactor(VSOut a, VSOut b) { if (gUseNormalMap <= 0.5) @@ -4340,6 +4349,7 @@ VSOut DSMain(HSConstOut tessFactors, float3 bary : SV_DomainLocation, const Outp float height = QD3D12_GetFilteredTessHeight(i.uv0); float centeredHeight = QD3D12_CleanCenteredTessHeight(height); float displacementFade = QD3D12_TessellationDisplacementFade(i.currClip); + displacementFade *= QD3D12_TessellationPatchEdgeFade(bary); float reliefConfidence = QD3D12_GetPomConfidence(i.uv0); float displacement = centeredHeight * gTessellationDisplacement * displacementFade * reliefConfidence; float3 displacedObjPos = i.objPos + objNormal * displacement;