Possible to render Z DEPTH in TGE?
by Tim.Holt · in Torque Game Engine · 01/25/2009 (3:13 pm) · 14 replies
I'm in need of a Z DEPTH rendering method for TGE 1.5.2. By Z-depth I mean that everything is rendered as white that is directly in front of the camera, fading to black with distance. It would be like rendering everything white with no shadows, and then using a black fog that started at 0 and ended at what ever you want your max depth to be.
While I dive into the TGE code to see how I can force white rendering of stuff (too bad I don't use TGEA!) I'm wondering if anyone can point me in the right direction. Either how to force everything to render out as white, or to actually render out with a Z-depth lighting.
The application by the way is to feed it into a technology that can render 3D views of things. I'd like to use it for some Torque content I've been working on.
While I dive into the TGE code to see how I can force white rendering of stuff (too bad I don't use TGEA!) I'm wondering if anyone can point me in the right direction. Either how to force everything to render out as white, or to actually render out with a Z-depth lighting.
The application by the way is to feed it into a technology that can render 3D views of things. I'd like to use it for some Torque content I've been working on.
#2
04/11/2009 (2:29 pm)
Thanks for the reply Marcus. Yea something similar to the WOWvx.
#3
I'm a bit confused actually, to get a stereoscopic image on a stereo display you need two images, one normal and one depthmask (Or 2,4,6,8,10,12 inputs if you want to be picky, depending on how many "views" the display has)
I ran a business focusing on 3D and VR, I might know a guy who knows a guy.
04/11/2009 (2:35 pm)
Ok so it's not a WOWvx? Mind asking what technology you're using? SpatialView?I'm a bit confused actually, to get a stereoscopic image on a stereo display you need two images, one normal and one depthmask (Or 2,4,6,8,10,12 inputs if you want to be picky, depending on how many "views" the display has)
I ran a business focusing on 3D and VR, I might know a guy who knows a guy.
#4
04/11/2009 (4:02 pm)
NDA
#5
If your NDA restricts you from talking about even the technology platform, that means you're working with a company developing a brand new display, but if you do you wouldn't need to ask here about a z-depth renderer.. I is confuzzled. lol
You do need actual z-depth though if you're going to use with a stereo-display, and I'm not sure how well that works with TGE since it does this funky thing and flips x/y/z around, might need to invert the coloring of the z-depth.
It shouldn't be too hard to find a pre-made z-depth renderer so the next step would be for you to implement that into TGE, and that I can't help you with.
Take a look at the WOWvx plugin, if I remember right though it gives you split-screen at high resolution (Make sure you set the game resolution to the right value) and that might not be what you're looking for, but you do need *both* z-depth *and* normal, so either you'll have to use something like the WOWvx OpenGL plugin (Add-on program) or use pathed cameras and etc. and run it twice, once rendering normally and once rendering z-depth, then go and synch the two perfectly or you'll end up with some weird effects, run it through a stereo player and hope it works with whatever display system you're using.
nVidia has some papers on stereoscopic rendering and games, check that out too.
I wish you luck!
Stereoscopic 3D is loads of fun but can be loads of work.
04/12/2009 (2:56 am)
Now I'm even more confused.If your NDA restricts you from talking about even the technology platform, that means you're working with a company developing a brand new display, but if you do you wouldn't need to ask here about a z-depth renderer.. I is confuzzled. lol
You do need actual z-depth though if you're going to use with a stereo-display, and I'm not sure how well that works with TGE since it does this funky thing and flips x/y/z around, might need to invert the coloring of the z-depth.
It shouldn't be too hard to find a pre-made z-depth renderer so the next step would be for you to implement that into TGE, and that I can't help you with.
Take a look at the WOWvx plugin, if I remember right though it gives you split-screen at high resolution (Make sure you set the game resolution to the right value) and that might not be what you're looking for, but you do need *both* z-depth *and* normal, so either you'll have to use something like the WOWvx OpenGL plugin (Add-on program) or use pathed cameras and etc. and run it twice, once rendering normally and once rendering z-depth, then go and synch the two perfectly or you'll end up with some weird effects, run it through a stereo player and hope it works with whatever display system you're using.
nVidia has some papers on stereoscopic rendering and games, check that out too.
I wish you luck!
Stereoscopic 3D is loads of fun but can be loads of work.
#6
Thanks very much for all the information though! I'll definitely check out the WOWvx plugin plus the nVidia papers.
Definitely would be easier to do this in TGEA via shader. I have a license (other project, other user name) and might just do that.
04/12/2009 (9:11 am)
This is a partnership with someone's unreleased technology - we wanted to try out some screenshots of a game in progress with it.Thanks very much for all the information though! I'll definitely check out the WOWvx plugin plus the nVidia papers.
Definitely would be easier to do this in TGEA via shader. I have a license (other project, other user name) and might just do that.
#7
No problem with the info Tim, one problem that you'll face is that you need to render everything twice (More or less anyway), you can't *just* make something render with z-depth since you wouldn't have anything to actually show, z-depth is nothing more then telling the display what depth to show everything at (And remember that each pixel on your z-depth image represents the exact same pixel on the normal image)
Since I don't know what technology you're using I can't really be specific with info or help, but I guess you should check out the info on how the WOWvx displays render things, how their SDK works etc.
Oh, and if you're wondering about my credentials when talking about stereoscopic displays, feel free to have a look at my company website: http://www.NewRealityCompany.com
I wish you luck!
Stereoscopic displays are interesting, and the next step in display technology.
04/12/2009 (9:38 am)
Let me know if you want more info or help, I would sign an NDA if that's needed too.No problem with the info Tim, one problem that you'll face is that you need to render everything twice (More or less anyway), you can't *just* make something render with z-depth since you wouldn't have anything to actually show, z-depth is nothing more then telling the display what depth to show everything at (And remember that each pixel on your z-depth image represents the exact same pixel on the normal image)
Since I don't know what technology you're using I can't really be specific with info or help, but I guess you should check out the info on how the WOWvx displays render things, how their SDK works etc.
Oh, and if you're wondering about my credentials when talking about stereoscopic displays, feel free to have a look at my company website: http://www.NewRealityCompany.com
I wish you luck!
Stereoscopic displays are interesting, and the next step in display technology.
#8
in an ideal world, you would call glReadPixels() together with GL_DEPTH_COMPONENT to get the depth data, then call glDrawPixels() with GL_LUMINANCE to set all three color channels simultaneously.
re turning off RGB rendering,
that's really just an optimization,
so i would start with the copy business and only look at turning off RGB if you find the performance is too slow.
04/13/2009 (8:26 am)
I think you would want to turn off RGB rendering, only render to the ZBuffer, then copy the ZBuffer into each of the RGB channels.in an ideal world, you would call glReadPixels() together with GL_DEPTH_COMPONENT to get the depth data, then call glDrawPixels() with GL_LUMINANCE to set all three color channels simultaneously.
re turning off RGB rendering,
that's really just an optimization,
so i would start with the copy business and only look at turning off RGB if you find the performance is too slow.
#9
.. and Bob's your uncle!

04/13/2009 (9:25 am)
yep, try putting something like this at the bottom of GameTSCtrl::renderWorld():if (Con::getBoolVariable("Video::ShowDepth"))
{
PROFILE_START(ShowDepth);
#define OXE_WIDTH 960
#define OXE_HEIGHT 544
static GLfloat pixelBuf[OXE_WIDTH * OXE_HEIGHT];
// i found this to be necessary to stretch (and invert) the visible range
glPixelTransferf(GL_DEPTH_SCALE, -40.0f); // range 0 to -40
glPixelTransferf(GL_DEPTH_BIAS , 40.0f); // range 40 to 0
glReadPixels(0, 0, OXE_WIDTH, OXE_HEIGHT, GL_DEPTH_COMPONENT, GL_FLOAT, pixelBuf);
glDrawPixels( OXE_WIDTH, OXE_HEIGHT, GL_LUMINANCE , GL_FLOAT, pixelBuf);
PROFILE_END();
}
else
{
Con::setBoolVariable("Video::ShowDepth", false); // avoids multiple "undefined variable" warnings
}.. and Bob's your uncle!

#10
04/13/2009 (9:27 am)
WOW! Thanks!
#11
Yeah Tim, try that out (With scripted cameras, else you'll end up with weird stereo effects.. and render once normally and once with z-depth)
04/13/2009 (9:52 am)
Nice work Orion!Yeah Tim, try that out (With scripted cameras, else you'll end up with weird stereo effects.. and render once normally and once with z-depth)
#12
you can, actually: glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE).
thanks for bringing this up, Tim.
i was actually thinking about a use for something like this (not stereoscopic display) over the weekend, but probably wouldn't have gotten off my butt if you hadn't brought it up.
fun stuff !
futzing around with the scale & the bias you can get it so that a good visible range is about the size of a person:


04/13/2009 (10:06 am)
> you can't *just* make something render with z-depth since you wouldn't have anything to actually showyou can, actually: glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE).
thanks for bringing this up, Tim.
i was actually thinking about a use for something like this (not stereoscopic display) over the weekend, but probably wouldn't have gotten off my butt if you hadn't brought it up.
fun stuff !
futzing around with the scale & the bias you can get it so that a good visible range is about the size of a person:


#13
Which means that what's shown in the z-depth is nothing more then a representation of the depth at which the corresponding pixel on the other image will be displayed.
I'm not sure if that's what you did in the image above here, but there's also the fact that stereo displays are dependant on resolution, IE. most of them (For best result) require the input to be at a certain resolution, which is then split in half because you're putting two images in there representing one image.
What I meant by saying what you're quoting though, was that he can't *just* make the game render a z-depth, since he wouldn't have anything to show by doing that, the z-depth image is just a representation of what "depth" the pixel should be displayed at.
Looks like good progress though and I wish you the best of luck Tim! :D
Stereo 3D ftw!
And yeah, really nice Orion :)
04/13/2009 (10:28 am)
@Orion, the thing with stereoscopic displays using z-depth is that each pixel in the z-depth = the same pixel on a normal image.Which means that what's shown in the z-depth is nothing more then a representation of the depth at which the corresponding pixel on the other image will be displayed.
I'm not sure if that's what you did in the image above here, but there's also the fact that stereo displays are dependant on resolution, IE. most of them (For best result) require the input to be at a certain resolution, which is then split in half because you're putting two images in there representing one image.
What I meant by saying what you're quoting though, was that he can't *just* make the game render a z-depth, since he wouldn't have anything to show by doing that, the z-depth image is just a representation of what "depth" the pixel should be displayed at.
Looks like good progress though and I wish you the best of luck Tim! :D
Stereo 3D ftw!
And yeah, really nice Orion :)
#14
it seems like Tim is indeed working with sterographic display, in which case you certainly would want the color values, but i could think of several applications where you might not care about the color data, such as creating an input file for a CNC Mill or some other physical display device.
04/13/2009 (11:07 am)
well, sure, if you want to show color values then of course you have to have color values to display. perhaps i was being too literal in answering the question at hand. ;)it seems like Tim is indeed working with sterographic display, in which case you certainly would want the color values, but i could think of several applications where you might not care about the color data, such as creating an input file for a CNC Mill or some other physical display device.
Torque Owner Marcus Fernstrom
If so, you not only need to render z-depth though.
Sorry, I don't know of any resource that does what you need, but there are plugins available if you're working with the WOWvx display.