Help projecting a reflected texture (distorting)

Started by
17 comments, last by toucel 19 years, 7 months ago
If you use VP, then you can do things like clamp tex coordinats to 0-1 range. Or, something that might work even without VP, is to render to texture with differnt (bigger) FOV, but that is not so easy to get right. There is better alternative to this but I can't find that thread now (I know it was posted by Yann).
You should never let your fears become the boundaries of your dreams.
Advertisement
Ok, I'm using a VP now so it should be easy to clap that, but first I have a problem when using the vp.

When using a VP I dont know how to get this to pass though the program.
	glMatrixMode(GL_TEXTURE);	glLoadIdentity();	glPushMatrix();	glScalef(0.5f, 0.5f, 1.0f);	glTranslatef(1.0f, 1.00f, 0.0f);	glMultMatrixf(camPointer->projMatrix);	glMultMatrixf(camPointer->modelMatrix);	glMatrixMode(GL_MODELVIEW);


So I went to try and do this in cg. I can do the multMatrix no problem but I have no idea how do the scale and translation.

My VP
vfconn main(appdata IN,	uniform float4x4 ModelViewProj,uniform float4x4 ProjMatrix){	vfconn OUT;		OUT.HPos = mul(ModelViewProj, IN.position);		OUT.Col0 = IN.color;		OUT.textcrdo = mul(ModelViewProj, IN.textcrd);	return OUT;}
Ok I found out you can pass in the texture matrix *duh*.


But the problem is now clamping so the texture doesnt extend beyond where it should (creating the problem you see in the picture above). I can't just clap between 0 and 1, how should I go about clamping?

Here is by cg vp:
vfconn main(appdata IN,	uniform float4x4 ModelViewProj, uniform float4x4 TextureMatrix){	vfconn OUT;		float ts, tc;		ts = .5*sin(IN.position.x/2.0+IN.wave);	tc = .5*cos(IN.position.z+IN.wave);	OUT.HPos = mul(ModelViewProj, IN.position);	OUT.Col0 = IN.color;		OUT.textcrdo = IN.position;	OUT.textcrdo.x += ts;	OUT.textcrdo.y += tc+ts;		OUT.textcrdo.y += tc;				OUT.textcrdo = mul(TextureMatrix, OUT.textcrdo);	return OUT;}
Any one?
Bump :(

I actually just fixed that same problem in my code, after realizing how obvious the solution was.

I wasnt setting my rendered texture to be clamped - it was set to repeat by default.

I told it to CLAMP_TO_EDGE and now everything works great...
skow : is that you who's replying here ?

<rant>I always hate anonymous posters who write interesting things. It's so frustrating not to know if this is a member that couldn't log or someone else.</rant>
Hah that worked easy!

Thanks!

It was me, sorry about the confusion. I usually post anonymous, unless there is a real reason to do otherwise.

This topic is closed to new replies.

Advertisement