I see lots of numbers in Ambient Occlusion definitions file (AO.xml) for several games, but most of them use different and clueless combinations. How do I create Ambient Occlusion profiles for games not yet supported by RadeonPro? Is it possible?
This question is marked "community wiki".
asked Jan 08 at 20:00
Yes, it is possible (with a few exceptions)
Quoting myself from What is Ambient Occlusion?
RadeonPro uses some flags to capture the Z-buffer while dealing with the graphics pipeline. A typical Ambient Occlusion profile looks like this:
<File name="Fifa 2013" exe="fifa13.exe" flags="d3d9:1:0x00000000" params="" />
Breaking it down in pieces, we have:
name="Fifa 2013" ==> the human readable game title
exe="fifa13.exe" ==> the target executable for this AO profile
flags="d3d9:1:0x00000000" ==> the API, the Z-buffer index to be used and the bit flags, separated by ":". In this example, the API is D3D9, the Z-buffer index is 0 and bit flags are 0x00000000
params="" ==> optional parameters (not used in FIFA13 profile)
The name and exe parameters are self-explanatory. As you may already guessed, the flags parameters are the heart of Ambient Occlusion detection. The API can be D3D9, D3D10 or D3D11 (D3D8 and previous DX versions and OpenGL are not currently supported). A game engine can hold multiple Z-buffers for several tasks, first of all we need to find the correct index. Currently it's a trial and error task, but luckily most games use the first (index=0) Z-buffer (a simple debug tool is being developed to list Z-buffers created by the game engine so you'll be able to know how many indices are available to test). The FIFA 13 profile uses default bit flags (0x00000000)
If you open the Ambient Occlusion definitions file (AO.xml) you'll notice that several profiles use the same bit flags as FIFA 13 profile, meaning you can add a new profile using the same flags and just be lucky :) Unfortunately, some games need more hard work to get the Z-buffer detected, as Left 4 Dead 2 listed below:
<File name="Left 4 Dead 2" exe="left4dead2.exe" flags="d3d9:0:0xA0138041" params="nearZ=1,farZ=3000,firstI=1,lastI=2" />
The flags for L4D2 profile are much more complex and it includes some extra parameters as well, they are all needed to make Ambient Occlusion work on that game. Let's begin with the optional parameters: params="nearZ=1,farZ=3000,firstI=1,lastI=2"
nearZ=1 and farZ=3000 ==> these variable help during depth buffer sampling, nearZ is usually 1, farZ value vary depending on engine.
nearZ indicates how far from the view camera the Z-buffer will start to be sampled. A value of 1 means the Z-buffer is sampled right from the start of view camera. A higher value may help on games with lots of smoke/fog (like Alan Wake) so the ambient occlusion shadows don't appear in front of them.
farZ is set at 1000 if omitted, its value must be increased when the ambient occlusion shadows are too strong, creating an un-natural look. Recommended value for farZ starts at 1000 and can be set up to 10000. Greater values make AO shadows look more "soft".
firstI indicates at which step the Z-buffer will be captured, its value starts at 0. A Z-buffer can be cleared multiple times by the game engine, in case of L4D2 profile the firstI=1 indicates that Z-buffer must be captured at second clear step (firstI=0 would mean first step)
The bit flags, 0xA0138041, are a combination of values from 0 up to (2^32)-1 (0xFFFFFFFF) described on table below:
Obs: values with (*) will be documented soon.