WEBGL_clip_cull_distance
WebGL working group (public_webgl 'at' khronos.org)
Members of the WebGL working group
Kevin Rogovin (kevinrogovin 'at' invisionapp.com)
Last modified date: September 07, 2023
Revision: 5
WebGL extension #43
Written against the WebGL API 2.0 specification.
This extension exposes the EXT_clip_cull_distance functionality to WebGL.
The following WebGL-specific behavioral changes apply:
#extension GL_ANGLE_clip_cull_distance
directive, as shown in the sample code, to use the built-ins in shaders.
Likewise the shading language preprocessor #define GL_ANGLE_clip_cull_distance,
will be defined to 1 if the extension is supported.
Consult the above extension for documentation, issues and new functions and enumerants.
When this extension is enabled:
Clip and cull distance built-ins are supported in ESSL 3.00 shaders.
If the platform does not support cull distances:
MAX_CULL_DISTANCES_WEBGL and
MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL
must return zero.
gl_MaxCullDistances and
gl_MaxCombinedClipAndCullDistances are defined as zero.
gl_CullDistance built-in must not be redeclared and
may only be used conditionally, see the sample code below.
GL_ANGLE_clip_cull_distance with an #extension directive:highp float gl_ClipDistance[] is a built-in input.
highp float gl_CullDistance[] is a built-in input.
highp float gl_ClipDistance[] is a built-in output.
highp float gl_CullDistance[] is a built-in output.
GL_ANGLE_clip_cull_distance
is defined as 1.
[Exposed=(Window,Worker), LegacyNoInterfaceObject]
interface WEBGL_clip_cull_distance {
const GLenum MAX_CLIP_DISTANCES_WEBGL = 0x0D32;
const GLenum MAX_CULL_DISTANCES_WEBGL = 0x82F9;
const GLenum MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL = 0x82FA;
const GLenum CLIP_DISTANCE0_WEBGL = 0x3000;
const GLenum CLIP_DISTANCE1_WEBGL = 0x3001;
const GLenum CLIP_DISTANCE2_WEBGL = 0x3002;
const GLenum CLIP_DISTANCE3_WEBGL = 0x3003;
const GLenum CLIP_DISTANCE4_WEBGL = 0x3004;
const GLenum CLIP_DISTANCE5_WEBGL = 0x3005;
const GLenum CLIP_DISTANCE6_WEBGL = 0x3006;
const GLenum CLIP_DISTANCE7_WEBGL = 0x3007;
};
#extension GL_ANGLE_clip_cull_distance : enable
void main() {
// Compute the clip distances for the current vertex
gl_ClipDistance[0] = ...;
gl_ClipDistance[1] = ...;
// For better portability, check if cull distances are supported.
// This should compile even when the platform does not support cull distances.
if (gl_MaxCullDistances > 0) {
gl_CullDistance[0] = ...;
gl_CullDistance[1] = ...;
}
}
Revision 1, 2016/08/22
Revision 2, 2019/09/25
Revision 3, 2020/07/01
Revision 4, 2022/12/01
Revision 5, 2023/09/07