Jump to content
  • Advertisement
Sign in to follow this  
winsrp

Very basic AO concept in HLSL

This topic is 2106 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So in my world of cubes something seemed to be missing, and I might want to add a little of AO to it. I have read about SSAO, and other types but, since its a world of cubes and I dont have really complex features, objects, geometry and stuff, I was looking for a very very very basic application of AO to apply to my game in HLSL.

So, can anyone help me out here.?

Share this post


Link to post
Share on other sites
Advertisement
If it is too simple then it will look awful. Even if you don’t understand the shader you can add a decent AO technique. Besides, all need the same, the depth buffer and some parameters.

I included a couple of SSAO techniques in my engine (http://xnafinalengine.codeplex.com/) that you can see in my source code. I think that they are "easy" to adapt to your engine.
One more thing, I use the AO result with the ambient light, but you can compose it in a final pass.

Share this post


Link to post
Share on other sites
interesting, I gave it a look and can't really understand what it does!!!.. much less how to get it to work. tongue.png

Share this post


Link to post
Share on other sites
Every SSAO technique needs a depth buffer as input. In XNA you can’t access the GPU depth buffer so you need to build one yourself. Why not start there?

You need to render all you opaque geometry in a render target with a Single surface format and a depth surface. Use my shader, but ignore the normal information. Then show me a screenshot of this buffer. I will tell you if it looks correct.

Be aware that the Single surface format does not work with linear or anisotropic filter, so when you render the render target to screen adjust the filter parameter to point.

Any questions?

Share this post


Link to post
Share on other sites
blink.png... will work on that.. and let you know... I do need to make the normals in the pixel buffer, since I'm working normal-less

Share this post


Link to post
Share on other sites
One step at a time. Let's do the depth buffer first.

I’m following the thread so when you have something to show me do a post and I check it.

Good luck!!

Share this post


Link to post
Share on other sites
ok I'm back now, had to do a long trip to Asia which is not over.

I have been looking into catalin zima deferred rendering tutorial here http://www.catalinzima.com/tutorials/deferred-rendering-in-xna/ since this kind of works its way into making the buffers, (I'm also using as reference the xna 4.0 version that other guy did based on this), but I'm kind of stuck trying to thet the direct light to work as it always shows a blank screen, but I can see my other 3 views with, color, normals, and depth in a buffer, so I guess step one is done. I'll post a screen when I get back home.

Share this post


Link to post
Share on other sites
here is the screen of the buffer I have so far.... for some reason the low right corner should be light map, but it still not showing...

[attachment=9311:depth test.png]

Share this post


Link to post
Share on other sites
ok well, I managed to get to get it to work, but its still kind of odd, and I don't fully understand how did I make it work... :huh:

I have some fx files, one does the normal rendering to 3 rendertargets2D, which I draw on the screen above with a spritebatch call of the rendertarget, and then another fx file, does the lighting taking as input the render targets from the first file, but the thing is that I had to render a quad to make it work??? and I cannot seem to print the result with my spritebatch even when the result of the lights fx file is a rendertarget2D because it comes out blank, but if i render what look like a totaly empty quad... the result image pops up in full screen.

:blink: very confused here? I though that only using filling out the parameters and executing the effect.technique.apply method would trigger the code in the hlsl file, so why rendering an empty quad with no reference whatsoever will make any difference when the pixel shader has a output structure? Edited by winsrp

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!