Rendering transparent objects in OpenGL

前端 未结 2 1812
南笙
南笙 2021-01-03 11:38

Iam trying to render some 3d objects using opengl. Requirement is that i need to hide all the transparent objects which are z-behind another transparent object. All the tria

2条回答
  •  滥情空心
    2021-01-03 12:12

    Try using glDepthMask():

        //Render all opaque objects
        glDepthMask(false); //disable z-testing
        //Render all transparent objects*
        glDepthMask(true); //enable z-testing (for the next frame)
    

    *Technically, you should render the transparent objects from back to front, but it is rarely noticeable if you don't.

提交回复
热议问题