Difference between revisions of "Shader/Defined Uniforms"

From OpenGL Wiki
Jump to: navigation, search
m (Alfonse moved page Fragment Shader/Defined Uniforms to Shader/Defined Uniforms: These are not limited to fragment shaders.)
(Clarified where gl_DepthRange comes from.)
Line 1: Line 1:
{{pagelink|Fragment Shader}}s define the following uniforms.
+
{{pagelink|Shader}}s define the following uniforms.
  
 
<source lang="glsl">
 
<source lang="glsl">
Line 13: Line 13:
 
</source>
 
</source>
  
This struct provides access to the {{apifunc|glDepthRange}} near and far values. The {{code|diff}} value is the {{code|far}} value minus the {{code|near}} value. Do recall that OpenGL makes no requirement that {{code|far}} is greater than {{code|near}}.
+
This struct provides access to the {{apifunc|glDepthRange}} near and far values. The {{code|diff}} value is the {{code|far}} value minus the {{code|near}} value. Do recall that OpenGL makes no requirement that {{code|far}} is greater than {{code|near}}. With regard to multiple [[Viewport]]s, {{code|gl_DepthRange}} only stores the range for viewport 0.
  
 
{{code|gl_NumSamples}} is the number of samples in the current [[Framebuffer]]. If the framebuffer is not multisampled, then this value will be 1.
 
{{code|gl_NumSamples}} is the number of samples in the current [[Framebuffer]]. If the framebuffer is not multisampled, then this value will be 1.

Revision as of 16:13, 3 May 2015

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.