KhronosGroup / glTF-Sample-Viewer

Physically-Based Rendering in glTF 2.0 using WebGL
Apache License 2.0
1.21k stars 229 forks source link

Support clipping planes #517

Open lexaknyazev opened 5 months ago

lexaknyazev commented 5 months ago

Custom clipping planes could be used for more convenient model inspection.

This feature would consist of:

Rendering implementation would require a relatively simple vertex shader update:

gl_ClipDistance[0] = dot(position, planeXPos);
gl_ClipDistance[1] = dot(position, planeXNeg);
gl_ClipDistance[2] = dot(position, planeYPos);
gl_ClipDistance[3] = dot(position, planeYNeg);
gl_ClipDistance[4] = dot(position, planeZPos);
gl_ClipDistance[5] = dot(position, planeZNeg);

where position is a vertex position in the world (or view) space and each plane* is a vector with plane equation coefficients in the same space.

The feature would require support for the WEBGL_clip_cull_distance extension.