7 Replies Latest reply on Oct 14, 2018 9:59 PM by xhuang

    Help needed working out why a uniform is not active when used to set gl_ClipDistance

    dgholz

      Hello,

       

      I'm using a Radeon RX 580 with version 18.9.3 of the drivers from AMD. I have a small shader that has some uniforms that do not get assigned a location, and I need help working out why they aren't/how to get them assigned to a location.

       

      The vertex shader looks like this:

      #version 430

      in vec4 inVertex;

      //out gl_PerVertex { vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[2]; };

      out float gl_ClipDistance[2];

      uniform mat4 u_ModelView;

      uniform mat4 u_Projection;

      uniform vec4 u_plane0;

      uniform vec4 u_plane1 = vec4(0,-1,0,0);

       

      void main(){

          vec4 vsPos = u_ModelView * inVertex;

          gl_Position = u_Projection * vsPos;

       

          gl_ClipDistance[0] = dot(u_plane0, vsPos);

          gl_ClipDistance[1] = dot(u_plane1, vsPos);

      }

       

      I enable the clip planes before creating the shader like this:

      for (int i = 0; i < 2; i++) {

          glEnable(GL_CLIP_DISTANCE0 + i);

      }

       

      The shader compiles without error, but when I call glGetUniformLocation(hShader, "u_plane0") I get -1 back (same for u_plane1). I don't understand exactly why the uniforms are not considered to be active, as gl_ClipDistance can definitely affect the rendered output. The commented-out gl_PerVertex line was me checking that I explicitly declared the size of gl_ClipDistance correctly (it doesn't affect the behaviour regardless of how I declare gl_ClipDistance, explicit or implicit).

       

      When I roll back the drivers to before 18.7.1, the uniforms are assigned a location. Also if I leave the drivers at 18.9.3 and change the version to '#version 330'.

       

      Can someone point me in the right direction to work out why these uniforms aren't assigned a location?