PDA

View Full Version : Code examples of ambient occlusion techniques?



jeramboquai
04-07-2012, 12:41 PM
Hello, everyone. I'm very inexperienced in OpenGL and graphics programming in general but I am trying to do an implementation of horizon-based ambient occlusion. The problem is that I don't know how to use or copy the depth buffer to a texture, send that texture to the fragment shader, or access textures in the fragment shader. I am using C/C++.

Can anybody point me to a good piece of sample code that shows this sort of thing being done? Something where the code is understandable and relatively straightforward in implementation? If not that, is there any good book or other source that clearly explains these things to total novices such as myself?

If anybody could help, I would be most grateful!

BionicBytes
04-07-2012, 01:34 PM
Use a framebuffer object with a depth texture attached.
plenty of examples on the net.

jeramboquai
04-07-2012, 02:13 PM
Thanks for responding. Once I find code that does that, where does it go in the program? I know it it slow, but I understand immediate mode in OpenGL. If I were using that, would I make the texture right after the glEnd() call but before I swap buffers?

Also, how would I send it to the fragment shader?

noobscratcher
04-13-2012, 01:38 AM
people don't help here they just give you hints and tips and ones in a while an actual solution its a load of bullshit but hey thats how its been put onto me so I just decide to get away from it and try another way

Alfonse Reinheart
04-13-2012, 09:19 AM
people don't help here they just give you hints and tips

I've never seen anyone "helped" by being given code that they can copy and paste directly into their application.

And if you don't like this place so much, why are you still here?

BionicBytes
04-13-2012, 09:20 AM
people don't help here they just give you hints and tips and ones in a while an actual solution its a load of bullshit but hey thats how its been put onto me so I just decide to get away from it and try another way
That's because people insist on asking open-ended questions which could take hours or weeks to answer properly. On other occasions people are too lazy and don't even bother to Google the question themselves. Typically, the questions are too vaigue - ask specific questions and people here are more than willing to answer them.

tonyo_au
04-13-2012, 11:46 PM
people don't help here they just give you hints and tips
Many of us have full time jobs programming this stuff are truly grateful for any time people put into answering our questions. If you want to pay me I will write your code for you

V-man
04-14-2012, 02:48 AM
I agree with the above comments.
Besides, this is Jeram's thread. It is up to him to come back and post questions. We'll be happy to throw in keywords Jeram can search with, which BionicBytes already did.

Besides that, all I can add is if you want to copy the framebuffer's depth to a texture, make a depth texture. Use glCopyTexSubImage2D.

If you do a search on the Wiki, you find
http://www.opengl.org/wiki/Common_Mistakes#Updating_A_Texture

As for FBO, there is this
http://www.opengl.org/wiki/Framebuffer_Object_Examples

and look at "Quick example, render_to_texture (2D Depth texture ONLY)"

jeramboquai
04-14-2012, 09:12 PM
Wow! Looks like there has been some activity in my absence. Heh.

I am sorry if my questions were too vague or open-ended? Were they? Even in my reply? I am just asking for future reference.

For the record, I did try to search for information/tutorials/code that could help for quite a while before coming here. Believe or not I initially had trouble finding a really good, clear source from which I could learn. This was actually more of a "last resort". Nevertheless, I did manage to find a great source that answered all of my questions by searching for "shadow mapping tutorial" since it involves many of these techniques. I thought it was kind of funny that a more indirect approach to searching worked out so well.

If that helps any future individual who steps into this thread, there you go. Thanks, everybody!