Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Rendering inverted scene to FBO oddness

This topic is 3737 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

Hey I'm trying to implement this article: http://www.gamedev.net/reference/articles/article2138.asp using OpenGL and CG (ps if anyone has it implemented i'd love to take a look) But anyway, I have everything correctly set up. I have a FBO that I render to, no problems ( I draw the texture on screen to make sure everything is correct), however a problem arises when I want invert the scene as I render it to the FBO. It's driving me crazy. This is how my render loop is set up:
	// Set the camera


			// Invert everything
			glScaled(1, -1, 1);

			glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, World::self->ocean->m_fbo);
			glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);


	// Clear the buffer

	// Render the world

I render to the FBO first, but i've also tried to move it behind. Anyway, the problem is that everything I render in the FBO rendering part, will actually show up NON reversed in the FBO, but REVERSED when i render to the screen! This ALSO happens if I move the FBO rendering part below the screen rendering. I've read that this could possibly be because glscaled changes the winding order, but I've tried to manually set them for both render modes without any change. So basicly... What I'm having a really hard time understanding is why rendering something in my FBO rendering stage would affect the way it's rendered in my screen rendering stage. If I don't render anything to the FBO (but still leave the glscaled and everything) the screen render is fine. But as soon as something is rendered to FBO it flips in my screen rendering. Hope anyone understands what i'm saying :o

Share this post

Link to post
Share on other sites
You have this line in your Cg shader
outPos = mul(Mvp, inPos);

are you sure you are properly updating Mvp?

Share this post

Link to post
Share on other sites

I'm actually not even rendering the water at all right now, i'm just trying to make the inverted texture.

I've tried to reload my camera ModelViewMatrix after and before the FBO rendering, and even putting a couple of glLoadIdentity()'s there too, but without any changes.

In all my render calls I update the MV and MVP matrices in the shader, so I should do it twice every frame, each time with an appropriate Mvp.

Each render call also activates and deactivates the appropriate shader, so there should be no "bleed" between.

Here is a screenshot if it helps:


The blue overlay is the FBO projected texture'd on to the water plane (In the previous example I had the ocean rendering disabled).

The FBO is drawn in the little window that overlays evertyhing.

Here is annother screen:
There I only render the SkyDome and SkyPlane into the FBO.
However, once it comes to render it to the screen it's turned upside down! :P

it's probably something really stupid... but I can't see it!

[Edited by - bjarnia on April 23, 2008 1:38:14 PM]

Share this post

Link to post
Share on other sites
I've managed to get it working. But in a manner that makes no sense at all.

I first render to my FBO without inverting anything.

Then I invert my MV and render to screen.

For some bizzare reason this works. It makes no sense at all to me.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!