Handkor
05-31-2004, 07:25 AM
I am trying to read from multiple textures but as soon as I read from one texture all the reads from the others will give values from the first.
Fragment Shader example
uniform sampler2D TNormals;
uniform sampler2D TColors;
uniform sampler2D TMasks;
varying vec2 v_texCoord;
void main( void )
{
vec4 c = vec4(0.0,0.0,0.0,0.0);
if(v_pos.x > 0.5 && v_pos.y > 0.5)
c=texture2D( TColors, v_texCoord );
if(v_pos.x < 0.5 && v_pos.y < 0.5)
c=texture2D( TNormals, v_texCoord );
if(v_pos.x > 0.5 && v_pos.y < 0.5)
c=texture2D( TMasks, v_texCoord );
if(v_pos.x < 0.5 && v_pos.y > 0.5)
c=vec4(1.0,0.0,0.0,0.0);
gl_FragColor = c;
}
This code should paints my cube with a different texture for each quadrant and one red quadrant. (using flat colors, each quadrant is different)
Instead I get a red quadrant and the rest is all the same texture.
If I change the order of the textures, the displayed texture will change but I will only see one texture at a time.
How can I see all my textures?
Fragment Shader example
uniform sampler2D TNormals;
uniform sampler2D TColors;
uniform sampler2D TMasks;
varying vec2 v_texCoord;
void main( void )
{
vec4 c = vec4(0.0,0.0,0.0,0.0);
if(v_pos.x > 0.5 && v_pos.y > 0.5)
c=texture2D( TColors, v_texCoord );
if(v_pos.x < 0.5 && v_pos.y < 0.5)
c=texture2D( TNormals, v_texCoord );
if(v_pos.x > 0.5 && v_pos.y < 0.5)
c=texture2D( TMasks, v_texCoord );
if(v_pos.x < 0.5 && v_pos.y > 0.5)
c=vec4(1.0,0.0,0.0,0.0);
gl_FragColor = c;
}
This code should paints my cube with a different texture for each quadrant and one red quadrant. (using flat colors, each quadrant is different)
Instead I get a red quadrant and the rest is all the same texture.
If I change the order of the textures, the displayed texture will change but I will only see one texture at a time.
How can I see all my textures?