0

I'm working on a shader that runs two passes:

  • A standard vertex / pixel shader that draws the original object with some alpha blending
  • A geometry shader that subdivides the mesh and makes it crumble

My issue however is that the geometry of the first pass occludes the geometry of the second pass. Even when the original geometry is fully transparent, it completely culls whatever geometry from the second pass is behind it. The original geometry is a sphere, which as you can see here occludes the result of the geometry shader

The first pass uses this blending mode:

BlendState SrcAlphaBlendingAdd
{
    BlendEnable[0] = TRUE;
    SrcBlend = SRC_ALPHA;
    DestBlend = INV_SRC_ALPHA;
    BlendOp = ADD;
    SrcBlendAlpha = ZERO;
    DestBlendAlpha = ZERO;
    BlendOpAlpha = ADD;
    RenderTargetWriteMask[0] = 0x0F;
};

both passes currently use this depthstencilstate:

DepthStencilState Depth {
  // Depth test parameters
  DepthEnable = true;
  DepthWriteMask = all;
  DepthFunc = less;
  StencilEnable = false;
};

Cullmode is set to NONE for both passes.

Is there a way for both passes to use depthtest, without the first pass occluding the second?

If need be I can separate these passes into two shaders and just render the same object with both shaders in engine, but I would like to figure out if it's possible just using multiple passes.

kiamvdd
  • 31
  • 3
  • You could switch the drawing order, so the opaque pass would be drawn before the transparent pass. As depth testing don't work well in conjunction with semi-transparent objects you normally split the scene into two steps. First drawing all opaque objects with depth writing and testing. Then all transparent objects sorted from back to front with depth testing, but not writing. So no objects are clipped from transparent depth pixels and the transparent objects are overlapping properly. – Gnietschow May 27 '17 at 20:38
  • @Gnietschow swapping the order makes the second pass completely disappear somehow. Even when I alter its position so it wouldn't be culled by the first pass, it's just not visible at all. – kiamvdd May 28 '17 at 10:33

0 Answers0