|
||||||||||||||||||
GameDev.Net Discussion Forums Image of the Day SSAO for Quest3DSend Topic To a Friend | View Forum FAQ | Track this topic | View Forum |
Last Image Next Image ![]() |
| SSAO for Quest3D |
|
![]() Viik Member since: 5/1/2006 From: Kiev, Ukraine |
||||
|
|
||||
![]()
This is implementation of SSAO specifically made for Quest3D engine. SSAO rendered into texture that is the same size as screen resolution, depth is not downsampled, performance can be much better if both options added. On my PC's biggest performance hit is a double render of geometry, first time for getting depth and second time for actual shading. First version was build using Starcraft II approach, but usage of special normal map and issues with sampling radius made it less flexible than needed. So, I decided to rewrite it from scratch. Current version dosn't use normal map and as result has a self-occlusion artifact, but it can used as advantage if you don't treat occlusion calculation as binary function. Occlusion calculated by averaging depth difference between current pixel and 8-16 samples around it, including positive and negative difference. 4x4 texture of semi-random vectors is used to rotate samples in screen space. Simple box blur that accounts for depth difference is used at the end to blur noise. You can grab executable here: http://3dvrm.com/ssao/ [Edited by - Viik on March 23, 2009 6:56:30 AM] |
||||
|
||||
![]() ali rahimi Member since: 9/26/2006 From: Tehran, Iran |
||||
|
|
||||
| Hello. Iam quest3d user. Great work. Are those plant are hardware instancing? My online portfolio website : http://www.ali-rahimi.net |
||||
|
||||
![]() Viik Member since: 5/1/2006 From: Kiev, Ukraine |
||||
|
|
||||
| Hello Ali, yes, plants and stones are both hardware instanced meshes. |
||||
|
||||
![]() PolyVox Member since: 11/24/2002 From: Derby, United Kingdom |
||||
|
|
||||
| Looks nice :-) I get about 150FPS with the SSAO turned on, and about 190FPS with it turned off on my NVidia 260. My open source voxel-based game engine |
||||
|
||||
![]() Ezbez Member since: 5/10/2005 |
||||
|
|
||||
| Quite nice! I get about 15 FPS on my GeForce 7600 GS, but it's still pretty. Though it looks great on statue and rocks, I find it too much on the plants. Party because the z-buffer doesn't line up with the actual graphic of the plants, but mostly it just makes it too much contrast there. The improvements of SSAO are dramatic on the statue, though! |
||||
|
||||
![]() Semei Member since: 10/28/2007 |
||||
|
|
||||
| I think that SSAO is not worth its price :) None implementation. More soft shadowed lights look better, and faster. If you use SSAO, you are limited on shadowed lights (because of performance) Use baked AO instead for static objects and good quality soft shadows for dynamic objects + you will have more free space for other effects. That's my opinion. |
||||
|
||||
![]() Viik Member since: 5/1/2006 From: Kiev, Ukraine |
||||
|
|
||||
| PolyVox Thanks for feedback! Ezbez Yeah, contrast is a bit too strong, I set it in such a way to make bigger difference between shading with and without SSAO. In real projects I always make it subtle. Funny, but somtimes you trying to understand is it there at all or something bugged and it dosnt render and when you switch it off to check, you get surprised ))) Our brain get's used to it very fast. Semei I didn't had enought time to add shadow maps to this example, why I mention them, because one would apply SSAO scaled by amount of lighting (biggest influent would be in shadow). SSAO should be used to attentuate ambient light and together with other techniques, like hemisphrecial lighting, it greatly improves shading on non lit surfaces. You can use it for lit surfaces as well, like in case of ground in demo, with or without shadows. So it dosn't relevant to shadow technique used in your application. As to performance, FPS is not the best measure of performance, on my PC's scene with heavy shading run's about 35-40 Fps, switching off SSAO give's about 2-3 fps, switching off double render give 15, but you need it for other effects. Soft-shadows don't have a linear impact on performance, their performance depends on geometry that is affected by light. SSAO on other side has a linear performance dependency from screen resolution. So, removing SSAO dosn't give you enought performance exactly for one more soft-shadowed light. Another point is that there many ways to implement both of them, performance depends more on implenentation than the idea itself. Bytheway, visual impact of soft-shadows and SSAO is different. Why you would bake AO for static geometry if you can use SSAO? ))) http://www.crytek.com/fileadmin/user_upload/inside/presentations/2008/TheRenderingTechnologiesOfTheCryENGINE2.ppt Slide 11, affect of SSAO in Crysis. Look how much details you get on shadowed ceiling. [Edited by - Viik on March 25, 2009 4:55:44 AM] |
||||
|
||||
![]() Semei Member since: 10/28/2007 |
||||
|
|
||||
| You are taking like 16 samples per pixel (for average SSAO), then possibly converting them from depth to position, adding comparing, dividing that's HUGE load. Also in good implementation you should prevent things like bleeding AO of foreground objects against background, and many other stuff. Why not to bake AO for static objects, it will look better and much faster! I think that people are overusing SSAO just because its more simple to do some fullscreen pass, and write one shader than to integrate AO baking :P. Easy is not always better. Use some stencil/scissor test to include only dynamic objects and blend with static. |
||||
|
||||
![]() Hightree Member since: 1/18/2002 From: Netherlands |
||||
|
|
||||
| Sometimes there is no room in the art pipeline for AO baking. Adding it increases the turnaround time considerably. So SSAO is a nice alternative, especially if you're not too pressed for max performance. |
||||
|
||||
![]() Viik Member since: 5/1/2006 From: Kiev, Ukraine |
||||
|
|
||||
Quote: I would quote Hightree on this one. Sometimes "easy" means thousands of $. Hypotetically, I can send you this scene, how much time you would spent on baking AO. Ohh.. one thing, rocks and plants are hardware instanced, not sure that you can bake them at all. As to performance I agree, on current average hardware even the best SSAO implementation is a performance hit, as well as most of the soft-shadows ;) This will changes as hardware evolve. For example demo of Empire Total War had SSAO, I didn't saw that big performance hit at all, maybe because of the GX2. For sure on 7x or 8x series it's much worse. I've added shadows, you can grab new demo on project's webpage: http://3dvrm.com/ssao/ "SSAO executable demo with Variance Shadow Maps" New screenshot: ![]() |
||||
|
||||
![]() Semei Member since: 10/28/2007 |
||||
|
|
||||
| This is good! Only i can't say anything about performance because sadly im cpu limited - 640x480 runs at same speed as 1280x1024 :P (i turned off v-sync) |
||||
|
||||
![]() Viik Member since: 5/1/2006 From: Kiev, Ukraine |
||||
|
|
||||
| That's because of the geometry. Currently every mesh is renderend three times. One time for depth, one time for shadow (for VSM you need to render receiver and caster) and one final for shading, and it's done for 656k triangles. Art dosn't look good that much for such amount of polys )) But demo is not about art anyway. |
||||
|
||||
![]() Semei Member since: 10/28/2007 |
||||
|
|
||||
| ahh, 625x3 is good ammount, but i should still gain something form reducing screen width, because my card have unified vertex/shader processors :P Still, this is just only driver(cpu) work could not be because of state changes so i suspect draw calls ^~ One thing thro - shadows in non-ssao mode are lighter for like 50% |
||||
|
||||
![]() knighty Member since: 10/8/2006 From: Algiers, Algeria |
||||
|
|
||||
| Beautyfull and impressive. Your SSAO is "perfectly" smooth. How are you doing it? |
||||
|
||||
![]() Viik Member since: 5/1/2006 From: Kiev, Ukraine |
||||
|
|
||||
| Trick in texture that rotates samples, it shouldn't be completely random. Samples should be semi-random. I took a sphere, devide it into 8 parts, for every part generate two random vectors. Combination of final texture is very simple, you just take 4 vectors from one hemishpere and use them for first 4 pixels, for next 4 pixels (2-nd row) you use four vectors from another hemisphere and so on. Generated SSAO will have a pattern, but it's easily blured. |
||||
|
||||
![]() Viik Member since: 5/1/2006 From: Kiev, Ukraine |
||||
|
|
||||
This is a shot from same angle before and after bluring:![]() ![]() |
||||
|
||||
![]() Viik Member since: 5/1/2006 From: Kiev, Ukraine |
||||
|
|
||||
| I have an idea how further improve current implementation. Several developers are using frame coherency to distribute SSAO calculation among several frames. Simpliest solution is to calculate SSAO using 8 samples on one frame and calculate it again for another 8 samples on second frame but now using different radius. I'll try to extend it even further, take four frames and on each frame use a different rotation texture and global sampling radius togather with different downsampling. For example on first frame I'll calculate 8 sample, with big sampling radius, on 8th times smaller size downsampled depth buffer, than another 8 with smaller radius but bigger downsampled buffer and so on. Blur will be apllied to sum of this four SSAO images. Getting less than 8 sample dosn't have much sense as the setup costs are the same for any number of samples. |
||||
|
||||
![]() skarab Member since: 4/5/2008 From: Lyon, France |
||||
|
|
||||
| Viik: yes there is a demo somewhere here if i remember correctly. looked nice but it seamed it replace the problem by another. I've tried another thing to bypass this screen-pattern problem, in my engine i use the texcoords for making the "random" vector, so the pattern is object space instead of screen space which make the whole thing more tweakable ... but yes technic really depends of what you have to shade (and if u dont need uv for other stuff its overkill ;). |
||||
|
||||
![]() Viik Member since: 5/1/2006 From: Kiev, Ukraine |
||||
|
|
||||
| Interesting, how is look like? Is it better than doing the same in screen space? In any case it can give a usefull insight. |
||||
|
||||
![]() skarab Member since: 4/5/2008 From: Lyon, France |
||||
|
|
||||
| thing is that when you move the camera you cant see the pattern cause its in object space (stay the same for all pov), no need to randomize by time... here is a sample http://img254.imageshack.us/img254/465/fakestuff02.jpg but its old thing i havent touch it since (im entirely rebuilding my editor), anyway when u move the camera its exactly like if it was precalc in a texture, you can clearly see the pattern though. |
||||
|
||||
![]() Viik Member since: 5/1/2006 From: Kiev, Ukraine |
||||
|
|
||||
| This can be pretty usefull when you calculate SSAO with small resolution or use heavy downsampled depth buffer, as in both of this cases SSAO starts shimmering as you move camera. I'll give it a try for sure. Thanks for the tip! |
||||
|
||||
![]() b_thangvn Member since: 7/15/2008 From: Santa Ana, CA, United States |
||||
|
|
||||
| Hi, Can you please pm me the 4x4 random vector please? Thank you. Edit: Can you consider releasing the code for SSAO ? I've been trying to implement the Crytek technique with no luck. Thanks. [Edited by - b_thangvn on July 30, 2009 7:36:47 PM] |
||||
|
||||
All times are ET (US)![]() |
Last Image Next Image ![]() |
|