PDA

View Full Version : sampler object not work with compare mode



notwork
04-04-2012, 05:39 AM
hi all, my first blood.
i'm using sampler objs to replace texture params, but found it not work specially with compare mode.
snippet is truncated from glIntercept log


glUseProgram(10)
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_2D,5)
glBindSampler(0,11)
glActiveTexture(GL_TEXTURE1)
glBindTexture(GL_TEXTURE_2D,9)
glBindSampler(1,10)
... other uniforms
glDrawArrays(GL_POINTS,0,1) GLSL=10 Textures[ (0,5) (1,9) ]



uniform sampler2DShadow samp_Shadow;
...
//add offset along pixel to lit
const float offset=0.2f;
vec3 newPos=pos+toLight*offset;
vec4 proj=uni_ViewToLightProj*vec4(newPos,1.f);
proj+=vec4(proj.w);
gl_FragData[0].x=textureProj(samp_Shadow,proj).x;


using this to draw a sphere, fbo outputs a image with depth value, rather than cmp result.
works fine if i replace the glSamplerParam* calls with glTexParam*.

wrong form: check fbo_output, the rectangle is view frustum far plane, and light is casting on the upper sphere.

correct form: check what_i_want.

PS: i was facing this prob using ati hd5650 and catalyst 12.1, prob hold after 12.3 is installed.

any idea & reply would be appreciated.

edit:
i think i'm not depicting the question properly,
the problem i'm facing is that,
feeding textureProj with sampler2DShadow ,
texture of format GL_DEPTH_COMPONENT32F,
setting sampler params like this:


glSamplerParameteri(handle,GL_TEXTURE_WRAP_S,GL_CL AMP_TO_BORDER);
glSamplerParameteri(handle,GL_TEXTURE_WRAP_T,GL_CL AMP_TO_BORDER);
glSamplerParameterfv(handle,GL_TEXTURE_BORDER_COLO R,&Color::RGBA(0)[0]);
glSamplerParameteri(handle,GL_TEXTURE_MIN_FILTER,G L_NEAREST);
glSamplerParameteri(handle,GL_TEXTURE_MAG_FILTER,G L_NEAREST);
glSamplerParameteri(handle,GL_TEXTURE_COMPARE_MODE ,GL_COMPARE_REF_TO_TEXTURE);
glSamplerParameteri(handle,GL_TEXTURE_COMPARE_FUNC ,GL_LESS);


textureProj should return compared result (1.f or 0), but it obviously not, that it return raw depth value

notwork
04-04-2012, 08:28 AM
got smthing strange:


glActiveTexture(GL_TEXTURE0+texUnit);
glBindTexture(GL_TEXTURE_2D,texHandle);
glBindSampler(texUnit, handle);
int32 param;
glGetIntegerv(GL_SAMPLER_BINDING, &param);

param will always get 0x0, guess its a driver bug