]> git.tdb.fi Git - libs/gl.git/commitdiff
Add a separate constant to enable clipping in standard shaders
authorMikko Rasa <tdb@tdb.fi>
Wed, 7 Apr 2021 23:00:51 +0000 (02:00 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 7 Apr 2021 23:02:04 +0000 (02:02 +0300)
Declaring an array with zero size is not allowed, so using zero for
max_clip_planes doesn't work.

shaderlib/common.glsl
shaderlib/msp_interface.glsl

index f952c8bd6c1cb34c647d869011ea51fd61d1ff29..849d97c9cef6d418024aff4604708ba2aa3141c9 100644 (file)
@@ -54,8 +54,11 @@ void standard_transform()
        out vec3 tbn_zenith_dir = eye_zenith_dir*eye_tbn_matrix;
        out float fog_coord = eye_vertex.z;
 
-       for(int i=0; i<max_clip_planes; ++i)
-               gl_ClipDistance[i] = dot(eye_vertex, clip_planes[i].equation);
+       if(use_clipping)
+       {
+               for(int i=0; i<max_clip_planes; ++i)
+                       gl_ClipDistance[i] = dot(eye_vertex, clip_planes[i].equation);
+       }
 
        shadow_transform(eye_vertex);
 }
index 2458b97d6b2d08e36de81c6e3f2397b32c930aa8..b86d09bb32e4a5cdc3d49423f5336cf9d896cae1 100644 (file)
@@ -30,7 +30,8 @@ uniform Lighting
        float fog_density;
 };
 
-layout(constant_id=auto) const int max_clip_planes = 0;
+layout(constant_id=auto) const bool use_clipping = false;
+layout(constant_id=auto) const int max_clip_planes = 8;
 uniform Clipping
 {
        ClipPlane clip_planes[max_clip_planes];