SSAO help
SSAO help
WTF!? I hit submit and my internet instantly killed my text, and hitting back made me retype. Oh, nevermind.
I'm working on screen space ambient occlusion and got to the point where I had to sample my depthmaps at specific points, but I'm getting major artifacts like strange silhouette of objects and major bandings:
Sure my depthmap is precise enough as I encoded the 3color components in it as well. (The R8B8G8A8, which should give me 32-....bits? Is it called that?
I'm suspecting it's due to the projection of the several eyerays for depth difference. What do you think?
I'm working on screen space ambient occlusion and got to the point where I had to sample my depthmaps at specific points, but I'm getting major artifacts like strange silhouette of objects and major bandings:
Sure my depthmap is precise enough as I encoded the 3color components in it as well. (The R8B8G8A8, which should give me 32-....bits? Is it called that?
I'm suspecting it's due to the projection of the several eyerays for depth difference. What do you think?
Last edited by jingquan on Thu Mar 20, 2008 12:47 pm, edited 1 time in total.
A little update: I had to optimize my depth values to get rid of the banding. The ghosting was caused by the incorrect camera frustum.
Now it looks like a really bad toon shading. I'll check out my eyeray depth tmr, and that's probably causing the sampling problems.
BTW, is sourceforge screwing up again?
Now it looks like a really bad toon shading. I'll check out my eyeray depth tmr, and that's probably causing the sampling problems.
BTW, is sourceforge screwing up again?
HELppppp.....
Ok, I can't get it to work. If anyone have any experiences with shaders, you can check out my current screen space ambient occlusion code and see if there's any glaring mistake I made, which there should be?
Thank you.
Thank you.
Last edited by jingquan on Wed Mar 05, 2008 5:28 am, edited 1 time in total.
I'm not too sure if this would make a difference, but you seem to use integers alot in the shader. Sometimes not placing a ".0" after a constant can cause undesired effects.
Cheers
PS: In most cases SSAO is really just an overhyped toon shader, so you may be closer than you think?
Cheers
PS: In most cases SSAO is really just an overhyped toon shader, so you may be closer than you think?
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Ok, thanks, but it looks the same. Right now I'm getting some lines at the corners, something like a toon shader, but they disappear when I change my view to another position. Also, there's lots of noise everywhere.
I changed the eyespace position.
I changed the eyespace position.
Last edited by jingquan on Wed Mar 05, 2008 5:28 am, edited 1 time in total.
Im doing something like this:
Thats the basic theory, its very simple. Offcourse some tweaking and adjustment is needed to get a decent look.
Code: Select all
float Depth = (Read depth at pixel position);
float occludeFactor = 0.0;
Loop through samples (Around 4 - 16 samples usually)
{
float OtherDepth = (Read depth at neighbouring pixel position);
occludeFactor += clamp(Depth - otherDepth,0.001,0.999);
}
occludeFactor *= 50.0; // Multiply by a high number.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Looks like its not going to work for me. Here's the latest version if you would like to give it a try: http://pastebin.com/m528517a0
Right now I'm using it as a very expensive postprocess to generate grains for my scene, and it actually looks a little better with it.
Thanks.
Right now I'm using it as a very expensive postprocess to generate grains for my scene, and it actually looks a little better with it.
Thanks.
I'm not sure if it's a coincident that my shaders refuse to work since I last coded my SSAOs in Notepad. Rendermonkey is too much of a trouble setting up.
Anyway, I tried another form of SSAO: the crease shading. http://www.shalinor.com/code.html and it doesn't quite work either. There is only shading between objects at some parts but there isn't any shading happening on the object itself. e.g. My mesh level doesn't gets crease-shaded at corners, except certain parts that are sticking out which are rarely shaded too.
I'm sure my normal (the one with red/blue/black...colors) and the position (4 squares with light colors on every object) passes are correct.
If anyone could help me I'm so happy.
Code: http://pastebin.com/m1dbf2833
Anyway, I tried another form of SSAO: the crease shading. http://www.shalinor.com/code.html and it doesn't quite work either. There is only shading between objects at some parts but there isn't any shading happening on the object itself. e.g. My mesh level doesn't gets crease-shaded at corners, except certain parts that are sticking out which are rarely shaded too.
I'm sure my normal (the one with red/blue/black...colors) and the position (4 squares with light colors on every object) passes are correct.
If anyone could help me I'm so happy.
Code: http://pastebin.com/m1dbf2833
I already gave you the pseudo code for my SSAO, why not try it? Its really easy to implement. You also won't need any position/normal info, just depth.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
OK, I've tried your depth method and it looks good, at least for a fancy toon shader.
Sorry, anyway, here's what I'm looking at:
Good that its highlighting everything, but is it suppose to be doing it at the topright end of meshes? I encoded my depth to use all of the color channels but there's still light bandings.
Here's my code: http://pastebin.com/m331b0b1b
Let me know how I can optimize it further, thanks Blindside.
EDIT: FIXXXXXED!!!!!
It's so sweet! I was rushing it and forgotten about looping all the samples. (simply change PxOffsets[1] to PxOffsets in the last code)
There's a slight problem with it....Shouldn't the tabletop and weapon be non-shaded? How can I create a range based on the amount of depth differenced so that only values with slight depth diff would be shaded? Also, is there a way to get rid of the banding?
EDIT: Banding gotten rid by giving the 2nd depth a slight depth bias.
EDIT2: I tried a simple cutaway for the SSAO.
Any better ideas?
BTW, what's the use of multiplying with a large number?
Thanks!
Sorry, anyway, here's what I'm looking at:
Good that its highlighting everything, but is it suppose to be doing it at the topright end of meshes? I encoded my depth to use all of the color channels but there's still light bandings.
Here's my code: http://pastebin.com/m331b0b1b
Let me know how I can optimize it further, thanks Blindside.
EDIT: FIXXXXXED!!!!!
It's so sweet! I was rushing it and forgotten about looping all the samples. (simply change PxOffsets[1] to PxOffsets in the last code)
There's a slight problem with it....Shouldn't the tabletop and weapon be non-shaded? How can I create a range based on the amount of depth differenced so that only values with slight depth diff would be shaded? Also, is there a way to get rid of the banding?
EDIT: Banding gotten rid by giving the 2nd depth a slight depth bias.
EDIT2: I tried a simple cutaway for the SSAO.
Code: Select all
float ao = clamp(centerDepth - sampleDepth, 0.001, 0.999);
if (ao < 0.022)
color += ao;
BTW, what's the use of multiplying with a large number?
Thanks!
Hehe nice going, first shadow maps then ssao, you seem to be benefiting quite a bit from my advice.
I used a similar approach to your cutoff for the SSAO, though I don't have the code on me, I think I scaled by the same factor that causes the ssao itself (the depth difference), to create some kind of parabolic effect.
Good luck, It's starting to look pretty nice.
I used a similar approach to your cutoff for the SSAO, though I don't have the code on me, I think I scaled by the same factor that causes the ssao itself (the depth difference), to create some kind of parabolic effect.
Good luck, It's starting to look pretty nice.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Yesss, master of shadows! I'll want to do cubemapping too.Hehe nice going, first shadow maps then ssao, you seem to be benefiting quite a bit from my advice.
What is a parabolic effect? I'd like to try out your method too.
Anyway, here's the depth SSAO which looks great with a blur. It runs rast too since I do not have to render my scene twice (I don't have MRT support ) for depth and normals if I use the crysis method (which doesn't work too).
http://www.orandysoftware.com/user_files/decssao.jpg
SSAO + my scene:
http://www.orandysoftware.com/user_files/decnorm.jpg
BTW, is there a post processing method to fake irradiance? I tried spreading areas that are bright but it looked like bad bloom.
Thanks bliindside.
-
- Posts: 22
- Joined: Wed Mar 05, 2008 8:25 am
That does look nice, maybe a comparison shot of the scene with/without SSAO is in order? I think the difference will be quite amusing
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Here's the exact original scene without SSAO: http://www.orandysoftware.com/user_files/decorg.jpg Download the images and compare it slide by slide. You'll find out some area would look more 3D.
Here's how I do it in C#:
1st. Render everything you want SSAO to affect using the depth shader to a RTT, else hide it
2nd. Grab the texture and load it on the onscreen quad, applying SSAO as well.
I think that's all. There's a post processing framework lying somewhere in the forum too, you can have a look at it.
Here's how I do it in C#:
1st. Render everything you want SSAO to affect using the depth shader to a RTT, else hide it
Code: Select all
WorldNode.SetMaterialType(depth.MaterialType);
tablenode.SetMaterialType(depth.MaterialType);
tablenode2.SetMaterialType(depth.MaterialType);
......
plantnode1.Visible = false;
fernnode1.Visible = false;
fernnode2.Visible = false;
smoke.Visible = false;
driver.SetRenderTarget(lum.rtdepth, true, true, new Color(0, 0, 0, 0));
scene.DrawAll();
Code: Select all
rtao = driver.CreateRenderTargetTexture(new Dimension2D(512, 512));
rtdepth = driver.CreateRenderTargetTexture(new Dimension2D(512, 512));
SSAO.Wireframe = false;
SSAO.Lighting = false;
SSAO.Texture1 = rtdepth;
ushort[] indices = { 0, 1, 2, 3, 4, 5 };
driver.SetRenderTarget(rtao, true, true, new Color(0, 0, 0, 0));
driver.SetMaterial(SSAO);
driver.SetTransform(TransformationState.World, AbsoluteTransformation);
driver.DrawIndexedTriangleList(Vertices, 6, indices, 2);