Radegast.Rendering.SceneWindow.CreateRefractionDepthTexture C# (CSharp) Method

CreateRefractionDepthTexture() public method

public CreateRefractionDepthTexture ( float waterHeight, int textureSize ) : void
waterHeight float
textureSize int
return void
        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);
        }
SceneWindow