#1 Members - Reputation: 100
Posted 03 March 2012 - 02:25 PM
What are my options?
#3 Members - Reputation: 100
Posted 03 March 2012 - 03:07 PM
#5 Members - Reputation: 3809
Posted 03 March 2012 - 03:42 PM
Set some fog, either linear or exp, then draw your objects untextured (or with white textures). It won't be an exact replica of what the depth buffer contains, but it will give you the visual result you want.
It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.
#6 Members - Reputation: 100
Posted 03 March 2012 - 05:34 PM
The fog is not going to do it, since it is not just to fake the look, it's an actual depiction of distances that I need :-/ However, the basic idea miiiight have something to it, if I can find no other option...
#7 Senior Moderators - Reputation: 4735
Posted 03 March 2012 - 07:13 PM
However, unless you are restricted to an ancient version of OpenGL, I would recommend using an FBO (Frame Buffer Object), to render the depth buffer directly to a texture in the first place. Or even a shader, to render the z coordinate into the colour buffer, and save having to render multiple passes at all.
Tristam MacDonald - SDE @ Amazon - swiftcoding [Need to sync your files via the cloud? | Need affordable web hosting?]
#8 Members - Reputation: 100
Posted 04 March 2012 - 05:16 AM
You should just just be able to allocate a texture with an internal format of GL_DEPTH_COMPONENT, and call glCopyTexSubImage2D to copy the contents of the depth buffer into that texture. After that, you can render a fullscreen quad with the texture, or whatever else you want...
This looks like exactly what I was thinking. However, I cannot find the proper code for it, and I fear guessing it from scratch will end in utter failure (I am not a veteran). Is there an example or perhaps even a tutorial of this exact method somewhere?
However, unless you are restricted to an ancient version of OpenGL, I would recommend using an FBO (Frame Buffer Object), to render the depth buffer directly to a texture in the first place. Or even a shader, to render the z coordinate into the colour buffer, and save having to render multiple passes at all.
Partly due to my not being veteran, but also because of a long and boring story about what I'm doing (which I'll spare you), I would like to at least try without FBOs or shaders first, if there is a way?
#9 Members - Reputation: 130
Posted 04 March 2012 - 03:25 PM
I thought that since the Z-buffer exists somewhere (I assume, or things would overlap, and my clearing the depth buffer would affect nothing), I should be able to simply(??) swap it for the color buffer.
The thing with that is that, for as far as I'm aware, the z-buffer is implemented (either by hardware or software) on the GPU. This means that the only direct way to get access to it is via shaders.
#10 Senior Moderators - Reputation: 4735
Posted 04 March 2012 - 04:22 PM
AFAIK, shaders can't access the depth buffer directly, either. FBOs are the only way to directly render to a texture (which texture can then be used by a shader).The thing with that is that, for as far as I'm aware, the z-buffer is implemented (either by hardware or software) on the GPU. This means that the only direct way to get access to it is via shaders.
Tristam MacDonald - SDE @ Amazon - swiftcoding [Need to sync your files via the cloud? | Need affordable web hosting?]






