namespace Sandbox;
public class CubemapFogController
{
///
/// Adjust how quickly the cubemap blurs out at closer distances. A value of 0.0 always uses the lowest resolution MIP over the entire range, while a value of 1.0 uses the highest.
///
public float LodBias { get; set; }
///
/// The distance from the player at which the fog will start to fade in.
///
public float StartDistance { get; set; }
///
/// The distance from the player at which the fog will be at full strength.
///
public float EndDistance { get; set; }
///
/// Exponent for distance falloff. For example, 2.0 is proportional to square of distance.
///
public float FalloffExponent { get; set; }
///
/// The distance between the start of the height fog and where it is fully opaque. Setting this to 0 will disable height based blending.
///
public float HeightWidth { get; set; }
///
/// The absolute height in the map at which the height fog will start to fade in.
///
public float HeightStart { get; set; }
///
/// Exponent for height falloff. For example, 2.0 is proportional to square of distance.
///
public float HeightExponent { get; set; }
///
/// Is this cubemap fog active?
///
public bool Enabled { get; set; }
///
/// Cubemap texture to use for the fog.
///
public Texture Texture { get; set; }
///
/// Location of the fog.
///
public Transform Transform { get; set; }
///
/// Tint of the fog.
///
public Color Tint { get; set; }
internal void Write( RenderAttributes attr )
{
attr.Set( "CubeFogParams", new Vector4( StartDistance, EndDistance, LodBias, FalloffExponent ) );
attr.Set( "CubeFogParams2", new Vector4( HeightWidth, HeightStart, HeightExponent, 0.0f ) );
attr.Set( "CubeFogTransform", Matrix.FromTransform( Transform ) );
attr.Set( "CubemapFogColor", Tint );
if ( Enabled )
{
attr.Set( "CubemapFogTexture", Texture );
attr.SetCombo( "D_ENABLE_CUBEMAP_FOG", 1 );
}
else
{
attr.SetCombo( "D_ENABLE_CUBEMAP_FOG", 0 );
}
}
}