the best ssao ive seen

Started by
237 comments, last by Paksas 12 years, 5 months ago
Grrr I cannot get the frustum ray method to work. I get crap results like this:

http://img692.imageshack.us/img692/3958/fknssao.jpg

I've checked the output of the position and normals and they look the same as if I output them using the shader in render monkey. Eg. for position i have 4 quadrants - aqua/white/blue/pink

AgentSnoop: you definitely have the frustum method working with this shader? Can you whip up a small dx project showing it working coz this making me pull my hair out :( I tried your way of calculating the frustum rays too, and it gives me the same ray values.

ArKano22: an RM project showing frustum rays working with this would also be good if you can spare the time to make one? :)

[Edited by - Shael on March 20, 2010 2:49:33 AM]
Advertisement
Quote:Original post by Shael
Grrr I cannot get the frustum ray method to work. I get crap results like this:

http://img692.imageshack.us/img692/3958/fknssao.jpg

I've checked the output of the position and normals and they look the same as if I output them using the shader in render monkey. Eg. for position i have 4 quadrants - aqua/white/blue/pink

AgentSnoop: you definitely have the frustum method working with this shader? Can you whip up a small dx project showing it working coz this making me pull my hair out :( I tried your way of calculating the frustum rays too, and it gives me the same ray values.


I updated mine slightly. instead of sending the frustum ray via vertex shader to pixel shader, as ArKano22 has pointed out, the ray isn't really valid for the other samples, I sent the vector of just one view space corner, and then did:
float x = lerp(-frustumCorner.x, frustumCorner.x, uv.x);float y = lerp(frustumCorner.y, -frustumCorner.y, uv.y);return tex2D(depthbuffer, uv).r * float3(x, y, frustumCorner.z);


Give that a try, see if that fixes anything up. The order of the negations for the x, and y depend on which corner you send. I just outputted the position to make sure the quadrants were the right color to make sure.
I gave that a try and managed to get the colour output for ray to look right - green/yellow/black/red. I now get this as the output for ssao:

http://img718.imageshack.us/img718/2748/ssaoooo.jpg

Looking a lot better now but still not quite right I think. I haven't adjusted the scale/bias/etc yet so that might improve it. I'll let you know how I go though.

What sort of results are you getting?
Quote:Original post by Shael
I gave that a try and managed to get the colour output for ray to look right - green/yellow/black/red. I now get this as the output for ssao:

http://img718.imageshack.us/img718/2748/ssaoooo.jpg

Looking a lot better now but still not quite right I think. I haven't adjusted the scale/bias/etc yet so that might improve it. I'll let you know how I go though.

What sort of results are you getting?


Here are some of my results:


The cube in the second one is messed up I think because I exported it to .3ds from 3ds max because it looks that way when I load the model in RM using the non frustum ray as well.
@AgentSnoop

Looks correct to me but some of your normals are messed up (the cube in the second pic, as you say, but also the archs and some walls and collumns in sponza)
Quote:Original post by ArKano22
@AgentSnoop

Looks correct to me but some of your normals are messed up (the cube in the second pic, as you say, but also the archs and some walls and collumns in sponza)


Yeah, I just checked the normals on the cube, and they are way off. I'm wondering if the arches are the same because I exported to .3ds from .max file as well. I noticed some of the walls were also similar to the cube.

EDIT: Yeah, it's because of shared vertices. I detached each face of the cube in the 2nd screen shot and the normals are correct now.

[Edited by - AgentSnoop on March 20, 2010 5:13:29 PM]
EDIT: think I finally got the bugger working.

This is the mesh with the original values from the RM project. Appears to look identical to what shows in RM.

http://img440.imageshack.us/img440/3966/ssaooo.jpg

And this is after I have adjusted them:

http://img402.imageshack.us/img402/56/ssaooonew.jpg

Turns out I had to negate the frustum corner z.

float3 getPosition(in float2 uv){	float x = lerp(-FrustumCorner.x, FrustumCorner.x, uv.x);	float y = lerp(-FrustumCorner.y, FrustumCorner.y, uv.y);	return tex2D(DepthSampler, uv).r * float3(x, y, -FrustumCorner.z);}


Btw, AgentSnoop are you doing any blurring in those shots? They look a lot smoother than my results and what shows in RM for the box/room mesh.

Just wanna say thanks to both of you for your help. Much appreciated :)



[Edited by - Shael on March 20, 2010 9:30:17 PM]
Quote:Original post by Shael
I seem to be getting the same crappy results as before even using the new ray method. I'm noticing that the shading seems to shift when the camera view rotates. Would that means the normals are wrong or something else?

It has to be something small I'm missing. This is the depth/normal and ssao shader code.

http://illusionaldesign.net/depthnorm.fx
http://illusionaldesign.net/ssao.fx

And this is the output:

Depth: http://img688.imageshack.us/img688/2469/raydepth.jpg
VS Normals: http://img684.imageshack.us/img684/531/normals.jpg
SSAO: http://img683.imageshack.us/img683/479/ssaoo.jpg



The only differences I can see right now are that you seem to be sending a different frustum corner than me (not necessarily a problem), my z normals are opposite of yours (instead of black, I get blue), and my parameters for the SSAO are:

float g_sample_rad = .1;
float g_intensity = 1.0f;
float g_scale = 1.0f;
float g_bias = 0.01f;

So since your z normals are black instead of blue, maybe get rid of the -In.PositionVS.z and just put In.PositionVS.z.
Heh think I just edited my previous post as you replied. Using the parameters you have I look to be getting similar results to you now:

http://img11.imageshack.us/img11/8093/ssaoneww2.jpg

Yay! Thanks man :D
Quote:Original post by Shael
Heh think I just edited my previous post as you replied. Using the parameters you have I look to be getting similar results to you now:

http://img11.imageshack.us/img11/8093/ssaoneww2.jpg

Yay! Thanks man :D


Cool! you got it!

The only artifact I can see now are these little black dots on the floor, not sure what causes them though...

This topic is closed to new replies.

Advertisement