I had some spare time and inspiration from mtracer and Arkano22 and I made yet another Screen-Space Ambient Occlusion filter.
And there is a reason why I reinvented stuff that already exists and works.
faster - code kept as simple as possible.
more natural - samples are gathered circularly making occlusion softer, also AO is not rendered on lit and bright areas. In real life Ambient Occlusion is noticeable only in shadows.
Feel free to use and modify the filter…
screenshots:
notice the difference in bright areas, where AO makes the light look dull.
This specific type of SSAO is extremely easy to use, just download the .blend, append the ‘Fx’ object into your game, and you’re ready to go, no additional setup and real easy to tweak when you find the values used for distance, power, and how dark a pixel must be for the effect to be seen.
I can get “2nd” to work if I replace
luminance = clamp(max(0.0,…
luminance = clamp(max(vec3(0.0,0.0,0.0),…
This was at line 81 in the “ssao” page in the text editor window.
I had to save and reopen.
(I’m a noob at python coding btw.)
In general there are a few implicit int to float warnings that are easy to solve martinsh, but I’m having an issue with the ‘max’ function, since the debugger says that: ‘max’: no matching overloaded function found.
On SSAO: lines 66,67,68 and the max issue on line 81 (with a float to vec3 cast issue too).
On SSAO Light: on lines 65, 66, 67, and the max issue on line 79 (with a float to vec3 cast issue too).
Hope it helps.
I could get “2 - ssao+tex” to work by making a change to ssao in the text editor at line 81.
change:
luminance = clamp(max(0.0,…
to:
luminance = clamp(max(vec3(0.0,0.0,0.0),…
That is, “max(0.0” has to be changed everywhere it appears in the line to “max(vec3(0.0,0.0,0.0)”
I couldn’t figure any way to make game mode acknowledge this change so I had to save the blend then reopen it.
I get the little black dots, too. Also a textured cube I added didn’t seem to get the effect.
I’m using an old ATI card so I don’t have high expectations.
the filter
Fragment shader failed to compile with the following errors:
ERROR: 0:81: error<#202> No matching overloaded function found max
ERROR: 0:81: error<#202> No matching overloaded function found max
ERROR: 0:81: error<#202> No matching overloaded function found max
ERROR: 0:81: error<#160> Cannot convert from ‘const float’ to ‘highgp 3-component vector of float’
ERROR: error<#273> 4 compilation errors. No code generated
This one should work also on ATI cards. Thanks guys! http://www.pasteall.org/blend/2442
Thanks to Moguri, I included mouse-look script for Blender 2.5, just replace “Mouselook.py” to “Mouselook_2.5.py” in the Python Controller. Mouselook_2.5.py works also in 2.49 but due constant failure to import bge.logic it consumes quite alot of Logic, so I included both - 2.49 and 2.5 versions.
IAmThisGuy: I have no idea why it looks like that, seems like a Z-Buffer failure…
Yeah! It works, and how it works. I can fill up the whole thing with spheres (image) and it still runs with 50 FPS. This is unbelievable! I still get some artefacts but they are way smaller and way less frequent than before (red marked)
Now I am on my dad`s PC with ATI HD 4650 and I am also seeing same weirdness. With some tweaking I have fixed these visual errors, though I have no idea what is causing it.