Sign in to follow this  

GLSL double texture lookup problem...

This topic is 2844 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, Im trying to create a n1*m1 texture containing colors representing textcoord in a second texture n2*m2: For this I wrote a simple fragment shader: <code> uniform sampler2DRect colortexture; uniform sampler2DRect indexTexture; uniform vec2 sizecolortexture; void main(){ //1st texture lookup retrieving color representing 2D tex coord in RG vec4 inputVal = texture2DRect(indexTexture, gl_TexCoord[0].st); //scale texcoord to texture size inputVal.x*=sizecolortexture.x; inputVal.y*=sizecolortexture.y; vec4 col= texture2DRect(colortexture, inputVal.xy); gl_FragColor=col; } </code> But it doesnt work...:( I don't seem to make any errors in the code as i can display the two textures separatly. I's like that texture lookup on texcoord resulting from an other texlookup is not working?I dont know well glsl spec but it seems like all textures lookups are vectorized independently at compilation...?! Any idea or info about that? Thanks by advance [Edited by - mp3butcher on March 1, 2010 4:29:19 PM]

Share this post


Link to post
Share on other sites
Yeah it works..the shader outputs me whatever i want: the 1st texture the 2nd texture too... but not the double indirection result i wanna render....:(
I will give a try with square textures (texture2d) as you mentionned but im afraid it will be the same problem:(

Share this post


Link to post
Share on other sites
Can you post a better description of the result you're getting? "It doesn't work" is not really very helpful for debugging.

Also post maybe your actual program multitexture setup, to make sure you're setting up the samplers properly? Can you try to mix the two textures together using the gl_TexCoord[0] uv for both (just as a debug) to make sure that your GLSL actually has proper access to both textures?



Share this post


Link to post
Share on other sites
okay,
It's a kind of approximation problem when i multiply the inputVal by the colortexturesize.
I make a simple test:
bind 2 textures 512*512 on the same image containing a color gradient from black to red+green=yellow:
the results would be the same image....
But the result is a very coarse gradient with only 4 differents colors....

Note for myself : Stop with these damned *&#@ texturerectangle!!!

Here's my input 512² image attached to indexTexture and colortexture


Here's my output:(



Any idea how to correct it?

[Edited by - mp3butcher on March 2, 2010 5:19:01 AM]

Share this post


Link to post
Share on other sites
..arf i obtain exactly the same bad result with a normal texture2d lookup and this fragment shader

//unuseuduniform sampler2D colorTexture;
uniform sampler2D indexTexture;

void main(){
vec4 pos = texture2D(indexTexture, gl_TexCoord[0].st);
vec4 col= texture2D(indexTexture,pos.xy);
gl_FragColor=col;
}

plize help

[Edited by - mp3butcher on March 2, 2010 6:46:57 AM]

Share this post


Link to post
Share on other sites

This topic is 2844 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this