diff --git a/pxr/imaging/hdSt/CMakeLists.txt b/pxr/imaging/hdSt/CMakeLists.txt index 407f022a3e..e2122cb66a 100644 --- a/pxr/imaging/hdSt/CMakeLists.txt +++ b/pxr/imaging/hdSt/CMakeLists.txt @@ -201,6 +201,7 @@ pxr_library(hdSt shaders/meshWire.glslfx shaders/points.glslfx shaders/pointId.glslfx + shaders/pointDisk.glslfx shaders/ptexTexture.glslfx shaders/renderPass.glslfx shaders/renderPassShader.glslfx diff --git a/pxr/imaging/hdSt/basisCurves.cpp b/pxr/imaging/hdSt/basisCurves.cpp index 8a8810367a..594ae3ccae 100644 --- a/pxr/imaging/hdSt/basisCurves.cpp +++ b/pxr/imaging/hdSt/basisCurves.cpp @@ -359,6 +359,10 @@ HdStBasisCurves::_UpdateDrawItemGeometricShader( resourceRegistry->GetHgi()->GetCapabilities()-> IsSet(HgiDeviceCapabilitiesBitsMetalTessellation); + bool const nativeRoundPoints = + resourceRegistry->GetHgi()->GetCapabilities()-> + IsSet(HgiDeviceCapabilitiesBitsRoundPoints); + HdSt_BasisCurvesShaderKey shaderKey(curveType, curveBasis, drawStyle, @@ -368,7 +372,8 @@ HdStBasisCurves::_UpdateDrawItemGeometricShader( shadingTerminal, hasAuthoredTopologicalVisiblity, _pointsShadingEnabled, - hasMetalTessellation); + hasMetalTessellation, + nativeRoundPoints); TF_DEBUG(HD_RPRIM_UPDATED). Msg("HdStBasisCurves(%s) - Shader Key PrimType: %s\n ", diff --git a/pxr/imaging/hdSt/basisCurvesShaderKey.cpp b/pxr/imaging/hdSt/basisCurvesShaderKey.cpp index 405f4a39b5..53c8b29987 100644 --- a/pxr/imaging/hdSt/basisCurvesShaderKey.cpp +++ b/pxr/imaging/hdSt/basisCurvesShaderKey.cpp @@ -128,6 +128,12 @@ TF_DEFINE_PRIVATE_TOKENS( ((surfaceFS, "Fragment.Surface")) ((surfaceUnlitFS, "Fragment.SurfaceUnlit")) ((scalarOverrideFS, "Fragment.ScalarOverride")) + + // rounded points + ((pointSizeBiasVS, "PointDisk.Vertex.PointSizeBias")) + ((noPointSizeBiasVS, "PointDisk.Vertex.None")) + ((diskSampleMaskFS, "PointDisk.Fragment.SampleMask")) + ((noDiskSampleMaskFS, "PointDisk.Fragment.None")) ); static TfToken HdSt_BasisToShaderKey(const TfToken& basis){ @@ -151,7 +157,8 @@ HdSt_BasisCurvesShaderKey::HdSt_BasisCurvesShaderKey( TfToken shadingTerminal, bool hasAuthoredTopologicalVisibility, bool pointsShadingEnabled, - bool hasMetalTessellation) + bool hasMetalTessellation, + bool nativeRoundPoints) : useMetalTessellation(false) , glslfx(_tokens->baseGLSLFX) { @@ -201,8 +208,11 @@ HdSt_BasisCurvesShaderKey::HdSt_BasisCurvesShaderKey( VS[vsIndex++] = _tokens->pointIdVS; VS[vsIndex++] = _tokens->pointIdSelDecodeUtilsVS; VS[vsIndex++] = _tokens->pointIdSelPointSelVS; + VS[vsIndex++] = nativeRoundPoints ? _tokens->noPointSizeBiasVS : + _tokens->pointSizeBiasVS; } else { VS[vsIndex++] = _tokens->pointIdNoneVS; + VS[vsIndex++] = _tokens->noPointSizeBiasVS; } VS[vsIndex] = TfToken(); @@ -485,11 +495,17 @@ HdSt_BasisCurvesShaderKey::HdSt_BasisCurvesShaderKey( } FS[fsIndex++] = _tokens->scalarOverrideFS; - FS[fsIndex++] = isPrimTypePoints? - _tokens->pointIdFS : _tokens->pointIdFallbackFS; - + if (isPrimTypePoints) { + FS[fsIndex++] = _tokens->pointIdFS; + FS[fsIndex++] = nativeRoundPoints ? _tokens->noDiskSampleMaskFS : + _tokens->diskSampleMaskFS; + } else { + FS[fsIndex++] = _tokens->pointIdFallbackFS; + FS[fsIndex++] = _tokens->noDiskSampleMaskFS; + } + FS[fsIndex++] = hasAuthoredTopologicalVisibility? _tokens->topVisFS : - _tokens->topVisFallbackFS; + _tokens->topVisFallbackFS; if (drawStyle == HdSt_BasisCurvesShaderKey::WIRE || diff --git a/pxr/imaging/hdSt/basisCurvesShaderKey.h b/pxr/imaging/hdSt/basisCurvesShaderKey.h index 6a23d009dd..f40615f65f 100644 --- a/pxr/imaging/hdSt/basisCurvesShaderKey.h +++ b/pxr/imaging/hdSt/basisCurvesShaderKey.h @@ -59,7 +59,8 @@ struct HdSt_BasisCurvesShaderKey : public HdSt_ShaderKey TfToken shadingTerminal, bool hasAuthoredTopologicalVisibility, bool pointsShadingEnabled, - bool hasMetalTessellation); + bool hasMetalTessellation, + bool nativeRoundPoints); HDST_API ~HdSt_BasisCurvesShaderKey(); @@ -83,12 +84,13 @@ struct HdSt_BasisCurvesShaderKey : public HdSt_ShaderKey HdSt_GeometricShader::PrimitiveType primType; bool useMetalTessellation; TfToken glslfx; - TfToken VS[7]; + TfToken VS[8]; TfToken TCS[7]; TfToken TES[12]; TfToken PTCS[9]; TfToken PTVS[14]; - TfToken FS[8]; + TfToken GS[2]; + TfToken FS[9]; }; diff --git a/pxr/imaging/hdSt/codeGen.cpp b/pxr/imaging/hdSt/codeGen.cpp index 2f41936567..645644576c 100644 --- a/pxr/imaging/hdSt/codeGen.cpp +++ b/pxr/imaging/hdSt/codeGen.cpp @@ -3190,6 +3190,18 @@ HdSt_CodeGen::_CompileWithGeneratedHgiResources( HgiShaderKeywordTokens->hdBaryCoordNoPersp); } + if (_geometricShader->GetPrimitiveType() == + HdSt_GeometricShader::PrimitiveType::PRIM_POINTS && + !registry->GetHgi()->GetCapabilities()->IsSet( + HgiDeviceCapabilitiesBitsRoundPoints)) { + HgiShaderFunctionAddStageInput(&fsDesc, "gl_PointCoord", "vec2", + HgiShaderKeywordTokens->hdPointCoord); + HgiShaderFunctionAddStageInput(&fsDesc, "hd_SampleMaskIn", "uint", + HgiShaderKeywordTokens->hdSampleMaskIn); + HgiShaderFunctionAddStageOutput(&fsDesc, "hd_SampleMask", "uint", + HgiShaderKeywordTokens->hdSampleMask); + } + if (!glslProgram->CompileShader(fsDesc)) { return nullptr; } diff --git a/pxr/imaging/hdSt/mesh.cpp b/pxr/imaging/hdSt/mesh.cpp index 2e467b2673..cf6626795b 100644 --- a/pxr/imaging/hdSt/mesh.cpp +++ b/pxr/imaging/hdSt/mesh.cpp @@ -2617,6 +2617,10 @@ HdStMesh::_UpdateDrawItemGeometricShader(HdSceneDelegate *sceneDelegate, resourceRegistry->GetHgi()->GetCapabilities()-> IsSet(HgiDeviceCapabilitiesBitsMetalTessellation); + bool const nativeRoundPoints = + resourceRegistry->GetHgi()->GetCapabilities()-> + IsSet(HgiDeviceCapabilitiesBitsRoundPoints); + // create a shaderKey and set to the geometric shader. HdSt_MeshShaderKey shaderKey(primType, shadingTerminal, @@ -2638,7 +2642,8 @@ HdStMesh::_UpdateDrawItemGeometricShader(HdSceneDelegate *sceneDelegate, desc.enableScalarOverride, _pointsShadingEnabled, desc.forceOpaqueEdges, - desc.surfaceEdgeIds); + desc.surfaceEdgeIds, + nativeRoundPoints); HdSt_GeometricShaderSharedPtr geomShader = HdSt_GeometricShader::Create(shaderKey, resourceRegistry); @@ -3057,4 +3062,3 @@ HdStMesh::GetInitialDirtyBitsMask() const } PXR_NAMESPACE_CLOSE_SCOPE - diff --git a/pxr/imaging/hdSt/meshShaderKey.cpp b/pxr/imaging/hdSt/meshShaderKey.cpp index 7de6b26a85..32b50699a3 100644 --- a/pxr/imaging/hdSt/meshShaderKey.cpp +++ b/pxr/imaging/hdSt/meshShaderKey.cpp @@ -136,6 +136,12 @@ TF_DEFINE_PRIVATE_TOKENS( ((pointShadedFS, "Fragment.PointShaded")) ((scalarOverrideFS, "Fragment.ScalarOverride")) ((noScalarOverrideFS, "Fragment.NoScalarOverride")) + + // rounded points + ((pointSizeBiasVS, "PointDisk.Vertex.PointSizeBias")) + ((noPointSizeBiasVS, "PointDisk.Vertex.None")) + ((diskSampleMaskFS, "PointDisk.Fragment.SampleMask")) + ((noDiskSampleMaskFS, "PointDisk.Fragment.None")) ); HdSt_MeshShaderKey::HdSt_MeshShaderKey( @@ -159,7 +165,8 @@ HdSt_MeshShaderKey::HdSt_MeshShaderKey( bool enableScalarOverride, bool pointsShadingEnabled, bool forceOpaqueEdges, - bool surfaceEdgeIds) + bool surfaceEdgeIds, + bool nativeRoundPoints) : primType(primitiveType) , cullStyle(cullStyle) , hasMirroredTransform(hasMirroredTransform) @@ -255,8 +262,11 @@ HdSt_MeshShaderKey::HdSt_MeshShaderKey( VS[vsIndex++] = _tokens->pointIdVS; VS[vsIndex++] = _tokens->selDecodeUtils; VS[vsIndex++] = _tokens->selPointSelVS; + VS[vsIndex++] = nativeRoundPoints ? _tokens->noPointSizeBiasVS : + _tokens->pointSizeBiasVS; } else { VS[vsIndex++] = _tokens->pointIdNoneVS; + VS[vsIndex++] = _tokens->noPointSizeBiasVS; } VS[vsIndex++] = _tokens->mainVS; VS[vsIndex] = TfToken(); @@ -313,8 +323,11 @@ HdSt_MeshShaderKey::HdSt_MeshShaderKey( PTVS[ptvsIndex++] = _tokens->pointIdVS; PTVS[ptvsIndex++] = _tokens->selDecodeUtils; PTVS[ptvsIndex++] = _tokens->selPointSelVS; + PTVS[ptvsIndex++] = nativeRoundPoints ? _tokens->noPointSizeBiasVS : + _tokens->pointSizeBiasVS; } else { PTVS[ptvsIndex++] = _tokens->pointIdNoneVS; + PTVS[ptvsIndex++] = _tokens->noPointSizeBiasVS; } if (hasCustomDisplacement) { @@ -579,10 +592,17 @@ HdSt_MeshShaderKey::HdSt_MeshShaderKey( } // PointId mixin for point picking and selection - FS[fsIndex++] = isPrimTypePoints? _tokens->pointIdFS : - _tokens->pointIdFallbackFS; + if (isPrimTypePoints) { + FS[fsIndex++] = _tokens->pointIdFS; + FS[fsIndex++] = nativeRoundPoints ? _tokens->noDiskSampleMaskFS : + _tokens->diskSampleMaskFS; + } else { + FS[fsIndex++] = _tokens->pointIdFallbackFS; + FS[fsIndex++] = _tokens->noDiskSampleMaskFS; + } + FS[fsIndex++] = hasTopologicalVisibility? _tokens->topVisFS : - _tokens->topVisFallbackFS; + _tokens->topVisFallbackFS; // Triangles if (isPrimTypeTris && ptvsStageEnabled) { diff --git a/pxr/imaging/hdSt/meshShaderKey.h b/pxr/imaging/hdSt/meshShaderKey.h index b73a77887d..696565f0e2 100644 --- a/pxr/imaging/hdSt/meshShaderKey.h +++ b/pxr/imaging/hdSt/meshShaderKey.h @@ -50,7 +50,8 @@ struct HdSt_MeshShaderKey : public HdSt_ShaderKey bool enableScalarOverride, bool pointsShadingEnabled, bool forceOpaqueEdges, - bool surfaceEdgeIds); + bool surfaceEdgeIds, + bool nativeRoundPoints); // Note: it looks like gcc 4.8 has a problem issuing // a wrong warning as "array subscript is above array bounds" @@ -103,13 +104,13 @@ struct HdSt_MeshShaderKey : public HdSt_ShaderKey TfToken const *GetFS() const override { return FS; } TfToken glslfx; - TfToken VS[7]; + TfToken VS[8]; TfToken TCS[4]; TfToken TES[4]; TfToken PTCS[4]; - TfToken PTVS[12]; + TfToken PTVS[13]; TfToken GS[10]; - TfToken FS[22]; + TfToken FS[23]; }; diff --git a/pxr/imaging/hdSt/points.cpp b/pxr/imaging/hdSt/points.cpp index 1102458600..23a4e8ecb9 100644 --- a/pxr/imaging/hdSt/points.cpp +++ b/pxr/imaging/hdSt/points.cpp @@ -161,10 +161,15 @@ HdStPoints::_UpdateDrawItem(HdSceneDelegate *sceneDelegate, constantPrimvars, HdTokens->displayOpacity); } - HdSt_PointsShaderKey shaderKey; HdStResourceRegistrySharedPtr resourceRegistry = std::static_pointer_cast( sceneDelegate->GetRenderIndex().GetResourceRegistry()); + + bool const nativeRoundPoints = + resourceRegistry->GetHgi()->GetCapabilities()-> + IsSet(HgiDeviceCapabilitiesBitsRoundPoints); + + HdSt_PointsShaderKey shaderKey{nativeRoundPoints}; drawItem->SetGeometricShader( HdSt_GeometricShader::Create(shaderKey, resourceRegistry)); @@ -434,4 +439,3 @@ HdStPoints::_InitRepr(TfToken const &reprToken, HdDirtyBits *dirtyBits) } PXR_NAMESPACE_CLOSE_SCOPE - diff --git a/pxr/imaging/hdSt/pointsShaderKey.cpp b/pxr/imaging/hdSt/pointsShaderKey.cpp index bcb5456da1..27cddf89a4 100644 --- a/pxr/imaging/hdSt/pointsShaderKey.cpp +++ b/pxr/imaging/hdSt/pointsShaderKey.cpp @@ -32,25 +32,36 @@ TF_DEFINE_PRIVATE_TOKENS( // instancing ((instancing, "Instancing.Transform")) + + // rounded points + ((pointSizeBiasVS, "PointDisk.Vertex.PointSizeBias")) + ((noPointSizeBiasVS, "PointDisk.Vertex.None")) + ((diskSampleMaskFS, "PointDisk.Fragment.SampleMask")) + ((noDiskSampleMaskFS, "PointDisk.Fragment.None")) ); -HdSt_PointsShaderKey::HdSt_PointsShaderKey() +HdSt_PointsShaderKey::HdSt_PointsShaderKey( + bool nativeRoundPoints) : glslfx(_tokens->baseGLSLFX) { VS[0] = _tokens->instancing; - VS[1] = _tokens->mainVS; - VS[2] = _tokens->pointIdVS; - VS[3] = _tokens->pointIdSelDecodeUtilsVS; - VS[4] = _tokens->pointIdSelPointSelVS; - VS[5] = TfToken(); + VS[1] = nativeRoundPoints ? _tokens->noPointSizeBiasVS : + _tokens->pointSizeBiasVS; + VS[2] = _tokens->mainVS; + VS[3] = _tokens->pointIdVS; + VS[4] = _tokens->pointIdSelDecodeUtilsVS; + VS[5] = _tokens->pointIdSelPointSelVS; + VS[6] = TfToken(); // Common must be first as it defines terminal interfaces FS[0] = _tokens->commonFS; FS[1] = _tokens->surfaceFS; FS[2] = _tokens->noScalarOverrideFS; - FS[3] = _tokens->mainFS; - FS[4] = _tokens->pointIdFS; - FS[5] = TfToken(); + FS[3] = nativeRoundPoints ? _tokens->noDiskSampleMaskFS : + _tokens->diskSampleMaskFS; + FS[4] = _tokens->mainFS; + FS[5] = _tokens->pointIdFS; + FS[6] = TfToken(); } HdSt_PointsShaderKey::~HdSt_PointsShaderKey() @@ -58,4 +69,3 @@ HdSt_PointsShaderKey::~HdSt_PointsShaderKey() } PXR_NAMESPACE_CLOSE_SCOPE - diff --git a/pxr/imaging/hdSt/pointsShaderKey.h b/pxr/imaging/hdSt/pointsShaderKey.h index be71588de8..44505bcf7a 100644 --- a/pxr/imaging/hdSt/pointsShaderKey.h +++ b/pxr/imaging/hdSt/pointsShaderKey.h @@ -19,7 +19,7 @@ PXR_NAMESPACE_OPEN_SCOPE struct HdSt_PointsShaderKey : public HdSt_ShaderKey { HDST_API - HdSt_PointsShaderKey(); + HdSt_PointsShaderKey(bool nativeRoundPoints); HDST_API ~HdSt_PointsShaderKey(); @@ -33,8 +33,8 @@ struct HdSt_PointsShaderKey : public HdSt_ShaderKey } TfToken glslfx; - TfToken VS[6]; - TfToken FS[6]; + TfToken VS[7]; + TfToken FS[7]; }; diff --git a/pxr/imaging/hdSt/shaders/basisCurves.glslfx b/pxr/imaging/hdSt/shaders/basisCurves.glslfx index f389a14a64..bb087c1978 100644 --- a/pxr/imaging/hdSt/shaders/basisCurves.glslfx +++ b/pxr/imaging/hdSt/shaders/basisCurves.glslfx @@ -13,6 +13,7 @@ #import $TOOLS/hdSt/shaders/instancing.glslfx #import $TOOLS/hdSt/shaders/terminals.glslfx #import $TOOLS/hdSt/shaders/pointId.glslfx +#import $TOOLS/hdSt/shaders/pointDisk.glslfx #import $TOOLS/hdSt/shaders/visibility.glslfx // Known issues: @@ -138,10 +139,12 @@ void SetTessFactors(float out0, float out1, float out2, float out3, // We will either generate a camera facing normal or use the authored normal. FORWARD_DECL(vec3 getNormal(MAT4 transform)); -// Fwd declare methods defined in pointId.glslfx, that are used below. +// Fwd declare methods defined in pointId.glslfx and points.glslfx +// that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); FORWARD_DECL(void ProcessPointId(int)); +FORWARD_DECL(float ApplyPointSizeBias(float)); void main(void) { @@ -164,7 +167,8 @@ void main(void) #else float scale = 1; #endif - gl_PointSize = GetPointRasterSize(pointId) * scale; + gl_PointSize = ApplyPointSizeBias( + GetPointRasterSize(pointId) * scale); ProcessPointId(pointId); } @@ -216,10 +220,12 @@ vec3 getNormal(MAT4 transform, int index) --- -------------------------------------------------------------------------- -- glsl Curves.Vertex.Wire -// Fwd declare methods defined in pointId.glslfx, that are used below. +// Fwd declare methods defined in pointId.glslfx and points.glslfx +// that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); FORWARD_DECL(void ProcessPointId(int)); +FORWARD_DECL(float ApplyPointSizeBias(float)); void main(void) { @@ -239,8 +245,10 @@ void main(void) #else float scale = 1; #endif - gl_PointSize = GetPointRasterSize(pointId) * scale; - ProcessPointId(pointId);} + gl_PointSize = ApplyPointSizeBias( + GetPointRasterSize(pointId) * scale); + ProcessPointId(pointId); +} --- -------------------------------------------------------------------------- -- glsl Curves.CommonControl @@ -1177,6 +1185,8 @@ Coeffs evaluateBasis(float u, const vec4 cv[4]) void main(void) { + ApplyDiskSampleMask(); + DiscardBasedOnTopologicalVisibility(); vec4 color = vec4(0.5, 0.5, 0.5, 1); @@ -1226,6 +1236,8 @@ void main(void) FORWARD_DECL(vec3 fragmentNormal(vec3 position, vec3 normal, float v)); void main(void) { + ApplyDiskSampleMask(); + DiscardBasedOnTopologicalVisibility(); vec4 color = vec4(0.5, 0.5, 0.5, 1); diff --git a/pxr/imaging/hdSt/shaders/mesh.glslfx b/pxr/imaging/hdSt/shaders/mesh.glslfx index 55bd9e871c..d57d0b1972 100644 --- a/pxr/imaging/hdSt/shaders/mesh.glslfx +++ b/pxr/imaging/hdSt/shaders/mesh.glslfx @@ -17,6 +17,7 @@ #import $TOOLS/hdSt/shaders/terminals.glslfx #import $TOOLS/hdSt/shaders/edgeId.glslfx #import $TOOLS/hdSt/shaders/pointId.glslfx +#import $TOOLS/hdSt/shaders/pointDisk.glslfx #import $TOOLS/hdSt/shaders/visibility.glslfx --- -------------------------------------------------------------------------- @@ -48,7 +49,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -94,7 +95,7 @@ void main(void) MAT4 transform = ApplyInstanceTransform(HdGet_transform()); int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); vec4 point0 = GetWorldToViewMatrix() * transform * vec4(points[0],1.0); @@ -167,7 +168,7 @@ void main(void) MAT4 transform = ApplyInstanceTransform(HdGet_transform()); int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); vec4 point0 = GetWorldToViewMatrix() * transform * vec4(points[0],1.0); @@ -251,7 +252,7 @@ void main(void) MAT4 transform = ApplyInstanceTransform(HdGet_transform()); int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); vec4 point0 = GetWorldToViewMatrix() * transform * vec4(points[0],1.0); @@ -689,7 +690,7 @@ void main(void) MAT4 transform = ApplyInstanceTransform(HdGet_transform()); int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); const ivec3 patchParam = GetPatchParam(); @@ -872,7 +873,7 @@ void main(void) MAT4 transform = ApplyInstanceTransform(HdGet_transform()); int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); const ivec3 patchParam = GetPatchParam(); @@ -1474,6 +1475,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/shaders/pointDisk.glslfx b/pxr/imaging/hdSt/shaders/pointDisk.glslfx new file mode 100644 index 0000000000..3dac0dcd50 --- /dev/null +++ b/pxr/imaging/hdSt/shaders/pointDisk.glslfx @@ -0,0 +1,89 @@ +-- glslfx version 0.1 + +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// + +--- This is what an import might look like. +--- #import $TOOLS/hdSt/shaders/pointDisk.glslfx + +--- -------------------------------------------------------------------------- +-- glsl PointDisk.Vertex.PointSizeBias + +float ApplyPointSizeBias(float pointSize) +{ + if (pointSize <= 0) { + return 0; + } + + // Slightly enlarge the points as the input size reaches 1. + // This improves MSAA and prevents tiny point from disappearing + // when MSAA is disabled. Similar behaviour is observed when + // using native round points on Nvidia GPUs. + if (pointSize < 16.0) { + pointSize += (16.0 - pointSize) * 0.0825; + } + + // We must enlarge the point ever so slightly to make + // sure that the rounding sample mask doesn't conflict + // with the input edge sample mask. We want our input + // sample mask to always be all 1s. This is compensated + // in the fragment shader. + pointSize += 0.5; + + return pointSize; +} + +--- -------------------------------------------------------------------------- +-- glsl PointDisk.Vertex.None + +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + +--- -------------------------------------------------------------------------- +-- glsl PointDisk.Fragment.SampleMask + +void ApplyDiskSampleMask() +{ + // By using the sample mask directly, don't dependent on the + // alpha-to-coverage or multisampling state. + + // We can ignore dFdy(gl_PointCoord.y) because on a + // square it's the same as dFdx(gl_PointCoord.x). + const float pointSize = 1.0 / dFdx(gl_PointCoord.x); + const float pointSdf = length(gl_PointCoord - 0.5) - 0.5; + // +0.25 to compensate for enlargement in the vertex shader. + const float pointSdfPx = pointSdf * pointSize + 0.25; + if (pointSdfPx < -1) { + // Inside disk edge + hd_SampleMask = hd_SampleMaskIn; + } else if (pointSdfPx > 0) { + // Outside disk + hd_SampleMask = 0; + } else { + // On the disk edge + const float edgeSdf = clamp(-pointSdfPx, 0.0, 1.0); +#ifdef HD_HAS_multisampleCount + const int sampleCount = int(round(HdGet_multisampleCount() * edgeSdf)); +#else + const int sampleCount = int(round(edgeSdf)); +#endif + const int sampleMask = ((1 << sampleCount) - 1); + hd_SampleMask = hd_SampleMaskIn & sampleMask; + } +} + +--- -------------------------------------------------------------------------- +-- glsl PointDisk.Fragment.None + +void ApplyDiskSampleMask() +{ + // do nothing +} + diff --git a/pxr/imaging/hdSt/shaders/points.glslfx b/pxr/imaging/hdSt/shaders/points.glslfx index 1e8ad2d623..f76e839d4c 100644 --- a/pxr/imaging/hdSt/shaders/points.glslfx +++ b/pxr/imaging/hdSt/shaders/points.glslfx @@ -13,6 +13,7 @@ #import $TOOLS/hdSt/shaders/instancing.glslfx #import $TOOLS/hdSt/shaders/terminals.glslfx #import $TOOLS/hdSt/shaders/pointId.glslfx +#import $TOOLS/hdSt/shaders/pointDisk.glslfx --- -------------------------------------------------------------------------- -- layout Point.Vertex @@ -106,6 +107,7 @@ void main(void) ApplyClipPlanes(outData.Peye); float screenSpaceWidth = ComputeRasterPointSize(transform, outData.Peye.z); + screenSpaceWidth = ApplyPointSizeBias(screenSpaceWidth); gl_PointSize = clamp(screenSpaceWidth, HD_GL_POINT_SIZE_MIN, HD_GL_POINT_SIZE_MAX); @@ -126,6 +128,8 @@ void main(void) void main(void) { + ApplyDiskSampleMask(); + vec3 Peye = inData.Peye.xyz / inData.Peye.w; // camera facing. vec3 Neye = vec3(0, 0, 1); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp b/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp index c44c5867fb..5bcd42e928 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp @@ -387,8 +387,9 @@ int main(int argc, char *argv[]) /* enableScalarOverride */ true, /* isWidget */ false, /* forceOpaqueEdges */ true, - /* surfaceEdgeIds */ true), - instance, smoothNormals); + /* surfaceEdgeIds */ true, + /* nativeRoundPoints */ true), + instance, smoothNormals); success &= TestShader( registry, HdSt_MeshShaderKey( @@ -412,8 +413,9 @@ int main(int argc, char *argv[]) /* enableScalarOverride */ true, /* isWidget */ false, /* forceOpaqueEdges */ true, - /* surfaceEdgeIds */ true), - instance, smoothNormals); + /* surfaceEdgeIds */ true, + /* nativeRoundPoints */ true), + instance, smoothNormals); } // curves @@ -427,15 +429,16 @@ int main(int argc, char *argv[]) true, HdBasisCurvesReprDescTokens->surfaceShader, topologicalVisibility, - /* isWidget */ false, false), - instance, false); + /* isWidget */ false, + /* hasMetalTessellation */ false, + /* nativeRoundPoints */ true), + instance, false); } // points if (points) { - success &= TestShader(registry, - HdSt_PointsShaderKey(), - instance, false); + success &= TestShader(registry, HdSt_PointsShaderKey( + /* nativeRoundPoints */ false), instance, false); } if (success) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_indirect.out index 177144a152..5d5af10729 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_indirect.out @@ -3,10 +3,10 @@ #import $TOOLS/hdSt/shaders/basisCurves.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "Curves.Vertex.Wire", "Curves.Vertex.Normal.Implicit", "PointId.Vertex.None"] } +"vertexShader" : { "source" : ["Instancing.Transform", "Curves.Vertex.Wire", "Curves.Vertex.Normal.Implicit", "PointId.Vertex.None", "PointDisk.Vertex.None"] } , "tessControlShader" : { "source" : ["Curves.CommonData", "Curves.TessFactorsGLSL", "Curves.CommonControl", "Curves.Tess.CurveData.Wire", "Curves.TessControl.Cubic.Wire"] } , "tessEvalShader" : { "source" : ["Curves.CommonData", "Instancing.Transform", "Curves.Tess.CurveData.Wire", "Curves.TessEval.Cubic.Wire", "Curves.BezierBasis", "Curves.Cubic.VaryingInterpolation"] } -, "fragmentShader" : { "source" : ["Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Curves.Fragment.Wire"] } +, "fragmentShader" : { "source" : ["Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Curves.Fragment.Wire"] } }}} ------------------------------------------------------- ======================================================= @@ -613,10 +613,12 @@ bool IsFlipped() } -// Fwd declare methods defined in pointId.glslfx, that are used below. +// Fwd declare methods defined in pointId.glslfx and points.glslfx +// that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); FORWARD_DECL(void ProcessPointId(int)); +FORWARD_DECL(float ApplyPointSizeBias(float)); void main(void) { @@ -636,8 +638,10 @@ void main(void) #else float scale = 1; #endif - gl_PointSize = GetPointRasterSize(pointId) * scale; - ProcessPointId(pointId);} + gl_PointSize = ApplyPointSizeBias( + GetPointRasterSize(pointId) * scale); + ProcessPointId(pointId); +} @@ -666,6 +670,14 @@ void ProcessPointId(int pointId) } + +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + ======================================================= TESS CONTROL SHADER ======================================================= @@ -2640,6 +2652,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2649,6 +2668,8 @@ void DiscardBasedOnTopologicalVisibility() void main(void) { + ApplyDiskSampleMask(); + DiscardBasedOnTopologicalVisibility(); vec4 color = vec4(0.5, 0.5, 0.5, 1); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly.out index 09d854645e..ba306608f0 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskTriangle", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyNoBlend", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleLines", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskTriangle", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyNoBlend", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleLines", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -643,6 +643,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -659,7 +667,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -2634,6 +2642,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2681,6 +2696,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2727,9 +2744,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskQuad", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyNoBlend", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadLines", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskQuad", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyNoBlend", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadLines", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -3367,6 +3384,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3383,7 +3408,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -5392,6 +5417,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5439,6 +5471,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly_blendwireframe.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly_blendwireframe.out index 88fb7d46c3..32cbf1baa4 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly_blendwireframe.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly_blendwireframe.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskTriangle", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyBlendColor", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleLines", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskTriangle", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyBlendColor", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleLines", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -643,6 +643,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -659,7 +667,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -2640,6 +2648,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2687,6 +2702,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2733,9 +2750,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskQuad", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyBlendColor", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadLines", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskQuad", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyBlendColor", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadLines", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -3373,6 +3390,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3389,7 +3414,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -5404,6 +5429,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5451,6 +5483,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect.out index d07406acf2..d0f55f58f9 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -643,6 +643,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -659,7 +667,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -2585,6 +2593,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2632,6 +2647,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2678,9 +2695,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -3318,6 +3335,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3334,7 +3359,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -5292,6 +5317,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5339,6 +5371,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_doubleSided.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_doubleSided.out index 54211f9db5..c015cde4c2 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_doubleSided.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_doubleSided.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.DoubleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.DoubleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -643,6 +643,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -659,7 +667,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -2584,6 +2592,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2631,6 +2646,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2677,9 +2694,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.DoubleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.DoubleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -3317,6 +3334,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3333,7 +3358,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -5290,6 +5315,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5337,6 +5369,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_faceVarying.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_faceVarying.out index d07406acf2..d0f55f58f9 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_faceVarying.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_faceVarying.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -643,6 +643,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -659,7 +667,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -2585,6 +2593,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2632,6 +2647,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2678,9 +2695,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -3318,6 +3335,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3334,7 +3359,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -5292,6 +5317,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5339,6 +5371,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_instance.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_instance.out index 41c1675225..f95e3e2d35 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_instance.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_instance.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -693,6 +693,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -709,7 +717,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -2690,6 +2698,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2737,6 +2752,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2783,9 +2800,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -3473,6 +3490,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3489,7 +3514,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -5502,6 +5527,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5549,6 +5581,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_smoothNormals.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_smoothNormals.out index 164c40fd0a..f2217a7de4 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_smoothNormals.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_smoothNormals.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Smooth", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Smooth", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -656,6 +656,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -672,7 +680,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -2585,6 +2593,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2632,6 +2647,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2678,9 +2695,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Smooth", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Smooth", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -3331,6 +3348,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3347,7 +3372,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -5292,6 +5317,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5339,6 +5371,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_indirect.out index ca9ae8d020..af2032fef9 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_indirect.out @@ -3,8 +3,8 @@ #import $TOOLS/hdSt/shaders/points.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "Point.Vertex", "PointId.Vertex.PointParam", "Selection.DecodeUtils", "Selection.Vertex.PointSel"] } -, "fragmentShader" : { "source" : ["Fragment.CommonTerminals", "Fragment.Surface", "Fragment.NoScalarOverride", "Point.Fragment", "PointId.Fragment.PointParam"] } +"vertexShader" : { "source" : ["Instancing.Transform", "PointDisk.Vertex.PointSizeBias", "Point.Vertex", "PointId.Vertex.PointParam", "Selection.DecodeUtils", "Selection.Vertex.PointSel"] } +, "fragmentShader" : { "source" : ["Fragment.CommonTerminals", "Fragment.Surface", "Fragment.NoScalarOverride", "PointDisk.Fragment.SampleMask", "Point.Fragment", "PointId.Fragment.PointParam"] } }}} ------------------------------------------------------- ======================================================= @@ -608,6 +608,32 @@ bool IsFlipped() } +float ApplyPointSizeBias(float pointSize) +{ + if (pointSize <= 0) { + return 0; + } + + // Slightly enlarge the points as the input size reaches 1. + // This improves MSAA and prevents tiny point from disappearing + // when MSAA is disabled. Similar behaviour is observed when + // using native round points on Nvidia GPUs. + if (pointSize < 16.0) { + pointSize += (16.0 - pointSize) * 0.0825; + } + + // We must enlarge the point ever so slightly to make + // sure that the rounding sample mask doesn't conflict + // with the input edge sample mask. We want our input + // sample mask to always be all 1s. This is compensated + // in the fragment shader. + pointSize += 0.5; + + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(void ProcessPointId(int)); @@ -688,6 +714,7 @@ void main(void) ApplyClipPlanes(outData.Peye); float screenSpaceWidth = ComputeRasterPointSize(transform, outData.Peye.z); + screenSpaceWidth = ApplyPointSizeBias(screenSpaceWidth); gl_PointSize = clamp(screenSpaceWidth, HD_GL_POINT_SIZE_MIN, HD_GL_POINT_SIZE_MAX); @@ -1754,8 +1781,42 @@ ScalarOverride GetScalarOverride() } +void ApplyDiskSampleMask() +{ + // By using the sample mask directly, don't dependent on the + // alpha-to-coverage or multisampling state. + + // We can ignore dFdy(gl_PointCoord.y) because on a + // square it's the same as dFdx(gl_PointCoord.x). + const float pointSize = 1.0 / dFdx(gl_PointCoord.x); + const float pointSdf = length(gl_PointCoord - 0.5) - 0.5; + // +0.25 to compensate for enlargement in the vertex shader. + const float pointSdfPx = pointSdf * pointSize + 0.25; + if (pointSdfPx < -1) { + // Inside disk edge + hd_SampleMask = hd_SampleMaskIn; + } else if (pointSdfPx > 0) { + // Outside disk + hd_SampleMask = 0; + } else { + // On the disk edge + const float edgeSdf = clamp(-pointSdfPx, 0.0, 1.0); +#ifdef HD_HAS_multisampleCount + const int sampleCount = int(round(HdGet_multisampleCount() * edgeSdf)); +#else + const int sampleCount = int(round(edgeSdf)); +#endif + const int sampleMask = ((1 << sampleCount) - 1); + hd_SampleMask = hd_SampleMaskIn & sampleMask; + } +} + + + void main(void) { + ApplyDiskSampleMask(); + vec3 Peye = inData.Peye.xyz / inData.Peye.w; // camera facing. vec3 Neye = vec3(0, 0, 1); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_curves_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_curves_indirect.out index 172f95d7a9..322aa9e2a4 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_curves_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_curves_indirect.out @@ -3,10 +3,10 @@ #import $TOOLS/hdSt/shaders/basisCurves.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "Curves.Vertex.Wire", "Curves.Vertex.Normal.Implicit", "PointId.Vertex.None"] } +"vertexShader" : { "source" : ["Instancing.Transform", "Curves.Vertex.Wire", "Curves.Vertex.Normal.Implicit", "PointId.Vertex.None", "PointDisk.Vertex.None"] } , "tessControlShader" : { "source" : ["Curves.CommonData", "Curves.TessFactorsGLSL", "Curves.CommonControl", "Curves.Tess.CurveData.Wire", "Curves.TessControl.Cubic.Wire"] } , "tessEvalShader" : { "source" : ["Curves.CommonData", "Instancing.Transform", "Curves.Tess.CurveData.Wire", "Curves.TessEval.Cubic.Wire", "Curves.BezierBasis", "Curves.Cubic.VaryingInterpolation"] } -, "fragmentShader" : { "source" : ["Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Curves.Fragment.Wire"] } +, "fragmentShader" : { "source" : ["Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Curves.Fragment.Wire"] } }}} ------------------------------------------------------- ======================================================= @@ -610,10 +610,12 @@ bool IsFlipped() } -// Fwd declare methods defined in pointId.glslfx, that are used below. +// Fwd declare methods defined in pointId.glslfx and points.glslfx +// that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); FORWARD_DECL(void ProcessPointId(int)); +FORWARD_DECL(float ApplyPointSizeBias(float)); void main(void) { @@ -633,8 +635,10 @@ void main(void) #else float scale = 1; #endif - gl_PointSize = GetPointRasterSize(pointId) * scale; - ProcessPointId(pointId);} + gl_PointSize = ApplyPointSizeBias( + GetPointRasterSize(pointId) * scale); + ProcessPointId(pointId); +} @@ -663,6 +667,14 @@ void ProcessPointId(int pointId) } + +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + ======================================================= TESS CONTROL SHADER ======================================================= @@ -2621,6 +2633,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2630,6 +2649,8 @@ void DiscardBasedOnTopologicalVisibility() void main(void) { + ApplyDiskSampleMask(); + DiscardBasedOnTopologicalVisibility(); vec4 color = vec4(0.5, 0.5, 0.5, 1); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly.out index 19f06f9da1..2178002152 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskTriangle", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyNoBlend", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleLines", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskTriangle", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyNoBlend", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleLines", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -640,6 +640,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -656,7 +664,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -2620,6 +2628,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2667,6 +2682,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2713,9 +2730,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskQuad", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyNoBlend", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadLines", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskQuad", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyNoBlend", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadLines", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -3350,6 +3367,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3366,7 +3391,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -5364,6 +5389,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5411,6 +5443,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly_blendwireframe.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly_blendwireframe.out index 97bab4c30c..6a723ed210 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly_blendwireframe.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly_blendwireframe.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskTriangle", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyBlendColor", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleLines", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskTriangle", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyBlendColor", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleLines", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -640,6 +640,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -656,7 +664,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -2626,6 +2634,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2673,6 +2688,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2719,9 +2736,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskQuad", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyBlendColor", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadLines", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.EdgeCoord.Barycentric", "MeshWire.Fragment.EdgeMaskQuad", "MeshWire.Fragment.EdgeCommon", "MeshWire.Fragment.EdgeParam", "MeshWire.Fragment.FinalEdgeOpacityForce", "MeshWire.Fragment.EdgeOnlyBlendColor", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadLines", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -3356,6 +3373,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3372,7 +3397,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -5376,6 +5401,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5423,6 +5455,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect.out index 903c22cfb6..0d0f15b96c 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -640,6 +640,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -656,7 +664,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -2571,6 +2579,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2618,6 +2633,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2664,9 +2681,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -3301,6 +3318,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3317,7 +3342,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -5264,6 +5289,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5311,6 +5343,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_doubleSided.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_doubleSided.out index a0aee429e6..2ae915a42e 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_doubleSided.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_doubleSided.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.DoubleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.DoubleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -640,6 +640,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -656,7 +664,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -2570,6 +2578,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2617,6 +2632,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2663,9 +2680,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.DoubleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.DoubleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -3300,6 +3317,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3316,7 +3341,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -5262,6 +5287,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5309,6 +5341,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_faceVarying.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_faceVarying.out index 903c22cfb6..0d0f15b96c 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_faceVarying.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_faceVarying.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -640,6 +640,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -656,7 +664,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -2571,6 +2579,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2618,6 +2633,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2664,9 +2681,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -3301,6 +3318,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3317,7 +3342,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -5264,6 +5289,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5311,6 +5343,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_instance.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_instance.out index 5c659848a6..4b5de9bcb4 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_instance.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_instance.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -690,6 +690,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -706,7 +714,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -2676,6 +2684,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2723,6 +2738,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2769,9 +2786,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -3456,6 +3473,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3472,7 +3497,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -5474,6 +5499,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5521,6 +5553,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_smoothNormals.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_smoothNormals.out index 2a576844d1..b001478b38 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_smoothNormals.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_smoothNormals.out @@ -3,9 +3,9 @@ #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Smooth", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Smooth", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -653,6 +653,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -669,7 +677,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -2571,6 +2579,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -2618,6 +2633,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); @@ -2664,9 +2681,9 @@ void main(void) #import $TOOLS/hdSt/shaders/mesh.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Smooth", "PointId.Vertex.None", "Mesh.Vertex"] } +"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Smooth", "PointId.Vertex.None", "PointDisk.Vertex.None", "Mesh.Vertex"] } , "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } +, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "PointDisk.Fragment.None", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } }}} ------------------------------------------------------- ======================================================= @@ -3314,6 +3331,14 @@ void ProcessPointId(int pointId) +float ApplyPointSizeBias(float pointSize) +{ + // do nothing + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(float GetPointRasterSize(int)); @@ -3330,7 +3355,7 @@ void main(void) outData.Neye = GetNormal(vec3(0), 0); // normalized int pointId = GetPointId(); - gl_PointSize = GetPointRasterSize(pointId); + gl_PointSize = ApplyPointSizeBias(GetPointRasterSize(pointId)); ProcessPointId(pointId); gl_Position = vec4(GetProjectionMatrix() * outData.Peye); @@ -5264,6 +5289,13 @@ int GetPointId() } + +void ApplyDiskSampleMask() +{ + // do nothing +} + + void DiscardBasedOnTopologicalVisibility() { // Nothing to do, since there's no authored opinion. @@ -5311,6 +5343,8 @@ vec3 ComputeScreenSpaceNeye() void main(void) { + ApplyDiskSampleMask(); + bool isFlipped = IsFlipped(); DiscardBasedOnShading(gl_FrontFacing, isFlipped); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_points_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_points_indirect.out index ba79a946e3..21542e95b9 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_points_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_points_indirect.out @@ -3,8 +3,8 @@ #import $TOOLS/hdSt/shaders/points.glslfx -- configuration {"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "Point.Vertex", "PointId.Vertex.PointParam", "Selection.DecodeUtils", "Selection.Vertex.PointSel"] } -, "fragmentShader" : { "source" : ["Fragment.CommonTerminals", "Fragment.Surface", "Fragment.NoScalarOverride", "Point.Fragment", "PointId.Fragment.PointParam"] } +"vertexShader" : { "source" : ["Instancing.Transform", "PointDisk.Vertex.PointSizeBias", "Point.Vertex", "PointId.Vertex.PointParam", "Selection.DecodeUtils", "Selection.Vertex.PointSel"] } +, "fragmentShader" : { "source" : ["Fragment.CommonTerminals", "Fragment.Surface", "Fragment.NoScalarOverride", "PointDisk.Fragment.SampleMask", "Point.Fragment", "PointId.Fragment.PointParam"] } }}} ------------------------------------------------------- ======================================================= @@ -605,6 +605,32 @@ bool IsFlipped() } +float ApplyPointSizeBias(float pointSize) +{ + if (pointSize <= 0) { + return 0; + } + + // Slightly enlarge the points as the input size reaches 1. + // This improves MSAA and prevents tiny point from disappearing + // when MSAA is disabled. Similar behaviour is observed when + // using native round points on Nvidia GPUs. + if (pointSize < 16.0) { + pointSize += (16.0 - pointSize) * 0.0825; + } + + // We must enlarge the point ever so slightly to make + // sure that the rounding sample mask doesn't conflict + // with the input edge sample mask. We want our input + // sample mask to always be all 1s. This is compensated + // in the fragment shader. + pointSize += 0.5; + + return pointSize; +} + + + // Fwd declare methods defined in pointId.glslfx, that are used below. FORWARD_DECL(int GetPointId()); FORWARD_DECL(void ProcessPointId(int)); @@ -685,6 +711,7 @@ void main(void) ApplyClipPlanes(outData.Peye); float screenSpaceWidth = ComputeRasterPointSize(transform, outData.Peye.z); + screenSpaceWidth = ApplyPointSizeBias(screenSpaceWidth); gl_PointSize = clamp(screenSpaceWidth, HD_GL_POINT_SIZE_MIN, HD_GL_POINT_SIZE_MAX); @@ -1745,8 +1772,42 @@ ScalarOverride GetScalarOverride() } +void ApplyDiskSampleMask() +{ + // By using the sample mask directly, don't dependent on the + // alpha-to-coverage or multisampling state. + + // We can ignore dFdy(gl_PointCoord.y) because on a + // square it's the same as dFdx(gl_PointCoord.x). + const float pointSize = 1.0 / dFdx(gl_PointCoord.x); + const float pointSdf = length(gl_PointCoord - 0.5) - 0.5; + // +0.25 to compensate for enlargement in the vertex shader. + const float pointSdfPx = pointSdf * pointSize + 0.25; + if (pointSdfPx < -1) { + // Inside disk edge + hd_SampleMask = hd_SampleMaskIn; + } else if (pointSdfPx > 0) { + // Outside disk + hd_SampleMask = 0; + } else { + // On the disk edge + const float edgeSdf = clamp(-pointSdfPx, 0.0, 1.0); +#ifdef HD_HAS_multisampleCount + const int sampleCount = int(round(HdGet_multisampleCount() * edgeSdf)); +#else + const int sampleCount = int(round(edgeSdf)); +#endif + const int sampleMask = ((1 << sampleCount) - 1); + hd_SampleMask = hd_SampleMaskIn & sampleMask; + } +} + + + void main(void) { + ApplyDiskSampleMask(); + vec3 Peye = inData.Peye.xyz / inData.Peye.w; // camera facing. vec3 Neye = vec3(0, 0, 1); diff --git a/pxr/imaging/hdSt/testenv/testHdStDrawBatching.cpp b/pxr/imaging/hdSt/testenv/testHdStDrawBatching.cpp index 7f5e9ef24a..603f6d8501 100644 --- a/pxr/imaging/hdSt/testenv/testHdStDrawBatching.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStDrawBatching.cpp @@ -218,7 +218,8 @@ _RegisterDrawItem( /*enableScalarOverride=*/ true, /*isWidget*/ false, /* forceOpaqueEdges */ true, - /* surfaceEdgeIds */ true); + /* surfaceEdgeIds */ true, + /* nativeRoundPoints */ true); // need to register to get batching works HdSt_GeometricShaderSharedPtr const geomShader = @@ -707,7 +708,7 @@ EmptyDrawBatchTest(HdStResourceRegistrySharedPtr const ®istry) sharedData.bounds.SetRange(range); HdStDrawItem drawItem(&sharedData); - HdSt_PointsShaderKey shaderKey; + HdSt_PointsShaderKey shaderKey{/*nativeRoundPoints*/false}; // need to register to get batching works HdSt_GeometricShaderSharedPtr const geomShader = @@ -778,4 +779,3 @@ int main() return EXIT_FAILURE; } } - diff --git a/pxr/imaging/hdSt/testenv/testHdStQualifiers.cpp b/pxr/imaging/hdSt/testenv/testHdStQualifiers.cpp index 7005f497db..f457d63ad1 100644 --- a/pxr/imaging/hdSt/testenv/testHdStQualifiers.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStQualifiers.cpp @@ -249,7 +249,7 @@ My_TestGLDrawing::DrawTest() _tokens->glslfxFilename, _tokens->defaultToken); HdStShaderCodeSharedPtrVector shaders = { renderPassShader, shader }; - HdSt_PointsShaderKey shaderKey = HdSt_PointsShaderKey(); + HdSt_PointsShaderKey shaderKey{/*nativeRoundPoints*/false}; // Create the geometric shader. HdInstance geometricShaderInstance = diff --git a/pxr/imaging/hgi/enums.h b/pxr/imaging/hgi/enums.h index 5811b2c598..ca300584c2 100644 --- a/pxr/imaging/hgi/enums.h +++ b/pxr/imaging/hgi/enums.h @@ -58,6 +58,8 @@ using HgiBits = uint32_t; /// The device requires workaround for primitive id ///
  • HgiDeviceCapabilitiesBitsIndirectCommandBuffers: /// Indirect command buffers are supported
  • +///
  • HgiDeviceCapabilitiesBitsRoundPoints: +/// Points can be natively rasterized as disks
  • /// /// enum HgiDeviceCapabilitiesBits : HgiBits @@ -80,6 +82,7 @@ enum HgiDeviceCapabilitiesBits : HgiBits HgiDeviceCapabilitiesBitsBasePrimitiveOffset = 1 << 15, HgiDeviceCapabilitiesBitsPrimitiveIdEmulation = 1 << 16, HgiDeviceCapabilitiesBitsIndirectCommandBuffers = 1 << 17, + HgiDeviceCapabilitiesBitsRoundPoints = 1 << 18, }; using HgiDeviceCapabilities = HgiBits; diff --git a/pxr/imaging/hgiGL/capabilities.cpp b/pxr/imaging/hgiGL/capabilities.cpp index 4dc54436f6..df295385ce 100644 --- a/pxr/imaging/hgiGL/capabilities.cpp +++ b/pxr/imaging/hgiGL/capabilities.cpp @@ -191,6 +191,8 @@ HgiGLCapabilities::_LoadCapabilities() true); _SetFlag(HgiDeviceCapabilitiesBitsCustomDepthRange, true); + _SetFlag(HgiDeviceCapabilitiesBitsRoundPoints, + true); if (TfDebug::IsEnabled(HGI_DEBUG_DEVICE_CAPABILITIES)) { std::cout diff --git a/pxr/usdImaging/usdImagingGL/CMakeLists.txt b/pxr/usdImaging/usdImagingGL/CMakeLists.txt index e932e367ec..23636c903e 100644 --- a/pxr/usdImaging/usdImagingGL/CMakeLists.txt +++ b/pxr/usdImaging/usdImagingGL/CMakeLists.txt @@ -5533,10 +5533,10 @@ if (PTEX_FOUND AND ${PXR_ENABLE_PTEX_SUPPORT}) COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -offscreen -frameAll -lighting -stage instance.usda -write testUsdImagingGLInstancing_instance.png" IMAGE_DIFF_COMPARE testUsdImagingGLInstancing_instance.png - FAIL 0.01 - FAIL_PERCENT 0.005 - WARN 0.02 - WARN_PERCENT 0.0025 + FAIL 0.02 + FAIL_PERCENT 0.075 + WARN 0.01 + WARN_PERCENT 0.005 EXPECTED_RETURN_CODE 0 TESTENV testUsdImagingGLInstancing ) @@ -5545,10 +5545,10 @@ if (PTEX_FOUND AND ${PXR_ENABLE_PTEX_SUPPORT}) COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -offscreen -frameAll -lighting -stage instance2.usda -write testUsdImagingGLInstancing_instance2.png" IMAGE_DIFF_COMPARE testUsdImagingGLInstancing_instance2.png - FAIL 0.01 - FAIL_PERCENT 0.005 - WARN 0.02 - WARN_PERCENT 0.0025 + FAIL 0.02 + FAIL_PERCENT 0.075 + WARN 0.01 + WARN_PERCENT 0.005 EXPECTED_RETURN_CODE 0 TESTENV testUsdImagingGLInstancing ) @@ -5558,9 +5558,9 @@ if (PTEX_FOUND AND ${PXR_ENABLE_PTEX_SUPPORT}) IMAGE_DIFF_COMPARE testUsdImagingGLInstancing_instance3.png FAIL 0.02 - FAIL_PERCENT 0.005 - WARN 0.02 - WARN_PERCENT 0.0025 + FAIL_PERCENT 0.075 + WARN 0.01 + WARN_PERCENT 0.005 EXPECTED_RETURN_CODE 0 TESTENV testUsdImagingGLInstancing ) @@ -5570,9 +5570,9 @@ if (PTEX_FOUND AND ${PXR_ENABLE_PTEX_SUPPORT}) IMAGE_DIFF_COMPARE testUsdImagingGLInstancing_nestedInstance.png FAIL 0.02 - FAIL_PERCENT 0.005 - WARN 0.02 - WARN_PERCENT 0.0025 + FAIL_PERCENT 0.075 + WARN 0.01 + WARN_PERCENT 0.005 EXPECTED_RETURN_CODE 0 TESTENV testUsdImagingGLInstancing ) @@ -5581,10 +5581,10 @@ if (PTEX_FOUND AND ${PXR_ENABLE_PTEX_SUPPORT}) COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -offscreen -frameAll -lighting -stage instance.usda -write testUsdImagingGLInstancing_instance.png" IMAGE_DIFF_COMPARE testUsdImagingGLInstancing_instance.png - FAIL 0.01 - FAIL_PERCENT 0.005 - WARN 0.02 - WARN_PERCENT 0.0025 + FAIL 0.02 + FAIL_PERCENT 0.075 + WARN 0.01 + WARN_PERCENT 0.005 EXPECTED_RETURN_CODE 0 TESTENV testUsdImagingGLInstancing_SceneIndex ) @@ -5593,10 +5593,10 @@ if (PTEX_FOUND AND ${PXR_ENABLE_PTEX_SUPPORT}) COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -offscreen -frameAll -lighting -stage instance2.usda -write testUsdImagingGLInstancing_instance2.png" IMAGE_DIFF_COMPARE testUsdImagingGLInstancing_instance2.png - FAIL 0.01 - FAIL_PERCENT 0.005 - WARN 0.02 - WARN_PERCENT 0.0025 + FAIL 0.02 + FAIL_PERCENT 0.075 + WARN 0.01 + WARN_PERCENT 0.005 EXPECTED_RETURN_CODE 0 TESTENV testUsdImagingGLInstancing_SceneIndex ) @@ -5606,9 +5606,9 @@ if (PTEX_FOUND AND ${PXR_ENABLE_PTEX_SUPPORT}) IMAGE_DIFF_COMPARE testUsdImagingGLInstancing_instance3.png FAIL 0.02 - FAIL_PERCENT 0.005 - WARN 0.02 - WARN_PERCENT 0.0025 + FAIL_PERCENT 0.075 + WARN 0.01 + WARN_PERCENT 0.005 EXPECTED_RETURN_CODE 0 TESTENV testUsdImagingGLInstancing_SceneIndex ) @@ -5618,9 +5618,9 @@ if (PTEX_FOUND AND ${PXR_ENABLE_PTEX_SUPPORT}) IMAGE_DIFF_COMPARE testUsdImagingGLInstancing_nestedInstance.png FAIL 0.02 - FAIL_PERCENT 0.005 - WARN 0.02 - WARN_PERCENT 0.0025 + FAIL_PERCENT 0.075 + WARN 0.01 + WARN_PERCENT 0.005 EXPECTED_RETURN_CODE 0 TESTENV testUsdImagingGLInstancing_SceneIndex ENV diff --git a/pxr/usdImaging/usdImagingGL/engine.cpp b/pxr/usdImaging/usdImagingGL/engine.cpp index bc822e8d1b..c1807f84b9 100644 --- a/pxr/usdImaging/usdImagingGL/engine.cpp +++ b/pxr/usdImaging/usdImagingGL/engine.cpp @@ -2015,4 +2015,3 @@ UsdImagingGLEngine::PollForAsynchronousUpdates() const } PXR_NAMESPACE_CLOSE_SCOPE -