Skip to content

Commit 6fb3004

Browse files
authored
HYDRA-2005 : Fix depth peeling with USD data (#370)
1 parent dc11f90 commit 6fb3004

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

lib/mayaHydra/mayaPlugin/renderOverrideUtils.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,22 @@
1818
#ifndef MTOH_VIEW_OVERRIDE_UTILS_H
1919
#define MTOH_VIEW_OVERRIDE_UTILS_H
2020

21+
#include <mayaUsdAPI/utils.h>
22+
23+
#include <maya/MViewport2Renderer.h>
24+
2125
#include <pxr/pxr.h>
2226

2327
PXR_NAMESPACE_OPEN_SCOPE
2428

29+
// 2026-01-14 : The MayaHydraPreRender operation currently does two things :
30+
// 1. Draw the pre-scene UI, i.e. the grid
31+
// 2. Update the internal OGS scene
32+
// This second behavior isn't explicit and obvious, but is necessary for
33+
// the DataServer API to properly translate the Maya scene later on.
34+
// This means that we cannot exclude everything except the grid in
35+
// getObjectTypeExclusions(), as that would prevent the render items for
36+
// other objects in the scene from being created/updated.
2537
class MayaHydraPreRender : public MHWRender::MSceneRender
2638
{
2739
public:
@@ -31,18 +43,37 @@ class MayaHydraPreRender : public MHWRender::MSceneRender
3143
/// To keep the colors always sync'ed, reuse same clear colors as global ones instead of set
3244
/// the same colors explicitly.
3345
mClearOperation.setOverridesColors(false);
46+
47+
// 2026-01-14 : MayaUsd data is translated separately by MayaHydra, so we must exclude it from the update.
48+
// If we don't, the MayaUsd proxy shape will be processed as part of this operation, and when
49+
// using depth peeling, the MayaUsd render items will be drawn to the depth buffer. This later
50+
// causes z-fighting issues when compositing the Hydra render on top of the Maya framebuffer.
51+
_pluginDisplayFilterExclusions.append(MAYAUSDAPI_NS::getProxyShapeDisplayFilter());
3452
}
3553

3654
MUint64 getObjectTypeExclusions() override
3755
{
3856
/// To skip the generation of some unwanted render lists even the kRenderPreSceneUIItems
3957
/// filter is specified.
58+
/// 2026-01-14 : Note that since we implicitly rely on MayaHydraPreRender to update the internal OGS
59+
/// scene, we must keep most elements included so that they are translated by the
60+
/// DataServer API later.
4061
return MFrameContext::kExcludeManipulators | MFrameContext::kExcludeHUD;
4162
}
4263

64+
#if (MAYA_API_VERSION >= 20270000) // Method is only available in Maya 2027+
65+
MStringArray& pluginDisplayFilterExclusions() override
66+
{
67+
return _pluginDisplayFilterExclusions;
68+
}
69+
#endif
70+
4371
MSceneFilterOption renderFilterOverride() override { return kRenderPreSceneUIItems; }
4472

4573
MHWRender::MClearOperation& clearOperation() override { return mClearOperation; }
74+
75+
private:
76+
MStringArray _pluginDisplayFilterExclusions;
4677
};
4778

4879
class MayaHydraPostRender : public MHWRender::MSceneRender

0 commit comments

Comments
 (0)