Hi,
After days of tweaking, testing, writing shaders… i finally got an SSAO effect working in Unity free.
For now, the result is not perfect, there is halo, some artifact at the edge of the screen, but it looks good.
I’m currently using a modified version of IndieEffects, and performances are not good currently (drop from 70 to 25 fps),
so it need some optimizations.
There is some limitations too : max far range is 50 (but i found a trick), there is a little banding, and a bug with skybox (for now).
The method i use is Disk to Disk SSAO, which is an hybrid method between SSAO,HBAO and Disk AO.
The advantage over baking it is it’s in realtime. Performances are as i said, for now, not very good (because it uses ReadPixels).
PS : Someone has an idea on how i can have a 16 bit depth buffer in Unity free ?
Because for now i only have an access to a 8bit*2 depth buffer so only 0-512 range.
Encode depth (32 bit float) into an ARGB32 texture before you read it back instead of just writing it to R. Unity has builtin functions for it if you look into UnityCG.cginc. Then decompress it on the CPU and voila 32 bit depth. Not that it’s gonna be fast
Are you sure i will have a 32 bit depth ? Because i think it’s rather 8bit * 4 channel = 0-255 range * 4 = 0-1024 range = 10 bit.
16 bit have a 0-65535 range.
Well, if you store in linearly like that, yeah. You’re basically converting the float to an integer, which is not want you want to do.
Instead, use these functions to encode and decode the depth. They’re taken straight from UnityCG.cginc, so you can just call EncodeFloatRGBA right away (naturally, presuming you’re including UnityCG). Then just decode that into a float on the CPU using the decode function.
I’m currently using EncodeDepthNormals , so 1 texture for both depth and normals. So it’s 16 bit for each ?
The problem i have for now is if i increase the far clip range over 50 (like 100 or 200), the ao effect is only visible for far objects but near doesn’t have any ao on it.
Based on what you say, it would not be a problem of depth precision.
Oh right, Unity’s depth/normal texture is an ARGB32. Is there any way in Unity free to get depth into a 32 bit texture? I don’t remember the exact limitations. Is it possible to create a R32 texture and render only depth via replacement shaders? If that’s not possible, then I’m sorry I was wrong and I don’t think it’s possible to achieve greater precision in Unity free
60 fps in webplayer. System specs: CPU FX-8350, GPU GTX 780 on Windows 7
would like to get a standalone build if possible, to see performance at full resolution and highest Quallity settings
EDIT: and if you do that please disable v-sync
ASUS EP121
Intel i5 (1st Gen Sandy Bridge)
Intel HD Graphics (1st Gen Sandy Bridge)
4 GB RAM
64 MB Dedicated Video
Windows 8.1 64 bit + current patches
Chrome v35