gl_CullDistance

From OpenGL Reference
Jump to navigation Jump to search

Provides a mechanism for controlling user culling.

Declaration[edit]

Description[edit]

Thegl_CullDistancevariable provides a mechanism for controlling user culling. The element gl_CullDistance [i] specifies a cull distance for each planei. A distance of 0.0 means that the vertex is on the plane, a positive distance means that the vertex is inside the cull volume, and a negative distance means that the point is outside the cull volume. Primitives whose vertices all have a negative clip distance for planeiwill be discarded.

Thegl_CullDistancearray is predeclared as unsized and must be sized by the shader either by redeclaring it with an size or by indexing it only with integral constant expressions. The size determines the number and set of enabled cull distances and can be at mostgl_MaxCullDistances. The number of varying components consumed bygl_CullDistancewill match the size of the array. Shaders writinggl_CullDistancemust write all enabled distances, or culling results are undefined.

As an output variable,gl_CullDistanceprovides the place for the shader to write these distances. As an input in all but the fragment language, it reads the values written in the previous shader stage. In the fragment language, thegl_CullDistancearray contains linearly interpolated values for the vertex values written by a shader to thegl_CullDistancevertex output variable.

It is a compile-time or link-time error for the set of shaders forming a program to have the sum of the sizes of thegl_ClipDistanceandgl_CullDistancearrays to be larger thangl_MaxCombinedClipAndCullDistances.


Version Support[edit]

gl_CullDistance 4.5+

See Also[edit]

 gl_ClipDistance , gl_PointSize 


Copyright[edit]

Copyright© 2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.