public void CreateRefractionDepthTexture(float waterHeight, int textureSize)
{
GL.Viewport(0, 0, textureSize, textureSize);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.LoadIdentity();
Camera.LookAt();
GL.PushMatrix();
if (Camera.RenderPosition.Z > waterHeight)
{
GL.Enable(EnableCap.ClipPlane0);
GL.ClipPlane(ClipPlaneName.ClipPlane0, BelowWaterPlane);
terrain.Render(RenderPass.Simple, 0, this, lastFrameTime);
GL.Disable(EnableCap.ClipPlane0);
}
GL.PopMatrix();
GL.BindTexture(TextureTarget.Texture2D, refractionTexture);
GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, 0, 0, textureSize, textureSize);
GL.BindTexture(TextureTarget.Texture2D, depthTexture);
GL.CopyTexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.DepthComponent, 0, 0, textureSize, textureSize, 0);
}