protected void InitTextureLighting()
{
if ( targetRenderSystem.Capabilities.TextureUnitCount < 2 )
LogManager.Instance.Write( "--WARNING--At least 2 available texture units are required for BSP dynamic lighting!" );
Texture texLight = TextureLight.CreateTexture();
textureLightMaterial = (Material)MaterialManager.Instance.GetByName( "Axiom/BspTextureLightMaterial" );
if ( textureLightMaterial == null )
{
textureLightMaterial = (Material)MaterialManager.Instance.Create( "Axiom/BspTextureLightMaterial", ResourceGroupManager.DefaultResourceGroupName );
textureLightPass = textureLightMaterial.GetTechnique( 0 ).GetPass( 0 );
// the texture light
TextureUnitState tex = textureLightPass.CreateTextureUnitState( texLight.Name );
tex.SetColorOperation( LayerBlendOperation.Modulate );
tex.ColorBlendMode.source2 = LayerBlendSource.Diffuse;
tex.SetAlphaOperation( LayerBlendOperationEx.Modulate );
tex.AlphaBlendMode.source2 = LayerBlendSource.Diffuse;
tex.TextureCoordSet = 2;
tex.SetTextureAddressingMode( TextureAddressing.Clamp );
// The geometry texture without lightmap. Use the light texture on this
// pass, the appropriate texture will be rendered at RenderTextureLighting
tex = textureLightPass.CreateTextureUnitState( texLight.Name );
tex.SetColorOperation( LayerBlendOperation.Modulate );
tex.SetAlphaOperation( LayerBlendOperationEx.Modulate );
tex.SetTextureAddressingMode( TextureAddressing.Wrap );
textureLightPass.SetSceneBlending( SceneBlendType.TransparentAlpha );
textureLightMaterial.CullingMode = CullingMode.None;
textureLightMaterial.Lighting = false;
}
else
{
textureLightPass = textureLightMaterial.GetTechnique( 0 ).GetPass( 0 );
}
}