13 Replies Latest reply on May 27, 2011 9:00 AM by simonwood1

    Problems with sampler2dShadow

    gpeterpan

      Hi!

      I have a frament shader in GLSL language and when I use getUniformLocation with a variable then the function returns -1.

       

      In fragment shader:

      uniform sampler2DShadow shadowVar;

       

      In C code:

      idVariable = getUniformLocation(shader, "shadowVar");

      idVariable is asigned -1.

       

      I get this problem with ATI HD 5670 cards only.

      Can anyone help me,please?

        • Problems with sampler2dShadow
          frali

          The driver will return a valid uniform location only if this uniform variable is active in the shader.

            • Problems with sampler2dShadow
              gpeterpan

              Hi!

              First, thank you for your answer. But I've found the problem.

              You was right. The problem was that the variable was desactived. However, the main problem was I have used sample2DShadow function. I think HD 5600 serie ATI doesn´t implement the sample2DShadow because this function is deprecated. Now, I´m using textureProj and I don´t have any problem.

              I don´t know why the GPU compiler doesn´t show any warning about the deprecated functions. Then, I could know where the problem is.

               

              Thank you, for your interesting.

                • Problems with sampler2dShadow
                  frali

                  Do you mean there is a problem when you use shadow2DProj, but it works when you use textureProj with the sampler type - sampler2DShadow? The GPU compiler supports both functions for compatibility. Could you please show me where the problem is by pasting out your shader?

                  Thanks

                    • Problems with sampler2dShadow
                      gpeterpan

                      Hi!

                      I explain me better. If I have a uniform variable as this:

                      uniform sampler2D shadow;

                      and I use this varible using shadow2dProj, then getUniformLocation(shader, "shadow") function will return -1. But If I use textureProj then getUniformLocation function will return a correct id value.

                      I don´t know if this is an error ati drivers or if ati drivers don´t implement shadow2dProj. I've tried this problem with ATI RADEON HD 5670.

                      I hope my explication is better

                       

                        • Problems with sampler2dShadow
                          frali

                          It seems impossible. It's wrong to get the uniform location from the shader object by getUniformLocation(shader, "shadow"). We'd better get it by getUniformLocation(program, "shadow"). Is it a possible root cause? Anyway, we will verify it first. I appreciate that you tell me which catalyst driver you are using now.

                          • Problems with sampler2dShadow
                            frali

                            I can't reproduce the problem on HD5670 for the following two cases.

                            uniform sampler2DShadow shadow;
                            uniform vec4 coord;
                            gl_FragColor = shadow2DProj(shadow, coord);
                            or
                            gl_FragColor = textureProj(shadow, coord).xxxx;

                            Please note that shadow2DProj returns vec4 while textureProj returns float. 

                              • Problems with sampler2dShadow
                                gpeterpan

                                I have the catalyst last version. Well, I have the call function into a function. This is exactly my function:

                                float lookup(

                                              in sampler2DShadow shadowMap,

                                              in vec4 shadowCoord,

                                              in float dx, int float dy,

                                              in float ratioToPixelX, in float ratioToPixelY)

                                {

                                        float shadowFactor;

                                        bool isShadow;

                                        vec4 posSample;

                                 

                                        posSample = shadowCoord +

                                                                    vec4(dx * ratioPixelX * shadowCoord.w,

                                                                             dy * rationPixelY * shadowCoord.w,

                                                                             0., 0.);

                                      //if (textureProj(shadowMap, posSample) != 1) // Is ok,

                                      if (shadow2DProj(shadowMap, posSample).w != 1.)   //Is bad.

                                            shadowFactor = 1.;

                                     else

                                            shadowFactor = 0.;

                                 

                                     return shadowFactor;

                                }

                                If you want, you will be able to put all your code and so I could probe your version in my computer. So We could know if your program run ok in my computer.