Displaying my cubemaps in world space, rather than eye
This might be hard to describe eloquently, but here goes:
My cubemaps appear to be displayed in eye space. E.g., the cubemaps display as if the cube were always following the rotation of the camera. An example -- I'll cook up some screenshots if anybody wants -- would be if you had a cubemap with blue sky and green ground. You position the camera level with the sphere, looking horizontally, and you see blue on top and green on bottom. That's great.
But, then you position the camera *over* the sphere, and look straight down. I'm seeing blue on top, green on bottom again. Which is wrong, since I'd expect to see blue only, since blue's on top of the cubemap and I should be seeing that reflected. This is why I think the cubemap is being calculated in eye space, as opposed to world.
What I'm assuming is that I need to swizzle the texture matrix to get the cubemap to be calculate in world space as opposed to eye. My... guess... would be to take the rotational component of my camera's modelview matrix, invert it, and assign that to the texture matrix.
Is this the right way?
Thanks,
My cubemaps appear to be displayed in eye space. E.g., the cubemaps display as if the cube were always following the rotation of the camera. An example -- I'll cook up some screenshots if anybody wants -- would be if you had a cubemap with blue sky and green ground. You position the camera level with the sphere, looking horizontally, and you see blue on top and green on bottom. That's great.
But, then you position the camera *over* the sphere, and look straight down. I'm seeing blue on top, green on bottom again. Which is wrong, since I'd expect to see blue only, since blue's on top of the cubemap and I should be seeing that reflected. This is why I think the cubemap is being calculated in eye space, as opposed to world.
What I'm assuming is that I need to swizzle the texture matrix to get the cubemap to be calculate in world space as opposed to eye. My... guess... would be to take the rotational component of my camera's modelview matrix, invert it, and assign that to the texture matrix.
Is this the right way?
Thanks,
Turns out, that's exactly what I needed to do.
Voila.
See, all the cubemap demos I'd looked over were of the simple "here's a cubemapped teapot", with a fixed camera. The mouse just rotated the teapot. I read over an NVIDIA article on cobemaps from '99 and it described how you could convert to world space in the texture matrix.
Code:
glMatrixMode( GL_TEXTURE );
glLoadMatrixf( world()->activeCamera()->modelview().rotation().inverse().mat );
glMatrixMode( GL_MODELVIEW );Voila.
See, all the cubemap demos I'd looked over were of the simple "here's a cubemapped teapot", with a fixed camera. The mouse just rotated the teapot. I read over an NVIDIA article on cobemaps from '99 and it described how you could convert to world space in the texture matrix.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Another beginner's question about displaying an animated object | superlemonster | 2 | 4,140 |
Jan 28, 2011 08:03 AM Last Post: OptimisticMonkey |
|
| Best strategy for rendering into cubemaps? | TomorrowPlusX | 7 | 4,113 |
Dec 6, 2009 11:53 AM Last Post: TomorrowPlusX |
|
| Simple OpenGL 2d test - nothing displaying | SaxMan | 8 | 5,473 |
Jan 19, 2009 12:04 AM Last Post: TythosEternal |
|
| Help converting normals from global space to tangent space | Muthaias | 6 | 4,756 |
Apr 1, 2008 06:28 AM Last Post: Muthaias |
|
| Displaying image with OpenGL and DevIL in C? | leRiCl | 13 | 8,287 |
Jan 23, 2007 01:25 PM Last Post: djork |
|

