SceneState and rendering to texture
by Kyle Goodwin · in Torque Game Engine · 09/25/2004 (1:59 pm) · 11 replies
I'm attempting to duplicate SceneState::RenderCurrentImages so that I can render the entire scene to a texture (with some matrix differences and a clip plane etc.) and then use said texture. After digging on this for a while I'm no longer certain that this is the best way to do such a thing, so I have a twofold question: is this the right way to go about rendering the scene to a texture and if it is, what's the right way to go about getting the SceneState upon which to call my new RenderCurrentImagesToTexture method from within the rendering of something else (right now in the fluid rendering code for a planar reflection)? Also, has anyone else done this or is there a good refernce anywhere? I don't want to be reinventing the wheel if it's not necessary... ;) This is the last aspect that's giving me trouble and preventing my having a fully functional real-time reflective bump-mapped water implementation (I'm using CG for my shaders).
Thanks! :)
Thanks! :)
About the author
#2
09/27/2004 (8:37 am)
Actually that works by manipulating portals and rendering what is basically a backwards facing portal back into the room you're in. In short: this will only work on interiors. At least that's how I understand it.
#3
09/28/2004 (9:36 pm)
I've made a lot of progress on this and am very close to having it done, but a few snags remain. My rendered to texture buffer is coming out all black, I must not be using it correctly or something, and for some reason whenever I have rendering to texture enabled I end up with random textures getting put on my terrain in spots, quite odd. It also corrupts the mouse cursor and text in places. Anyone have any ideas about that or agl help with the pbuffers and using them as textures?
#4
09/28/2004 (9:38 pm)
Are you in 16 bit or 32 bit mode?
#5
Check the glBase web site below:
http://www.futurenation.net/glbase/reflect.htm
It has a demo source using the pbuffers for rendering to textures, hope this helps!
09/28/2004 (11:23 pm)
@Kyle:Check the glBase web site below:
http://www.futurenation.net/glbase/reflect.htm
It has a demo source using the pbuffers for rendering to textures, hope this helps!
#6
09/29/2004 (5:29 am)
I'm rendering the texture in RGBA 32-bit mode.
#7
Just wondering what's the modelview matrix you use to mirror the terrain about the clip plane?
10/06/2004 (7:55 am)
@Kyle:Just wondering what's the modelview matrix you use to mirror the terrain about the clip plane?
#8
Assuming an xy-plane clip plane, multiply your current MV matrix by the identity (4x4) matrix and the z component negative. If your clip clane is parallel to the xy-plane but does not pass through the origin, add 2*h (the signed distance from the xy-plane to your plane) to the z-component of the homogenous column vector of the matrix (column 4). This is a standard rotation matrix, the only tricky part is the homogenous bit and the confusion that sometimes arises when not understanding the need for a w component/a fourth column vector.
10/06/2004 (2:38 pm)
@Steven:Assuming an xy-plane clip plane, multiply your current MV matrix by the identity (4x4) matrix and the z component negative. If your clip clane is parallel to the xy-plane but does not pass through the origin, add 2*h (the signed distance from the xy-plane to your plane) to the z-component of the homogenous column vector of the matrix (column 4). This is a standard rotation matrix, the only tricky part is the homogenous bit and the confusion that sometimes arises when not understanding the need for a w component/a fourth column vector.
#9
BTW The terrain still not fully show up in the reflection, I'll check if it's the camera lead to this problem. I use the advanced camera resource.
10/25/2004 (10:12 am)
Almost finish the planar reflection part of it and I can see the reflection now. But the texture coordinates seems not always correct, sometimes I can see it reflect the clippped portion of the rendered texture. So what's the texture matrix you use to project the rendered texture? Thanks.BTW The terrain still not fully show up in the reflection, I'll check if it's the camera lead to this problem. I use the advanced camera resource.
#10
12/03/2004 (9:46 am)
Will you be releasing any of this code? This is still something I'm working on, but I haven't really had time to finish.
#11
No problem! I'll mail the code and some screenshots to you asap, hope we can work together to finish the cool planar reflection and maybe for TSE also!
12/04/2004 (1:24 am)
@Kyle:No problem! I'll mail the code and some screenshots to you asap, hope we can work together to finish the cool planar reflection and maybe for TSE also!
Torque Owner Brian Richardson
You could probably use the same ideas to manipulate and render a scene from the water's pov.