Difference between revisions of "Shader/Defined Uniforms"

From OpenGL Wiki
Jump to: navigation, search
(Clarified where gl_DepthRange comes from.)
 
Line 10: Line 10:
 
uniform gl_DepthRangeParameters gl_DepthRange;
 
uniform gl_DepthRangeParameters gl_DepthRange;
  
uniform int gl_NumSamples; //GLSL 4.20
+
uniform int gl_NumSamples; // GLSL 4.20
 
</source>
 
</source>
  

Latest revision as of 14:00, 3 January 2018

Shaders define the following uniforms.

struct gl_DepthRangeParameters
{
    float near;
    float far;
    float diff;
};
uniform gl_DepthRangeParameters gl_DepthRange;

uniform int gl_NumSamples; // GLSL 4.20

This struct provides access to the glDepthRange near and far values. The diff value is the far value minus the near value. Do recall that OpenGL makes no requirement that far is greater than near. With regard to multiple Viewports, gl_DepthRange only stores the range for viewport 0.

gl_NumSamples is the number of samples in the current Framebuffer. If the framebuffer is not multisampled, then this value will be 1.