Alchemy ambient occlusion

Hey guys, I’m trying to add this to a sample game like NSW to test it out. I just need to load the default values without the controls and it doesn’t seem to work.

I loaded this values on top:

// Number of steps in each controller (high = precise+slow)
const float var_steps = 200.0f;

// Enable ambient occlusion effect
bool ao_enable = true;
// Enable a simple Gaussian blur
bool ao_blur = false;
// Enable a depth aware Gaussian blur
bool ao_blurdepth = true;
// Show ambient occlusion raw values
bool ao_only = false;

// uniforms format: Vector3[val, min, max]

// AO radius in scene units
Vector3 ao_radius = Vector3(1.0f, 0.0f, 4.0f);
// AO intensity (in the paper/demo is divided by radius^6, this is commented out)
Vector3 ao_intensity = Vector3(0.15f, 0.0f, 2.0f);
// Radius scale adjust (not present in the paper/demo, TODO to be fixed)
Vector3 ao_projscale = Vector3(0.3f, 0.0f, 1.0f);
// Self occlusion margin
Vector3 ao_bias = Vector3(0.01f, 0.0f, 0.1f);
// Aux vars
Vector3 ao_var1 = Vector3(0.0f, -1.0f, 1.0f);
Vector3 ao_var2 = Vector3(1.0f, 0.0f, 1.0f);[/code]

Then in the setup viewport, I added this:

effectRenderPath.Append( cache.GetResource("XMLFile", "RenderPaths/DeferredSAO.xml") );
effectRenderPath.SetEnabled("SAO_copy", ao_enable);
effectRenderPath.SetEnabled("BlurGaussian", ao_blur);
effectRenderPath.SetEnabled("BlurGaussianDepth", ao_blurdepth);
effectRenderPath.shaderParameters["Radius"] = Variant(ao_radius.x);
effectRenderPath.shaderParameters["ProjScale2"] = Variant(ao_projscale.x);
effectRenderPath.shaderParameters["IntensityDivR6"] = Variant( ao_intensity.x );
effectRenderPath.shaderParameters["Bias"] = Variant(ao_bias.x);        
effectRenderPath.shaderParameters["Var1"] = Variant(ao_var1.x);
effectRenderPath.shaderParameters["Var2"] = Variant(ao_var2.x);

I’m using other effects such as Bloom, etc. Any ideas on how to get this to work? Thanks! :slight_smile:

If you’re still around lol, I had issues when using this with bloom, to solve the problem you need to append the deferredSAO BEFORE you append bloom fxaa2 etc.
Problem is then that multisampling doesnt seem to work anymore. I solved this issue by using the ForwardDepthSAO.xml renderpath. except now I seem to get random crashes every now and then :frowning: Beyone the fact that ForwardDepthSAO is causing the issue, I have no idea what is wrong!
If anyone has any thoughts it would be appreciated!