GLSL header to force Early-Z
Posted: Sat May 27, 2017 8:05 am
You put this after your "#version 400" or other declaration at the very top of the fragment shader
if you're tagetting lower than GL 4.0, (same rule about positioning at the top of the file and just after version).
Code: Select all
#extension GL_ARB_conservative_depth: require
#if __VERSION__>=420
layout(early_fragment_tests) in;
#else
#extension GL_ARB_shader_image_load_store: enable
#ifdef GL_ARB_shader_image_load_store
layout(early_fragment_tests) in;
#else
#extension GL_EXT_shader_image_load_store: enable
#ifdef GL_EXT_shader_image_load_store
layout(early_fragment_tests) in;
#else
layout (depth_unchanged) out float gl_FragDepth;
#endif // GL_EXT_shader_image_load_store
#endif // GL_ARB_shader_image_load_store
#endif // __VERSION__
Code: Select all
#if __VERSION__>=420
layout(early_fragment_tests) in;
#else
#extension GL_ARB_shader_image_load_store: enable
#ifdef GL_ARB_shader_image_load_store
layout(early_fragment_tests) in;
#else
#extension GL_EXT_shader_image_load_store: enable
#ifdef GL_EXT_shader_image_load_store
layout(early_fragment_tests) in;
#else
#extension GL_ARB_conservative_depth: enable
#ifdef GL_ARB_conservative_depth
layout (depth_unchanged) out float gl_FragDepth;
#endif // GL_ARB_conservative_depth
#endif // GL_EXT_shader_image_load_store
#endif // GL_ARB_shader_image_load_store
#endif // __VERSION__