Ambient Occlusion Caster
The AmbientOcclusionCaster is used to generate an ambient occlusion map. The occlusion values are generated by ray casting from the original geometries, which will allow preservation of occlusion detail on an otherwise heavily optimized mesh.
The quality and noise of the ambient occlusion mesh can be controlled by setting the number of rays per pixel, as well as the falloff and occlusion multiplier for the rays. Note that increasing the multisampling in the mapping image settings can be used to further reduce noise.
The following example shows how to use the IAmbientOcclusionCaster to generate an ambient occlusion map.
cpp
void GenerateAOMap( spMappingImage mapping_image )
{
// Cast AO texture data.
spAmbientOcclusionCaster cast = sg->CreateAmbientOcclusionCaster();
// The mapping image from the process.
cast->SetMappingImage( mapping_image );
cast->SetRaysPerPixel( 256 );
cast->SetOutputChannels( 1 ); // 1 channel
cast->SetOutputChannelBitDepth( 8 ); // 8 bits per channel
cast->SetOutputFilePath( "ao_out.png" );
cast->RunProcessing();
}
csharp
void GenerateAOMap(spMappingImage mapping_image)
{
// Cast AO texture data.
spAmbientOcclusionCaster cast = sg.CreateAmbientOcclusionCaster();
// The mapping image from the process.
cast.SetMappingImage(mapping_image);
cast.SetRaysPerPixel(256);
cast.SetOutputChannels(1); // 1 channel
cast.SetOutputChannelBitDepth(8); // 8 bits per channel
cast.SetOutputFilePath("ao_out.png");
cast.RunProcessing();
}
python
def GenerateAOMap( mapping_image ):
# Cast AO texture data.
cast = sg.CreateAmbientOcclusionCaster()
# The mapping image from the process.
cast.SetMappingImage( mapping_image )
cast.SetRaysPerPixel( 256 )
cast.SetOutputChannels( 1 ) # 1 channel
cast.SetOutputChannelBitDepth( 8 ) # 8 bits per channel
cast.SetOutputFilePath( "ao_out.png" )
cast.RunProcessing()