Ejemplo n.º 1
0
        //bool FrameCycle = false;

        public TerrainWaterContainer(RenderManager RenderManager, TerrainGeometryContainer TerrainGeometry, Node3D ReflectionNode, Node3D RefractionNode, Node3D PropNode, WorldFile File, SettingsContainer Settings, Vector3 Pos, SceneRenderTarget ReflectionTarget, SceneRenderTarget RefractionTarget, SceneRenderTarget DepthTarget, SceneRenderTarget FromBelowTarget)
        {
            WorldFile     = File;
            WorldSettings = Settings;
            Terrain       = TerrainGeometry;
            Name          = "Water: " + File.FileName;
            Position      = Pos;

            ReflectionRenderTarget = ReflectionTarget;
            RefractionRenderTarget = RefractionTarget;
            DepthMapRenderTarget   = DepthTarget;

            WaterData0 = new Texture2D(RenderManager.Graphics, WorldFile.FlowXMap.GetLength(0), WorldFile.FlowXMap.GetLength(1));
            WaterData1 = new Texture2D(RenderManager.Graphics, WorldFile.WaterMap.GetLength(0), WorldFile.WaterMap.GetLength(1), false, SurfaceFormat.Alpha8);

            WaterColorData0 = new Texture2D(RenderManager.Graphics, WorldFile.WaterColorR.GetLength(0), WorldFile.WaterColorR.GetLength(1));
            WaterColorData1 = new Texture2D(RenderManager.Graphics, WorldFile.WaterNormalMap.GetLength(0), WorldFile.WaterNormalMap.GetLength(1));
            //FoamDataMap0 = new Texture2D(RenderManager.Graphics, WorldFile.FoamRampMap0.GetLength(0), WorldFile.FoamRampMap0.GetLength(1));
            WaveData0 = new Texture2D(RenderManager.Graphics, WorldFile.WaveHeightMap.GetLength(0), WorldFile.WaveHeightMap.GetLength(1));

            InitializeGeometry(RenderManager);
            ReflectionRenderTarget.Attach(Geom);
            RefractionRenderTarget.Attach(Geom);
            DepthMapRenderTarget.Attach(Geom);

            //Depth Input
            FromBelowDepth = FromBelowTarget;

            //DepthTarget0 = new RenderTarget2D(RenderManager.Graphics, 1025, 1025, false, SurfaceFormat.Single, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.PreserveContents);
            //DepthTarget1 = new RenderTarget2D(RenderManager.Graphics, 1025, 1025, false, SurfaceFormat.Single, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.PreserveContents);

            //SetHeight = new TextureTask(Name + "SetHeight", TaskType.FillFloat, TaskStage.PreRenderTarget, TaskUsage.FrameLimit,TaskSwitchType.PingPongOut);
            //SetHeight.AddParameter(FloatParameter.ColorFloat, WorldFile.TerrainDepth / Settings.FromBelowFarPlane);
            //SetHeight.SetRenderTarget(DepthTarget0, true);
            //SetHeight.SetRenderTarget(DepthTarget1, false);
            //SetHeight.FrameLimit = 2;

            //Begin PingPong
            //Depth
            //MergeDepth = new TextureTask("MergeDepth", TaskType.MergeMinFloat, TaskStage.PreOffScreenTarget, TaskUsage.Preserve, TaskSwitchType.PingPongIn);
            // MergeDepth.AddParameter(TextureParameter.InputTexture, FromBelowDepth.RenderTarget);

            //MergeDepth.AddParameter(TextureParameter.InputTexture2, (Texture2D)DepthTarget0, true);
            //MergeDepth.AddParameter(TextureParameter.InputTexture2, (Texture2D)DepthTarget1, false);
            //Current Frame Texture
            //MergeDepth.SetRenderTarget(DepthTarget1, true);
            //MergeDepth.SetRenderTarget(DepthTarget0, false);

            //WaterSimulation = new OffScreenTarget(RenderManager.Graphics, RenderManager.Shaders["WaterSimulation"].Clone());
            //NormalGenerator = new OffScreenTarget(RenderManager.Graphics, RenderManager.Shaders["WaterSimulation"].Clone());
            //NormalMap = new RenderTarget2D(RenderManager.Graphics, 1025, 1025);

            //FromBelowDepth.Attach(MergeDepth);
            //WaterSimulation.Attach(NormalGenerator.Shader);
            //WaterSimulation.Attach(Geom.Shader);
            WaterHeightMap = new Texture2D(RenderManager.Graphics, WorldFile.WaterHeightMap.GetLength(0), WorldFile.WaterHeightMap.GetLength(1), false, SurfaceFormat.Color);
            WaterClipMap   = new Texture2D(RenderManager.Graphics, WorldFile.WaterHeightMap.GetLength(0), WorldFile.WaterHeightMap.GetLength(1), false, SurfaceFormat.Color);
            //MergeDepth.DebugTextureName = "SceneWaterReflectionDebug";

            //NormalGenerator.Attach(Geom.Shader);
            //RenderManager.AddTextureModificationTask(SetHeight);
            //RenderManager.AddTextureModificationTask(MergeDepth);

            //RenderManager.AddOffScreenTarget(WaterSimulation);
            //RenderManager.AddOffScreenTarget(NormalGenerator);
        }
Ejemplo n.º 2
0
        public TerrainDeformableCoverContainer(RenderManager RenderManager, WorldFile File, TerrainGeometryContainer TerrainGeometry, SettingsContainer WorldSettings, SceneRenderTarget FromBelowDepth)
        {
            WorldFile = File;
            Name      = "Cover: " + File.FileName;
            InitializeGeometry(RenderManager);

            FromBelowDepthTarget = FromBelowDepth;

            TerrainBottom = TerrainGeometry;

            DisplacementTarget = new RenderTarget2D(RenderManager.Graphics, FromBelowDepthTarget.GetWidth(), FromBelowDepthTarget.GetHeight(), false, SurfaceFormat.Single, DepthFormat.Depth24Stencil8);

            DisplacementSimulator = new OffScreenTarget("Displacement", RenderManager.Graphics, RenderManager.Shaders["TerrainCoverDisplacement"].Clone());

            DisplacementSimulator.SetTargetPing(DisplacementTarget);

            DisplacementSimulator.AttachOutPut("HeightMap", Geom.Shader);
            DisplacementSimulator.AddParameter("HeightMap", TerrainGeometry.HeightMap);
            DisplacementSimulator.AddParameter("FarPlane", WorldSettings.FromBelowFarPlane);
            DisplacementSimulator.AddParameter("DepthOffset", WorldFile.TerrainDepth);

            DisplacementSimulator.DebugTextureName = "SceneDepthDebug";

            FromBelowDepthTarget.Attach(DisplacementSimulator.Shader);
            RenderManager.AddOffScreenTarget(DisplacementSimulator);
        }