Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Rendering to texture(s)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Kaptein   Prime Members   -  Reputation: 2175

Like
0Likes
Like

Posted 06 November 2012 - 02:22 PM

On the subject of rendering to textures...
I have read each specification up and down 7 times over. That is, I've tried to use FBOs 7 separate times, and found no way to use them in the specific case I'm about to elaborate on
Each time I try, depth-buffer testing no longer works, so, my question is:
If I need to render the scene with depth-testing, I'm guessing I can't use FBOs anymore, which makes them completely useless for me in this particular case.
Is this the case?

Please note that I am currently using FBOs successfully for other things in my project, and I have literally tried every combination of possibility..
I'm only asking as a last resort, just in case anyone has been sitting there for months working out the same problem, and found a solution, or more likely, come to the same conclusion... The specification says that the "real framebuffer" (aka framebuffer 0) is the only one that supports depth-testing

It doesn't matter if I add a renderbuffer or not, as long as I have a depth-texture target the screen is black
If I don't have depth-texture target it draws fine, just without depth-testing anymore
(I can't remember the exact details)

But this is what i need to do:
Render 1x depth, 2x color, remove 1x color, add 1x color, render 1x depth, 2x color, remove 1x color, render 1x depth, 1x color, done
this is the chain, and as you can see, im rendering to on average 3 textures, where one of them is the color target for the fullscreen shader (aka screenspace postprocess texture)
and the depth texture is for the same fullscreen shader


I'm guessing this doesn't work

I'm running OpenGL in compatibility mode (but using mostly 3.x features), so I'm unaware of any differences between core FBOs and compatibility FBOs
I'm hoping they are one and the same (since I don't query entry points for any *EXT)

Edited by Kaptein, 06 November 2012 - 02:28 PM.


Sponsor:

#2 freakchild   Members   -  Reputation: 557

Like
1Likes
Like

Posted 06 November 2012 - 05:36 PM

It doesn't matter if I add a renderbuffer or not, as long as I have a depth-texture target the screen is black
If I don't have depth-texture target it draws fine, just without depth-testing anymore


So, with no test it works but with a test it fails. It sounds like the test may be wrong or at least not configured how you expect it to be. At least make sure glDepthMask, glDepthRange and glDepthFunc are set as you expect them to be, personally it sounds like your fragment output is rejected due to depth working but not as you expect.

It's probably also worth reviewing (googling) the concept of 'framebuffer completeness' to be more certain about what you understand a framebuffer can/can't do. That will cover the necessary minimum and clarify what attachments need to be in place.
Checking for framebuffer completeness via glCheckFramebuffer status is a good idea and may help to debug any obvious errors you might have. You will find the concept of rendering to a depth buffer alone is considered 'incomplete' which is possibly where your actual problem might be. This might be specific to GL ES, but is worth checking anyway.

Specifically, what you might be witnessing above is a misconfiguration of depth parameters when you do have a renderbuffer and when you don't (if I'm reading your 'chain' correctly), you may have a framebuffer incomplete problem.

Edited by freakchild, 06 November 2012 - 06:00 PM.


#3 Ashaman73   Crossbones+   -  Reputation: 7859

Like
0Likes
Like

Posted 07 November 2012 - 07:07 AM

I'm using FBOs+ the depth buffer + multiple color buffers (OGL2.1), switching them all the time without any problems, so I guess, that you either have a missconception or a bug. As freakchild mentioned, check the framebuffer. A complete black screen might be a hint to an invalid framebuffer. Not working depth-tests would most likely result in render artifacts.

If you still can't pin down the bug, then post some code we could review.

#4 Kaptein   Prime Members   -  Reputation: 2175

Like
0Likes
Like

Posted 07 November 2012 - 07:53 AM

So, you are saying with confidence that I have a bug? I hope so Posted Image

I check for framebuffer completeness, all steps are taken to ensure it works (I wouldn't be getting an image otherwise)
Anyways, yes, the depth-buffer isn't modified if i render to a depth-texture at the same time as i render the scene
And the depth-stuff is working, otherwise my glCopyTexSubImage chain wouldn't work Posted Image

I don't know what to say, or what to write (since i stripped out all the code, i have the perfectionist curse)
But I suppose I will be trying again, since you all seem to agree it will work...
Just to be sure: You are saying that if I bind a FBO and use that FBO to render my entire scene,
take out one of the color targets, bind that texture, continue rendering the scene, and depth-testing will function just as before..
I can remove and add color targets as I please, and the only thing standing in my way is me Posted Image
Please say it's so :)

Edited by Kaptein, 07 November 2012 - 07:54 AM.


#5 freakchild   Members   -  Reputation: 557

Like
0Likes
Like

Posted 07 November 2012 - 09:13 AM

Just to make sure, but you are also clearing the depthbuffer too...including at the appropriate points in your chain?

A long shot also, but is there anything in your shader taking an early out so the pixel is not written, based on depth or not?

Given that you also have a long chain of swapping in/out targets, have you spent any time looking at interim results to see if they are as you expect, which if not might provide further clues?

#6 Kaptein   Prime Members   -  Reputation: 2175

Like
0Likes
Like

Posted 13 November 2012 - 05:30 PM

if i had a chair to throw for each combination of parameters and states i have tried out to make this work....
each and every combination i try results in one thing, and one thing only: depth testing stops working right after i remove a color target from an FBO
i need to use the same FBO over again, replacing one texture with another
nothing i do changes this fact
it doesn't matter that i dont need the depth data from before! ive tried not setting depth texture in the first part, only in the second
ive tried having both, clearing it in between
one combination makes the terrain render, but the sky disappear
the other combination makes the terrain not depth-test against itself, and the atmosphere work
how on earth is any of this not well documented??? how am I supposed to solve this nightmare? this is my 8th (yes, EIGHTH) try at implementing FBOs in my project
someone HAS to have an explanation for this behavior!
otherwise im back to good old - "it just works" - glCopyTexSubImage(...)

#7 Kaptein   Prime Members   -  Reputation: 2175

Like
0Likes
Like

Posted 13 November 2012 - 05:48 PM

Ok, I have to make a new post for this:
The fix is simple enough if you know beforehand that theres really only 1 supported format for all of this:
GL_DEPTH24_STENCIL8
everything else has "issues", unless you use FBOs the simple ways like in all the tutorials :)
the problem it seems, or at least i think so, is in clearing the depth buffer with any other format than the above (it didn't seem to work at all)
i just don't know.. it works now, that's good enough for now :)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS