Hey all,
First of all, I don’t know whether this question should go in the “beginner” or “advanced” forum section, but i just put it here. Hope it’s ok
I’ve been struggling with a little prob today.
I have this depth map which ranges from white (nearest to the screen) to black (deepest into the screen).
That is, the values range from 0-256.
So, what I wanna achieve is to make this depth info get into the “real” OGL depth buffer. As a start I just wanna pretend that 256 (i.e. white) equals 0.0f units in OGL and 0 (i.e. black) equals 256.0f.
But I have some problems making that depth info go into the real depth buffer.
I’m trying to use the function glDrawPixels() but I don’t know how I should submit my pixels.
Currently I’m reading the depth map’s pixels using the glGetTexImage() function with the GL_RED flag specified (since R, G and B all equal the same value/color).
I’m then converting those values so that 256 becomes 0 and 0 becomes -256 (since I guess the depth buffer handles negative (-) values as into the screen… as usual).
Before posting anymore stuff of what I’ve tried (and thereby confusing you more than necessary), I’d like to hear what you would do in order to make this work!
I also need to use the glSetRasterPos() in order to make the glDrawPixels() work correctly but I don’t know if I should use glOrtho() mode when submitting the depth map or what…
Just to clear up:
Imagine an adventure game such as Monkey Island. Say I have a pre-rendered 2D image of a scene. In order to move my 3D models around in that scene without it getting clipped away (since the 2D prerendered image is drawn in ortho mode in “front”) I’ve exported a depth map from 3dsmax containing info about how deep stuff is into the screen.
So, all I need to achieve is a way to get that depth map into the OGL depth buffer so e.g. the 3D models are clipped correctly.
Please post all your ideas and, hopefully, solutions to this problem of mine.
It’s GREATLY appreciated!
Thanks in advance,