cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

gpeterpan
Journeyman III

Problems with sampler2dShadow

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?

0 Likes
13 Replies
frali
Staff

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

0 Likes

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.

0 Likes

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

0 Likes

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

 

0 Likes

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.

0 Likes

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. 

0 Likes

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.

 

0 Likes

It depends on the depth texture setting. The depth texture mode is set to GL_LUMINANCE by default, according to the GL spec, the texel value is (Lt, Lt, Lt, 1) for GL_LUMINANCE, Lt is the comparison result.

In your case, the value of shadow2DProj(shadowMap, posSample).w is always 1 if you don't specify the depth texture mode. As a result, shadowMap is optimized out by the compiler, so you can't get the valid uniform location.

I think you could get what you want by modifying the shader.

0 Likes

Maybe you´re right. I'm proving now. I will tell you my results.

 

Thank you very much for your help and for your time.

0 Likes

Ok.

I have proved your option:

if (shadow2DProj(shadowMap, posSample).x != 1.)

And it is ok. Great.

Thanks a lot for your help.

0 Likes

hello guys.

0 Likes

Hello everyone.

0 Likes

sample2dshadow is now working good, after discussing here. 

Acai Berry

0 Likes