Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: 1 2 3 [4] 5 6
  Print  
Author Topic: Screen-Space Ambient Occlusion( SSAO )  (Read 8212 times)
AriusEso
Customers
Community Member
*****
Posts: 376

Esoteric


« Reply #60 on: June 15, 2008, 02:32:15 PM »

Yea, I was doing an IN->OUT in the vp. Now I'm doing this:


Code:

        float4x4 World    : WORLDVIEW;
        float4x4 wViewProj: WORLDVIEWPROJ;
       
        struct a2v
        {
                float4 Position: POSITION0;
                float3 Normal  : NORMAL;
        };

        struct v2f
        {
                float4 Position: POSITION0;
                float  Test    : TEXCOORD0;
                float3 Normal  : TEXCOORD1;
        };
       
        struct f2s
        {
                float4 Colour  : COLOR0;
        };
       
        void vp(in a2v IN, out v2f OUT)
        {
                OUT.Position = mul(IN.Position, World);
                OUT.Test     = length(OUT.Position.xyz);
                OUT.Position = mul(IN.Position, wViewProj);
                OUT.Normal   = mul(IN.Normal, World);
        }
       
        void fp(in v2f IN, out f2s OUT)
        {
                float  Deep = IN.Test;
                float3 N    = normalize(IN.Normal);
                OUT.Colour = float4(N.r, N.g, N.b, Deep);
        }
       
        technique
        {
                pass Pass0
                {
                        VertexShader = compile vs_1_1 vp();
                        PixelShader  = compile ps_2_0 fp();
                }
        }
Logged

AriusEso
Customers
Community Member
*****
Posts: 376

Esoteric


« Reply #61 on: June 15, 2008, 02:39:39 PM »

Appears to be working now. It is barely noticable in the final scene Cheesy.

http://azazeldev.org/ssao/yeap.jpg

Thanks again Agi, you've been invaluable. Smiley

Logged

nullsquared
Community Member
*
Posts: 13


« Reply #62 on: June 15, 2008, 02:42:50 PM »

Grin

Just out of curiosity, can I see the resulting normals?  Seems like this fixed it.  Now it's really just a matter of playing with the bias coefficient and SSAO radius until you get the desired results. (these two parts are directly related, since the bigger the bias, the longer the length of the random sampling direction, which has the same effect as increasing the SSAO radius)
« Last Edit: June 15, 2008, 02:45:08 PM by nullsquared » Logged
AriusEso
Customers
Community Member
*****
Posts: 376

Esoteric


« Reply #63 on: June 15, 2008, 02:48:31 PM »

It's low quality but you can see here. The walls are black, but fade to red( an just as they go out of shot blue ). I assume this is correct behaviour.

http://azazeldev.org/ssao/normals.avi
Logged

nullsquared
Community Member
*
Posts: 13


« Reply #64 on: June 15, 2008, 03:00:06 PM »

It's low quality but you can see here. The walls are black, but fade to red( an just as they go out of shot blue ). I assume this is correct behaviour.

http://azazeldev.org/ssao/normals.avi
Yup, that's correct behaviour.  Basically, these are view space normals (eye space, same term).  Any right-facing surfaces you see will be red (local +X), and up-facing surfaces will be green (local +Y), and any front-facing surfaces will be blue or black (local +Z or -Z, and the negative gets clamped to 0). (the last part depends on whether your renderer is left or right handed)

So, how does the SSAO look in the final scene now?  What else needs tweaking?
Logged
AriusEso
Customers
Community Member
*****
Posts: 376

Esoteric


« Reply #65 on: June 15, 2008, 03:08:37 PM »

I still need to play with the values I think, but this is what it looks like now:

http://azazeldev.org/ssao/now.jpg
Logged

Toaster
Community Member
*
Posts: 147


WWW
« Reply #66 on: June 15, 2008, 03:15:06 PM »

Wow it looks really neat arius. Keep up the good work you guys! Cheesy
Logged

Visit my site at: Unknown Abstraction
AriusEso
Customers
Community Member
*****
Posts: 376

Esoteric


« Reply #67 on: June 15, 2008, 03:24:35 PM »

Just because I could. 225 skulls.

[click for big]
Logged

Baiame
Customers
Community Member
*****
Posts: 41


« Reply #68 on: June 15, 2008, 05:40:09 PM »

Genius! For some reason I've read about damn near every publicly-discussed SSAO implementation since Crytek's paper. You seem to have really nailed it, nice job.
Logged
Mietze
Community Member
*
Posts: 277

