Page 1 of 1

Shader flipping everything!

Posted: Sun Jan 01, 2012 2:15 pm
by Auradrummer
Hello guys,

I'm facing a strange problem here.
I'm trying to do a car painter, like Need for Speed Carbon. Worked well and I'm happy with it, but I have a problem and have no idea how to solve.

I have one Scene Manager where the car texture is made. I can mix bitmaps and achieve the desired paniting without any problems (left image).
But, when I apply my shader, various images are flipped upside down. (right image).

Testing, I discovered that if I load directly an Image and not use the RTT one, this problem doesn't happen, even using my shader.
I noticed too that this happens only with images applyed AFTER the shader call.

How can I solve this?

Image

Thanks

Re: Shader flipping everything!

Posted: Sun Jan 01, 2012 2:22 pm
by serengeor
This is probably a problem with OpenGL driver. If so, do two RTTs, so it would flip back to normal. At least that's what I was told when I had this problem with RTTs.

Re: Shader flipping everything!

Posted: Sun Jan 01, 2012 2:30 pm
by Auradrummer
Hi Serengor,

How can I do two RTT's?
by calling

Code: Select all

driver->setRenderTarget(pintura, true, true, SColor(255, 255, 255, 255));
two times?

No difference here.

Thanks for the fast reply

Re: Shader flipping everything!

Posted: Sun Jan 01, 2012 4:00 pm
by Auradrummer
Keep trying here, but no success yet...

The another RTT should be another quad with another camera pointing to it?
To the experts, why this are bugging the others images that have nothing with the shader or RTT?

Keep working!

Re: Shader flipping everything!

Posted: Sun Jan 01, 2012 4:16 pm
by hendu
Using irr+gl+rtt = some bug somewhere mixing up the origin. The recommended workaround = set2dmaterial(get2dmaterial) (not exact syntax obviously, not at my usual comp).

Re: Shader flipping everything!

Posted: Sun Jan 01, 2012 8:00 pm
by serengeor
Auradrummer wrote: The another RTT should be another quad with another camera pointing to it?
Yes, I meant it like that. It worked perfectly fine for me.
Also maybe switching UV coords might do the job?

Re: Shader flipping everything!

Posted: Tue Jan 03, 2012 2:49 pm
by Nadro
In a vertex shader You can reverse an Y component of your quad UV.

Re: Shader flipping everything!

Posted: Tue Jan 03, 2012 4:06 pm
by Granyte
or reverse your texcoord

i faced the same issue with my game of life project

Re: Shader flipping everything!

Posted: Tue Jan 03, 2012 4:31 pm
by TheMrCerebro
With version "1.7.2" always happens exactly the same.
With earlier versions work well.

Re: Shader flipping everything!

Posted: Wed Jan 04, 2012 10:17 am
by Mel
Or move to DirectX if that option is feasible.

Re: Shader flipping everything!

Posted: Fri Jan 20, 2012 11:32 pm
by teto
Hi,

I've got the same pb with svn version (not the latest though). I can't move to directX and don't want to create another quad/cam. Rendering twice on the same quad doesn't change anything. I am a beginner with shader and as such, I don't succeed in reverting my texcoord.

I tend to do: gl_TexCoord[0] = gl_MultiTexCoord0 - vec4(0.,1.,0., 0.); in my vert shader but doesn't work.

Re: Shader flipping everything!

Posted: Fri Jan 20, 2012 11:37 pm
by hybrid
Could please someone set up a simple test case where I can reproduce this?

Re: Shader flipping everything!

Posted: Sat Jan 21, 2012 12:33 am
by Granyte
generaly texcoord can be reversed by simply adding

ouput.texcoord = 1.0-texcoord

in vertex shader but then again that depend on your specific vertex shader

Re: Shader flipping everything!

Posted: Sat Jan 21, 2012 1:17 am
by teto
@Hybrid > You can download my first attempt at shaders derived from example 13:
http://downloads.tuxfamily.org/bluecosm ... re_poc.zip
It should be simple enough for you to have it running quickly.

@granyte> i work with glsl (4.1) and gl_TexCoord[0] = vec4( 1,1,1,1) - gl_MultiTexCoord0 ; revert according to x and y, and I get exactly the same result for gl_TexCoord[0] = vec4( 0,1,1,1) - gl_MultiTexCoord0.

Re: Shader flipping everything!

Posted: Sat Jun 09, 2012 12:27 pm
by detefon
I have the same problem, but the change ($i_DeviceType) of OpenGl to DirectX solve the problem. :D

Obs: I use AutoIt with IrrLicht.