Projection/View matrix 'flipping' help!

Problems building or running the engine, queries about how to use features etc.
Post Reply
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Projection/View matrix 'flipping' help!

Post by al2950 »

Hi all

I am currently trying to sort an issue with ogre not rendering cubemaps correctly. Basically when rendering to the cubemap I need to flip the render horizontally. As an example here is the a dynamic cubemapping demo I have done;
Normal.jpg
When rendering to the cubemap I want it to look like this;
Flip.jpg
Currently I have done this with the following code

Code: Select all

projectionMatrix[0][0] = -projectionMatrix[0][0]
However it ends up messing up the vertex winding so it only renders the backfaces of the models. Can anyone give me a helping hand here as the maths involved in projection matrices is not my forte!?
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: Projection/View matrix 'flipping' help!

Post by xrgo »

al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: Projection/View matrix 'flipping' help!

Post by al2950 »

Unfortunately not :( . That changes it during sampling so although it fixes a dynamic cube map it breaks a normal 'static' cube map texture. This becomes very obvious/annoying when you use a static cube map texture as part of you skybox.
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: Projection/View matrix 'flipping' help!

Post by xrgo »

That's strange, for me it solved it for dynamic AND static/texturefile cubemaps
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: Projection/View matrix 'flipping' help!

Post by al2950 »

xrgo wrote:That's strange, for me it solved it for dynamic AND static/texturefile cubemaps
Well it depends on how you think a cubemap should be sampled! But if you created a skybox using a static cubemap texture then used it in a dynamic cube map, then it would not work, unless you fudged all the areas in which you sampled the different cubemaps.

cubemaps are sample as if the texture is wrapped around the outside of the box and you sample it from the inside, hence normal sampling will always 'flip' the texture, and so why when writing to a cubemaps (from affectively inside the cube) you need to flip it again.
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: Projection/View matrix 'flipping' help!

Post by xrgo »

=O that makes sense, thanks... and sorry I couldn't help :P
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: Projection/View matrix 'flipping' help!

Post by scrawl »

Can you flip the sampling from the cubemap instead of flipping the rendering itself?

Or, you could apply the flip to the camera's view matrix (enableReflection), this way the scene manager should automatically invert the vertex winding for you. https://bitbucket.org/sinbad/ogre/src/9 ... r.cpp-1207
Post Reply