Пример #1
0
        public void DrawRefraction(GameTime gameTime, RenderRefractionHandler render)
        {
            // Create our Refraction Plane
            Microsoft.Xna.Framework.Plane refractionPlane = Utilitys.CreatePlane(WaterHeight + 20.0f, Vector3.Down, Camera.View, Camera.Projection, false);

            // Setup the graphics Device
            GraphicsDevice.SetRenderTarget(rtRefraction);             // <- render to our RT

            // Clear the back buffer
            GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0);

            render.Invoke(gameTime);

            // Remove our render target from our device
            GraphicsDevice.SetRenderTarget(null);

            // Snag our Texture from our RenderTarget
            refractionMap = rtRefraction;

            // For diag just save it to disk
            //refractionMap.Save(AppDomain.CurrentDomain.BaseDirectory + @"\refractionMap.jpg", ImageFileFormat.Jpg);
        }
Пример #2
0
        public void DrawReflection(GameTime gameTime, RenderReflectionHandler render)
        {
            Microsoft.Xna.Framework.Plane reflectionPlane = Utilitys.CreatePlane(WaterHeight - 0.5f, Vector3.Down, ReflectionViewMatrix, Camera.Projection, true);

            // Setup the Graphics Device
            GraphicsDevice.SetRenderTarget(rtReflection);

            // Clear the back buffer
            GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0);

            // Draw anything that should reflect onto the water
            render.Invoke(ReflectionViewMatrix, Camera.Position, gameTime);

            // Remove our render target from our device
            GraphicsDevice.SetRenderTarget(null);

            // Snag our Texture from our RenderTarget
            reflectionMap = rtReflection;

            // For diag just save it to disk
            //reflectionMap.Save(AppDomain.CurrentDomain.BaseDirectory + @"\reflectionMap.jpg", ImageFileFormat.Jpg);
        }