简体   繁体   中英

How to get previous value in depth buffer?

How I can to do the next algorithm? :

if(Color.a < 0.9)
    gl_FragDepth = gl_PrevFragDepth;
else
    gl_FragDepth = gl_FragCoord.z;

This I can make with glDepthMask(false); , but it's working with polygons which have all pixels with alpha < 1 . If polygons have pixels with alpha = 1 and alpha < 1 I have incorrect rendered picture. I need this to rendering text masks, which contains any alpha values!

I can't use depth texture because I need to real-time working with depth buffer!

How I can to do the next algorithm? :

In OpenGL-4 you could do it using depth texture writes in the fragment shader. But the performance will be horrible, because GPUs are optimized for gather access, not scatter access, which however is what you're trying to do.

With OpenGL-3 and below you can't do it. Sorry.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM