2

I want to render concealed objects and achieve a similar effect as the one shown in the link in Stage3D.

Silhouette Effect in Torchlight 2

I already know how to do this theoretically. I have to draw the object twice:

  • Once with normal settings and
  • once with a different depth sorting mode where only pixels that are behind rendered geometry are shown. Also, to prevent weird effects later on, these pixels can't be rendered into the depth buffer.

I can set the correct depth sorting mode in Stage3D with Context3DCompareMode.GREATER. Is it also possible to have Stage3D render pixels into the back buffer, but not the z buffer?

If I can't keep Stage3D from rendering to the depth buffer, the effect will look like this:

Glitchy Silhoutte Effect

Max Did It
  • 23
  • 2

2 Answers2

0

Yes, you can turn off depth and stencil buffer. Check context3d.configureBackBuffer method.

nikitablack
  • 4,359
  • 2
  • 35
  • 68
0

If anyone comes across this, there are two things you should be aware of:

1) As Volgogradetzzz make sure you have a stencil/depth buffer as part of your backbuffer using Context3D.configureBackBuffer(...)

2) If you need to turn on or off depth pixel writing at different moments you can use set the depthMask argument in this function:

public function setDepthTest(depthMask:Boolean, passCompareMode:String):void

A little strange to find this feature in a function of this name, as depth write masking affects the results, not the test itself.

Jarrod Moldrich
  • 405
  • 5
  • 6