Difference between revisions of "Geometry Shader/Defined Outputs Layered"

From OpenGL Wiki
Jump to: navigation, search
(separate page for built-in outputs.)
 
 
Line 3: Line 3:
 
<source lang="glsl">
 
<source lang="glsl">
 
out int gl_Layer;
 
out int gl_Layer;
out int gl_ViewportIndex; //Requires GL 4.1 or ARB_viewport_array.
+
out int gl_ViewportIndex; // Requires GL 4.1 or ARB_viewport_array.
 
</source>
 
</source>
  

Latest revision as of 14:00, 3 January 2018

Layered rendering in the GS works via two special output variables:

out int gl_Layer;
out int gl_ViewportIndex; // Requires GL 4.1 or ARB_viewport_array.

The gl_Layer output defines which layer in the layered image the primitive goes to. Each vertex in the primitive must get the same layer index. Note that when rendering to cubemap arrays, the gl_Layer value represents layer-faces (the faces within a layer), not the layers of cubemaps.

gl_ViewportIndex, which requires GL 4.1 or ARB_viewport_array, specifies which viewport index to use with this primitive.

Note: ARB_viewport_array, while technically a 4.1 feature, is widely available on 3.3 hardware, from both NVIDIA and AMD.