Pleeease, don't let it crash!


WWW
« Reply #69 on: June 19, 2008, 12:48:18 PM »

Very niceley done, Arius! Will this thingy be applyable to real projects in the next time? The FPS are no the best. I think it will even get bader when some (needed) blur is applied. But what about faking the blur? You could downsample the your SSAO buffer, compute the AO and scale it up by modifiyng the UV coordinates in the final pass. This wouldn't look as good as "real" blur, but would decrease the noise factor and also speed this thingy up a bit, wouldn't it?
Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
AriusEso
Customers
Community Member
*****
Posts: 376

Esoteric


« Reply #70 on: June 19, 2008, 01:01:18 PM »

I already have blur and stuff in. The FPS is fine in SM3 and even better in SM2. I can break 140fps on an x1950 with SM2. It's only 2x samples though atm - it doesn't look that bad though.
Logged

GD
Customers
Community Member
*****
Posts: 364


« Reply #71 on: June 19, 2008, 01:43:26 PM »

just wondering... how does it behave with infinite background like sky behind these meshes?
looks great!
Logged

tvsm.co.cc - TVSceneManager
AriusEso
Customers
Community Member
*****
Posts: 376

Esoteric


« Reply #72 on: June 19, 2008, 02:10:01 PM »

It behaves fine. I have a distance check to ensure that close objects do not occlude against far objects. The blurring doesn't bleed either as I check normals etc.
Logged

GD
Customers
Community Member
*****
Posts: 364


« Reply #73 on: June 19, 2008, 03:57:38 PM »

simply great
Logged

tvsm.co.cc - TVSceneManager
Mietze
Community Member
*
Posts: 277

Pleeease, don't let it crash!


WWW
« Reply #74 on: June 19, 2008, 04:05:27 PM »

I already have blur and stuff in.

Ehh... and where is it? Smiley I can't see it on your screenshots :/
Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
AriusEso
Customers
Community Member
*****
Posts: 376

Esoteric


« Reply #75 on: June 19, 2008, 04:32:45 PM »

The screenshots are of the SSAO pass only. Here is the process:

( click them for big )
[no ssao]

[ssao pass]

[blur pass]

[final composite]
Logged

Zaknafein
Customers
Community Member
*****
Posts: 2670


WWW
« Reply #76 on: June 19, 2008, 05:08:41 PM »

1. Wow, the blurring pass overdarkens the SSAO a bit, doesn't it?
2. Do you use depth when blurring so that far-apart surfaces won't blur together?
3. I'd be curious to see a PNG version of the last screenshot to see if all those blocks really are JPEG artifacts... Tongue

And yes, I know, I'm an annoying perfectionist.
Logged

zaknafein.
>> the instruction limit : my blog & samples repository! <<
AriusEso
Customers
Community Member
*****
Posts: 376

Esoteric


« Reply #77 on: June 19, 2008, 05:43:52 PM »

Looks like this, depth rgb is normals.

Code:
                float3 Norm = tex2D(DeepSample, IN.UV).rgb;
                float  AO   = tex2D(SSAOSample, IN.UV).r;
               
                float  Num  = 1;
                int    Sam  = 32;
               
                for(int i = -Sam/2; i <= Sam/2; i+=1)
                {
                        float2 nUV    = float2(IN.UV + i * Direction.xy);
                       
                        float  Sample = tex2D(SSAOSample, nUV).r;
                        float3 sNorm  = tex2D(DeepSample, nUV).rgb;
                       
                        if(dot(Norm, sNorm) > 0.99)
                        {
                                Num += (Sam/2 - abs(i));
                                AO  += Sample * (Sam/2 - abs(i));
                        }
                }

Here is PNG( I did non-interlaced ).

[click for big]


You might notice under the men's feet you can see a gap, this is cause it's convex body and it's not actually touching the floor Smiley.
Logged

GD
Customers
Community Member
*****
Posts: 364


« Reply #78 on: June 22, 2008, 04:38:45 AM »

is parallax height taken into account for ao? would be cool to see that in "bumpy" scenes...
Logged

tvsm.co.cc - TVSceneManager
AriusEso
Customers
Community Member
*****
Posts: 376

Esoteric


« Reply #79 on: June 22, 2008, 09:01:30 AM »

No, the depth is grabbed just on position. Sad
Logged

Pages: 1 2 3 [4] 5 6
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks