void CreateReflectionTexture()
{
DestroyReflectionTexture();
Vec2i textureSize = GetRequiredReflectionTextureSize();
//create render texture
string textureName = TextureManager.Instance.GetUniqueName( "WaterPlaneReflection" );
bool hdr = RendererWorld.Instance.DefaultViewport.GetCompositorInstance( "HDR" ) != null;
reflectionTexture = TextureManager.Instance.Create( textureName, Texture.Type.Type2D,
textureSize, 1, 0, hdr ? PixelFormat.Float16RGB : PixelFormat.R8G8B8,
Texture.Usage.RenderTarget );
reflectionRenderTexture = reflectionTexture.GetBuffer().GetRenderTarget();
//create camera
reflectionCamera = SceneManager.Instance.CreateCamera();
reflectionCamera.AllowFrustumTestMode = true;
//add viewport
reflectionViewport = reflectionRenderTexture.AddViewport( reflectionCamera );
reflectionViewport.ShadowsEnabled = false;
reflectionViewport.MaterialScheme = MaterialSchemes.Low.ToString();
//add listener
renderTargetListener = new ReflectionRenderTargetListener( this );
reflectionRenderTexture.AddListener( renderTargetListener );
reflectionRenderTexture.AutoUpdate = Visible;
}