private void DrawRefractionMap(GameTime gameTime, ref Matrix ViewMatrix, ref Matrix ProjectionMatrix, Light SceneLight, Camera CurrentCam) { Vector4 planeCoefficients = new Vector4(ReflectNormalDirection, Elevation); Matrix camMatrix = ViewMatrix * ProjectionMatrix; Matrix invCamMatrix = Matrix.Invert(camMatrix); invCamMatrix = Matrix.Transpose(invCamMatrix); planeCoefficients = Vector4.Transform(planeCoefficients, invCamMatrix); Plane RefractionClipPlane = new Plane(planeCoefficients); Device.ClipPlanes[0].Plane = RefractionClipPlane; Device.ClipPlanes[0].IsEnabled = true; Device.SetRenderTarget(0, RefractionRenderTarg); Device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1.0f, 0); // Anything in this section will have refraction in water if (SceneTerrain != null) { SceneTerrain.Draw(gameTime, ref ViewMatrix, ref ProjectionMatrix, SceneLight, CurrentCam); } if (game != null) { game.DrawAllEntities(gameTime, ref ViewMatrix, false, Elevation); } //Device.ResolveRenderTarget(0); //Device.Re Device.SetRenderTarget(0, null); RefractionMap = RefractionRenderTarg.GetTexture(); Device.ClipPlanes[0].IsEnabled = false; //RefractionMap.Save("refractionmap.jpg", ImageFileFormat.Jpg); }