Very basic AO concept in HLSL

Started by
25 comments, last by winsrp 11 years, 8 months ago
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.?
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.

[size=1]Project page: [size=1]<

[size=1] XNA FINAL Engine[size=1] [size=1]>
interesting, I gave it a look and can't really understand what it does!!!.. much less how to get it to work. tongue.png
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?

[size=1]Project page: [size=1]<

[size=1] XNA FINAL Engine[size=1] [size=1]>
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
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!!

[size=1]Project page: [size=1]<

[size=1] XNA FINAL Engine[size=1] [size=1]>
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.
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]
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?
so I' trying to make this

http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/a-simple-and-practical-approach-to-ssao-r2753

work with my game, but besides compiling the code, I really have no idea how to make this work with the deferred rendering I have... clueless now.

This topic is closed to new replies.

Advertisement