actionscript-3fragment-shaderstage3dagal

Get current buffer depth in fragment shader in agal


Is it possible in AGAL in fragment shader get current fragment depth if any?


Solution

  • No, I'm afraid there is no way to read from the depth buffer in AGAL.

    You can however do a workaround by rendering a depthmap first into a texture, and then using it (which may be enought, depending on the effect you are trying to implement).

    In fact, even rendering a depth map with good precision can be (a little) tricky, because there are no float32 textures in flash, so the depth as to be stored in a R8G8B8A8 texture (by packing and unpackings values on the GPU).