Support Forum       G3D Web Page     
Public Member Functions | Public Attributes | List of all members
glsl::clip_glsl Class Reference


SIMD optimized code to clip a triangle or quadrilateral against a plane in GLSL. More...

Public Member Functions

int clip3 (const in vec3 n, in out vec3 v0, in out vec3 v1, in out vec3 v2, out vec3 v3)
 
Computes the intersection of triangle v0-v1-v2 with the half-space (x,y,z) * n > 0. More...
 
int clip4 (const in vec3 n, in out vec3 v0, in out vec3 v1, in out vec3 v2, in out vec3 v3, out vec3 v4)
 
Computes the intersection of quadrilateral v0-v1-v2-v3 with the half-space (x,y,z)*n > 0. More...
 

Public Attributes

const float clipEpsilon = 0.00001
 
const float clipEpsilon2 = 0.01
 

Detailed Description


SIMD optimized code to clip a triangle or quadrilateral against a plane in GLSL.

Design goals are to:

  1. maximize coherence (to keep all threads in a warp active for scalar ALUs) by quickly reducing to a small set of common cases,
  2. maximize vector instructions (for vector ALUs)
  1. minimize peak register count (to enable a large number of simultaneous threads), and
  2. avoid non-constant array indexing (which expands to a huge set of branches on many GPUs)

Member Function Documentation

◆ clip3()

int glsl::clip_glsl::clip3 ( const in vec3  n,
in out vec3  v0,
in out vec3  v1,
in out vec3  v2,
out vec3  v3 
)
inline


Computes the intersection of triangle v0-v1-v2 with the half-space (x,y,z) * n > 0.

The result is a convex polygon in v0-v1-v2-v3. Vertex v3 may be degenerate and equal to the first vertex.

Returns
number of vertices; 0, 3, or 4

◆ clip4()

int glsl::clip_glsl::clip4 ( const in vec3  n,
in out vec3  v0,
in out vec3  v1,
in out vec3  v2,
in out vec3  v3,
out vec3  v4 
)
inline


Computes the intersection of quadrilateral v0-v1-v2-v3 with the half-space (x,y,z)*n > 0.

If there is no intersection, returns 0. If there is an intersection, returns the number of unique vertices, k. Vertex [(k+1) % 5] is always equal to v0.

Returns
number of vertices; 0, 3, 4, or 5

Member Data Documentation

◆ clipEpsilon

const float glsl::clip_glsl::clipEpsilon = 0.00001

◆ clipEpsilon2

const float glsl::clip_glsl::clipEpsilon2 = 0.01

documentation generated on Wed Nov 24 2021 08:02:03 using doxygen 1.8.15