c++ - Write gl_FragDepth while still executing depth pre-test -


given depth-prepass renderer, have minimum depth values given fragment can possibly contain- thus, makes no sense consider fragments farther denoted.

now, have shader writes gl_fragdepth, guaranteed write value greater or equal depth value of polygonal face. how can still execute depth-pretest (ie, if fragment depth farther buffer value, discard without shader execution), allows me write value different (greater) interpolated face depth if passes pre-test?

starting opengl 4.2 (glsl 4.20), functionality you're looking available layout qualifier on gl_fragdepth. allows specify intent on how going modify depth output in fragment shader. example, following specifies going change depth value make in greater:

layout (depth_greater) out float gl_fragdepth; 

this allow depth test still used when depth modified in fragment shader. if not follow "contract" establish qualifier, undefined behavior. example, qualifier above, if make depth smaller, fragments otherwise visible may eliminated.

the functionality based on gl_amd_conservative_depth , gl_arb_conservative_depth extensions. if want use opengl versions lower 4.2, check presence of these extension, , use in 1 of extension forms if it's available.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -