Shader flipping everything!

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Auradrummer
Posts: 260
Joined: Thu Apr 17, 2008 1:38 pm
Location: Brasopolis - Brazil

Shader flipping everything!

Post 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
Professional Software Developer and Amateur Game Designer ;-)
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Shader flipping everything!

Post 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.
Working on game: Marrbles (Currently stopped).
Auradrummer
Posts: 260
Joined: Thu Apr 17, 2008 1:38 pm
Location: Brasopolis - Brazil

Re: Shader flipping everything!

Post 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
Professional Software Developer and Amateur Game Designer ;-)
Auradrummer
Posts: 260
Joined: Thu Apr 17, 2008 1:38 pm
Location: Brasopolis - Brazil

Re: Shader flipping everything!

Post 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!
Professional Software Developer and Amateur Game Designer ;-)
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Shader flipping everything!

Post 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).
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Shader flipping everything!

Post 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?
Working on game: Marrbles (Currently stopped).
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Shader flipping everything!

Post by Nadro »

In a vertex shader You can reverse an Y component of your quad UV.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Shader flipping everything!

Post by Granyte »

or reverse your texcoord

i faced the same issue with my game of life project
TheMrCerebro
Competition winner
Posts: 80
Joined: Tue Jun 29, 2010 10:06 pm
Location: Valencia, Spain

Re: Shader flipping everything!

Post by TheMrCerebro »

With version "1.7.2" always happens exactly the same.
With earlier versions work well.
Follow me on twitter: @themrcerebro
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Shader flipping everything!

Post by Mel »

Or move to DirectX if that option is feasible.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
teto
Posts: 159
Joined: Thu Dec 03, 2009 9:37 pm
Location: /home
Contact:

Re: Shader flipping everything!

Post 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.
Using trunk with mingw/gcc 4.6, Windows 7 64 bits driver opengl
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Shader flipping everything!

Post by hybrid »

Could please someone set up a simple test case where I can reproduce this?
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Shader flipping everything!

Post 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
teto
Posts: 159
Joined: Thu Dec 03, 2009 9:37 pm
Location: /home
Contact:

Re: Shader flipping everything!

Post 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.
Using trunk with mingw/gcc 4.6, Windows 7 64 bits driver opengl
detefon
Posts: 2
Joined: Tue Jun 05, 2012 10:21 pm

Re: Shader flipping everything!

Post 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.
Post Reply