Issue with transparent texture on 3D primitive, XNA 4.0

后端 未结 4 874
礼貌的吻别
礼貌的吻别 2021-01-01 05:50

I need to draw a large set of cubes, all with (possibly) unique textures on each side. Some of the textures also have parts of transparency. The cubes that are behind ones w

4条回答
  •  隐瞒了意图╮
    2021-01-01 06:08

    You are relying on depth buffering to achieve occlusion. This technique only works for opaque objects.

    To achieve correct occlusion for a scene containing transparent objects:

    1. Set DepthBufferEnable and DepthBufferWriteEnable to true

    2. Draw all opaque geometry

    3. Leave DepthBufferEnable set to true, but change DepthBufferWriteEnable to false

    4. Sort alpha blended objects by distance from the camera, then draw them in order from back to front

    Extract from Depth sorting alpha blended objects by Shawn Hargreaves

提交回复
热议问题