Example #1
0
        public void UpdateRenderTargets()
        {
            List <Geometry3D> ReflectionUpdateList = new List <Geometry3D>();
            List <Geometry3D> RefractionUpdateList = new List <Geometry3D>();
            List <Geometry3D> DepthUpdateList      = new List <Geometry3D>();

            if (ReflectionRenderTarget != null)
            {
                ReflectionUpdateList.AddRange(ReflectionRenderTarget.GeometryUpdateList);
                Render.DetachRenderTarget(ReflectionRenderTarget);
                //ReflectionRenderTarget.Dispose();
            }
            if (RefractionRenderTarget != null)
            {
                RefractionUpdateList.AddRange(RefractionRenderTarget.GeometryUpdateList);
                Render.DetachRenderTarget(RefractionRenderTarget);
                //RefractionRenderTarget.Dispose();
            }
            if (DepthMapRenderTarget != null)
            {
                DepthUpdateList.AddRange(DepthMapRenderTarget.GeometryUpdateList);
                Render.DetachRenderTarget(DepthMapRenderTarget);
                //DepthMapRenderTarget.Dispose();
            }


            Settings = FileManager.MasteryFile.Settings;

            PropStructureContainer = new WorldPropStructureContainer(Render);

            List <Geometry3D> PropBatches = PropStructureContainer.GetGeometries(-1);

            RenderNode.AttachRange(PropBatches);
            ReflectionNode.AttachRange(PropBatches);
            RefractionNode.AttachRange(PropBatches);
            PropNode.AttachRange(PropBatches);

            ReflectionRenderTarget = new SceneRenderTarget("ReflectionMap", ReflectionNode, Render.Graphics, Render.Camera.Position, Settings.CameraClosePlane, Settings.CameraFarPlane, Settings.WaterReflectionPlaneDirection, Settings.WaterReflectionResolutionX, Settings.WaterReflectionResolutionY, SceneRenderTarget.RenderType.SingleColor);
            RefractionRenderTarget = new SceneRenderTarget("RefractionMap", RefractionNode, Render.Graphics, Render.Camera.Position, Settings.CameraClosePlane, Settings.CameraFarPlane, Settings.WaterRefractionPlaneDirection, Settings.WaterReflectionResolutionX, Settings.WaterReflectionResolutionY, SceneRenderTarget.RenderType.SingleColor);
            DepthMapRenderTarget   = new SceneRenderTarget("DepthMap", RefractionNode, Render.Graphics, Render.Camera.Position, Settings.CameraClosePlane, Settings.CameraFarPlane, Settings.WaterRefractionPlaneDirection, Settings.WaterReflectionResolutionX, Settings.WaterReflectionResolutionY, SceneRenderTarget.RenderType.SingleDepth);


            FromBelowDepthTarget = new SceneRenderTarget("DepthMap", RefractionNode, Render.Graphics, new Vector3(), Settings.FromBelowClosePlane, Settings.FromBelowFarPlane, 0,
                                                         Settings.FromBelowResolutionX, Settings.FromBelowResolutionY, SceneRenderTarget.RenderType.SingleDepth, Settings.ChunkSize, Settings.ChunkSize);


            ReflectionRenderTarget.ClipOffset = Settings.ClipOffset;
            RefractionRenderTarget.ClipOffset = Settings.ClipOffset;
            DepthMapRenderTarget.ClipOffset   = Settings.ClipOffset;

            FromBelowDepthTarget.DebugTextureName = "SceneColorDebug";
            //DepthMapRenderTarget.DebugTextureName = "SceneDepthDebug";

            Render.AddRenderTarget(ReflectionRenderTarget);
            Render.AddRenderTarget(RefractionRenderTarget);
            Render.AddRenderTarget(DepthMapRenderTarget);
            Render.AddRenderTarget(FromBelowDepthTarget);

            ReflectionRenderTarget.AttachRange(ReflectionUpdateList);
            RefractionRenderTarget.AttachRange(RefractionUpdateList);
            DepthMapRenderTarget.AttachRange(DepthUpdateList);
        }