cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

jbizcocho
Adept I

OpenGL texture3D sample3D problem

Hello guys,

Right now i'm preparing a shader that contains glow, bloom and FXAA on a single pass. The problem is that i'm using one sample3D for a texture lookup in the glow part. and I don't know why, when I try to validate the shader it appears the error:

"Validation Error!, Different sampler types for same sample texture unit in fragment shader". here is a summary of the problematic part of the code:

#version 130

#extension GL_EXT_gpu_shader4 : enable

precision mediump float;

uniform vec2            vInvViewport;

uniform float            fGlowMultiplier;

uniform int                iDebug;

uniform sampler3D sourceLUT;

uniform sampler2D sourceTex;

uniform sampler2D sourceBloom;

uniform sampler2D sourceBlurData;

void main()

{

    vec3 vColor;

    if( iDebug == 0 )

    {

        vColor = FxaaPixelShader( gl_TexCoord[0].xy, sourceTex, vInvViewport );

    }

    else

    {

        vColor = texture2D( sourceTex, gl_TexCoord[0].xy ).rgb;

    }

    vec3 vBloom = texture2D( sourceBloom, gl_TexCoord[0].xy ).rgb;

    vColor += fGlowMultiplier * vBloom;

    vec4  vBlak = texture3D( sourceLUT, vColor.xyz ).xyzw;

    float  fBlik    = texture2D( sourceBlurData, gl_TexCoord[0].xy ).x;

    gl_FragColor = vec4( vBlak.xyz, fBlik );

}

If I comment the line 33, it works perfectly. So I dont know If I'm not using the function / variables in the proper way, or maybe its a driver confilct.

Does anyone have dealed with this issue before? .

My configuration is: Ubuntu 12.04, latest catalyst and ATI HD6870. I'm forcing the app to use OpenGL 2.1 with extensions when its possible to apply ^_^.

Thanks in advance people! .

0 Likes
1 Solution
gsellers
Staff

Hi,

Without seeing the application-side code that's driving the shader, my first guess would be that at the time that you validate the program, you have not set the sampler uniforms and thus they all refer to texture unit 0. Now you have a sampler3D and a sampler2D uniform referring to the same texture unit, which isn't really supported. When you comment line 33, the sourceLUT uniform is no longer referenced by the program and is optimized away, eliminating the issue.

Try setting the uniforms to different values using glUniform1i(location, unit) before calling glValidateProgram.

Thanks,

Graham

View solution in original post

0 Likes
4 Replies
gsellers
Staff

Hi,

Without seeing the application-side code that's driving the shader, my first guess would be that at the time that you validate the program, you have not set the sampler uniforms and thus they all refer to texture unit 0. Now you have a sampler3D and a sampler2D uniform referring to the same texture unit, which isn't really supported. When you comment line 33, the sourceLUT uniform is no longer referenced by the program and is optimized away, eliminating the issue.

Try setting the uniforms to different values using glUniform1i(location, unit) before calling glValidateProgram.

Thanks,

Graham

0 Likes

Thanks for your reply Graham,

I'm going to try that, but now that you mentioned it, from my experience you usually load, compile, link and validate before uniform assignation isn't it?. I'll tell you later if that fix the problem.

Thanks in advance!

Hi,

Almost... glValidateProgram takes into consideration the current OpenGL state, including what's bound where and current value of uniforms.

Thanks,

Graham

Hi again!,

You were right!, if you set the texunit uniforms before validation there is no problem!.

Thank you very much!.

=).!!!

0 Likes