GLSL troubles

Hello people,

I´m trying to figure out why this code is working:

uniform sampler3D volumeTex;
uniform sampler2D lookupTex;

void main()
{
vec4 color = texture3D(volumeTex, gl_TexCoord[0].stp);
vec4 outputColor = texture2D(lookupTex, vec2(0.1, 0.5));
gl_FragColor = outputColor;
}

and this is not:

uniform sampler3D volumeTex;
uniform sampler2D lookupTex;
void main()
{
vec4 color = texture3D(volumeTex, gl_TexCoord[0].stp);
vec4 outputColor = texture2D(lookupTex, color.rg);
gl_FragColor = outputColor;
}

First example of course shows to me a uniform color, but second simply shows nothing, like color is always 0, which is not the case (I tried to visualize it). Could someone help me, please ? thanks. I´m using Linux, nVidia GeForce 6600, 256 Mb, driver is 76.67

nuts, looks like nVidia driver GLSL compiler has a bug, because in CG everything works just fine :-/

I don’t have an NV card to try this out on, but the shader works on the hardware I’m using. I did notice a couple of things in your shader that could be improved, you are using gl_TexCoord[0] yet are only using three components. It may be better to specify a vec3 varying in your vertex shader instead of using a vec4 and only ever touching 3 components of it. The same logic would apply to your vec4 color that you set in the fragment shader. Why not declare this as a vec2 since you’re only using the red and green components? Try this and see if it works, both versions gave me the same output (the second shader you’d posted as well as the one I’ve posted below) using a 3Dlabs Wildcat Realizm 100 card.

uniform sampler3D volumeTex;
uniform sampler 2D lookupTex;
varying vec3 textureCoord;
void main()
{
    vec2 color = texture3D(volumeTex, textureCoord).rg;
    vec4 outputColor = texture2D(lookupTex, color);
    gl_FragColor = outputColor;
}  

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.