Esempio n. 1
0
        unsafe public void clearJacobianMap()
        {
            if (m_fxJacobian == null)// || mSynthesiser == null)
            {
                return;
            }


            Vector4 tr = new Vector4(0, 0, (float)m_iBuffersWidth, (float)m_iBuffersHeight);


            // save render target
            D3DProtectRenderTarget locktarget = new D3DProtectRenderTarget(true);

            // set new render target
            BRenderDevice.getDevice().SetRenderTarget(0, mJacobianMapSrf);
            BRenderDevice.getDevice().SetRenderTarget(1, mJacobianMapInverseSrf);

            savedDepthSten = BRenderDevice.getDevice().DepthStencilSurface;
            BRenderDevice.getDevice().DepthStencilSurface = m_DepthStencilSurface;


            // render
            BRenderDevice.getDevice().BeginScene();
            {
                BRenderDevice.getDevice().Clear(ClearFlags.Target, Color.Black, 1, 0);


                m_fxJacobian.Technique = m_fxJacobianClearTech;
                m_fxJacobian.SetValue(m_fxJacobianGlobalScale, mExemplar == null?0:mExemplar.mSynthParams.TextureScale);
                m_fxJacobian.SetValue(m_fxJacobianSelectedJMap, (int)mJMapPattern);
                m_fxJacobian.SetValue(m_fxJacobianViewport, tr);

                m_fxJacobian.CommitChanges();
                m_fxJacobian.Begin(FX.DoNotSaveState | FX.DoNotSaveShaderState | FX.DoNotSaveSamplerState);
                m_fxJacobian.BeginPass(0);
                m_QuadDual.render();
                m_fxJacobian.EndPass();
                m_fxJacobian.End();

                BRenderDevice.getDevice().EndScene();
            }

            m_bNeedUpdate = true;

            BRenderDevice.getDevice().DepthStencilSurface = savedDepthSten;
            savedDepthSten.Dispose();
            savedDepthSten = null;

            BRenderDevice.getDevice().SetRenderTarget(1, null);
            BRenderDevice.getDevice().SetTexture(0, null);
            locktarget.destroy();
            locktarget = null;

            //   BRenderDevice.writeTextureToFile(mJacobianMap, AppDomain.CurrentDomain.BaseDirectory + "screens\\localFrames.bmp");
            //   BRenderDevice.writeTextureToFile(mJacobianMapInverse, AppDomain.CurrentDomain.BaseDirectory + "screens\\localFramesINV.bmp");
        }
Esempio n. 2
0
        private void RenderPostProcess()
        {
            D3DDevice.Instance.Device.BeginScene();

            D3DDevice.Instance.Device.VertexFormat = CustomVertex.PositionTextured.Format;
            D3DDevice.Instance.Device.SetStreamSource(0, fullQuadVertexBuffer, 0);

            gogleViewEffect.SetValue("mainSceneTexture", auxRenderTarget);

            D3DDevice.Instance.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, fog.Color, 1.0f, 0);

            if (Player.IsSubmerged)
            {
                gogleViewEffect.Technique = "GogleView";
            }
            else
            {
                gogleViewEffect.Technique = "NoGogles";
            }

            gogleViewEffect.Begin(FX.None);
            gogleViewEffect.BeginPass(0);
            D3DDevice.Instance.Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            gogleViewEffect.EndPass();
            gogleViewEffect.End();


            RenderHUD();

            RenderFPS();
            RenderAxis();

            D3DDevice.Instance.Device.EndScene();
        }
Esempio n. 3
0
        public void DrawGoo()
        {
            float CurrTime = DXUtil.Timer(DirectXTimer.GetApplicationTime);
            float fTime    = (float)(((CurrTime % 180.0f) / 180.0f) * (2 * Math.PI));

            WorldMatrix = DirectX.Matrix.RotationYawPitchRoll((float)((CurrTime % 240) / 240 * Math.PI), 0, 0) * DirectX.Matrix.Translation(0, -45, -400);

            DirectX.Matrix WorldViewMatrix     = WorldMatrix * ViewMatrix;
            DirectX.Matrix WorldViewProjMatrix = WorldMatrix * ViewMatrix * ProjectionMatrix;

            GooEffect.SetValue("fMixTime", fTime);
            GooEffect.SetValue("WorldView", WorldViewMatrix);
            GooEffect.SetValue("WorldViewProjection", WorldViewProjMatrix);

            GameDevice.RenderState.AlphaBlendEnable = false;
            int numPasses = GooEffect.Begin(0);

            for (int i = 0; i < numPasses; i++)
            {
                GooEffect.BeginPass(i);
                GooMesh.DrawSubset(0);
                GooEffect.EndPass();
            }
            GooEffect.End();

            // Restore alpha blend setting
            GameDevice.RenderState.AlphaBlendEnable = true;
        }
Esempio n. 4
0
        private void drawPostProcess(float elapsedTime, bool activado)
        {
            //Arrancamos la escena
            D3DDevice.Instance.Device.BeginScene();

            //Cargamos para renderizar el unico modelo que tenemos, un Quad que ocupa toda la pantalla, con la textura de todo lo dibujado antes
            D3DDevice.Instance.Device.VertexFormat = CustomVertex.PositionTextured.Format;
            D3DDevice.Instance.Device.SetStreamSource(0, screenQuadVB, 0);

            //Ver si el efecto de alarma esta activado, configurar Technique del shader segun corresponda
            if (activado)
            {
                efecto.Technique = "AlarmaTechnique";
            }
            else
            {
                efecto.Technique = "DefaultTechnique";
            }

            //Cargamos parametros en el shader de Post-Procesado
            efecto.SetValue("render_target2D", renderTarget2D);
            efecto.SetValue("textura_alarma", alarmTexture.D3dTexture);
            efecto.SetValue("alarmaScaleFactor", intVaivenAlarm.update(elapsedTime));

            //Limiamos la pantalla y ejecutamos el render del shader
            D3DDevice.Instance.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            efecto.Begin(FX.None);
            efecto.BeginPass(0);
            D3DDevice.Instance.Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            efecto.EndPass();
            efecto.End();

            D3DDevice.Instance.Device.EndScene();
            D3DDevice.Instance.Device.Present();
        }
        /// <summary>
        ///     Renderizar el BoundingSphere
        /// </summary>
        public void render()
        {
            TexturesManager.Instance.clear(0);
            TexturesManager.Instance.clear(1);

            //Cargar shader si es la primera vez
            if (effect == null)
            {
                effect    = TgcShaders.Instance.VariosShader;
                technique = TgcShaders.T_POSITION_COLORED;
            }

            //Actualizar vertices de BoundingSphere solo si hubo una modificación
            if (dirtyValues)
            {
                updateValues();
                dirtyValues = false;
            }

            TgcShaders.Instance.setShaderMatrixIdentity(effect);
            D3DDevice.Instance.Device.VertexDeclaration = TgcShaders.Instance.VdecPositionColored;
            effect.Technique = technique;

            //Render con shader
            effect.Begin(0);
            effect.BeginPass(0);
            D3DDevice.Instance.Device.DrawUserPrimitives(PrimitiveType.LineList, vertices.Length / 2, vertices);
            effect.EndPass();
            effect.End();
        }
Esempio n. 6
0
        public void renderFull(int w, int h)
        {
            Vector4 v = new Vector4(0, 0, (float)w, (float)h);

            mShader.SetValue(m_fxViewport, v);
            Vector4 v2 = new Vector4(0, 0, 0, 0);

            mShader.SetValue(m_fxDestRegionCoord, v2);
            Vector4 v3 = new Vector4((float)w, (float)h, 0, 0);

            mShader.SetValue(m_fxDestRegionSize, v3);
            Vector4 v4 = new Vector4(1.0f / (float)w, 1.0f / (float)h, 0, 0);

            mShader.SetValue(m_fxInvDestRegionSize, v4);

            Viewport vp = new Viewport();

            vp.X      = 0;
            vp.Y      = 0;
            vp.Width  = w;
            vp.Height = h;
            vp.MinZ   = 0;
            vp.MaxZ   = 1;
            BRenderDevice.getDevice().Viewport = vp;

            mShader.CommitChanges();

            BRenderDevice.beginScene();
            mShader.Begin(FX.DoNotSaveState | FX.DoNotSaveShaderState | FX.DoNotSaveSamplerState);
            mShader.BeginPass(0);
            s_Quad.render();
            mShader.EndPass();
            mShader.End();
            BRenderDevice.endScene();
        }
Esempio n. 7
0
        /// <summary>
        ///     Se llama cada vez que hay que refrescar la pantalla.
        ///     Escribir aquí todo el código referido al renderizado.
        ///     Borrar todo lo que no haga falta.
        /// </summary>
        public override void Render()
        {
            if (effect != null && !effect.Disposed)
            {
                var device = D3DDevice.Instance.Device;

                PreRender();
                device.VertexFormat = CustomVertex.PositionTextured.Format;
                device.SetStreamSource(0, fullScreenQuad, 0);
                effect.Begin(FX.None);
                effect.BeginPass(0);
                device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
                effect.EndPass();
                effect.End();
                PostRender();
            }
        }
Esempio n. 8
0
        public static void RenderPostProcesado()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            // Devuelvo el render target original
            d3dDevice.SetRenderTarget(0, RenderTargetOriginal);

            // Cargo el quad
            d3dDevice.VertexFormat = CustomVertex.PositionTextured.Format;
            d3dDevice.SetStreamSource(0, ScreenQuad, 0);

            // Cargo los parametros al shader
            bool activar_efecto = (bool)GuiController.Instance.Modifiers["lluvia"];

            if (activar_efecto)
            {
                float  time         = (float)GuiController.Instance.UserVars.getValue("time");
                Random random       = new Random();
                int    randomNumber = random.Next(0, 10);

                if (time % 5 > 4 && randomNumber > 5)
                {
                    Shader.Technique = "RayoTechnique";
                }
                else
                {
                    Shader.Technique = "DefaultTechnique";
                }
            }
            else
            {
                Shader.Technique = "DefaultTechnique";
            }

            //Cargamos parametros en el shader de Post-Procesado
            Shader.SetValue("render_target2D", RenderTargetPostprocesado);
            Shader.SetValue("scaleFactor", intVaivenOscurecer.update());
            // Hago el postprocesado propiamente dicho
            d3dDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            Shader.Begin(FX.None);
            Shader.BeginPass(0);
            d3dDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            Shader.EndPass();
            Shader.End();
        }
Esempio n. 9
0
        /// <summary>
        ///     Se toma todo lo dibujado antes, que se guardo en una textura, y se le aplica un shader para distorsionar la imagen
        /// </summary>
        private void drawPostProcess(Microsoft.DirectX.Direct3D.Device d3dDevice)
        {
            //Arrancamos la escena
            d3dDevice.BeginScene();

            //Cargamos para renderizar el unico modelo que tenemos, un Quad que ocupa toda la pantalla, con la textura de todo lo dibujado antes
            d3dDevice.VertexFormat = CustomVertex.PositionTextured.Format;
            d3dDevice.SetStreamSource(0, screenQuadVB, 0);

            //Ver si el efecto de oscurecer esta activado, configurar Technique del shader segun corresponda

            effect.Technique = "RainTechnique";

            if (!presentacion && lloviendo)
            {
                effect.Technique = "RainTechnique";
            }
            else
            {
                effect.Technique = "DefaultTechnique";
            }

            //Cargamos parametros en el shader de Post-Procesado
            effect.SetValue("render_target2D", renderTarget2D);
            effect.SetValue("textura_alarma", lluviaTexture.D3dTexture);
            effect.SetValue("time", this.ElapsedTime);

            //Limiamos la pantalla y ejecutamos el render del shader
            d3dDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            effect.Begin(FX.None);
            effect.BeginPass(0);
            d3dDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            effect.EndPass();
            effect.End();

            //Terminamos el renderizado de la escena
            d3dDevice.EndScene();
            d3dDevice.Present();
        }
Esempio n. 10
0
        public void Draw(DX.Matrix transform, int pickValue = 0)
        {
            D3D.Device device = Renderer.current.device;
            device.VertexDeclaration = Renderer.current.vtxDeclaration;
            device.SetStreamSource(0, vertexBuffer, 0);
            Renderer.current.SetValues(usedEffect, transform);
            usedEffect.SetValue(Renderer.EffectHandles.PickColor, Renderer.pickIndexToColor(pickValue));

            foreach (Subset sub in subsets)
            {
                float shiftTValue = sub.shiftT >= 11 ? (int)1 << (0x10 - sub.shiftT) : 1.0f / (1 << sub.shiftT);
                float shiftSValue = sub.shiftS >= 11 ? (int)1 << (0x10 - sub.shiftS) : 1.0f / (1 << sub.shiftS);
                usedEffect.SetValue(Renderer.EffectHandles.ShiftMul, new DX.Vector4(shiftTValue / (float)sub.texture.width, shiftSValue / (float)sub.texture.height, 0, 0));
                usedEffect.SetValue(Renderer.EffectHandles.Texture0, sub.texture0);
                usedEffect.SetValue(Renderer.EffectHandles.Texture1, sub.texture1);
                usedEffect.Begin(D3D.FX.None);
                usedEffect.BeginPass(0);
                device.Indices = sub.indexBuffer;
                device.DrawIndexedPrimitives(D3D.PrimitiveType.TriangleList, 0, 0, vertices.Length, 0, sub.indices.Length / 3);
                usedEffect.EndPass();
                usedEffect.End();
            }
        }
Esempio n. 11
0
        public void render2D()
        {
            var device = D3DDevice.Instance.Device;

            device.DepthStencilSurface = pOldDS;
            device.SetRenderTarget(0, pOldRT);

            var oldFillMode = D3DDevice.Instance.Device.RenderState.FillMode;

            D3DDevice.Instance.Device.RenderState.FillMode = FillMode.Solid;
            device.BeginScene();

            EfectoRender2D.Technique = "Sharpen";
            if (Env.Input.keyDown(Key.F6))
            {
                EfectoRender2D.Technique = "Copy";
            }
            device.VertexFormat = CustomVertex.PositionTextured.Format;
            device.SetStreamSource(0, sharpenVBV3D, 0);
            EfectoRender2D.SetValue("g_RenderTarget", Text);

            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            EfectoRender2D.Begin(FX.None);
            EfectoRender2D.BeginPass(0);
            device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            EfectoRender2D.EndPass();
            EfectoRender2D.End();
            device.EndScene();

            device.BeginScene();
            Env.RenderizaAxis();
            Env.RenderizaFPS();
            device.EndScene();

            device.Present();
            D3DDevice.Instance.Device.RenderState.FillMode = oldFillMode;
        }
Esempio n. 12
0
        // renderiza la scena en el modo GAME
        public void RenderScene()
        {
            ClearTextures();

            var device = D3DDevice.Instance.Device;

            effect.Technique = "DefaultTechnique";
            effect.SetValue("time", time);

            // guardo el Render target anterior y seteo la textura como render target
            var pOldRT = device.GetRenderTarget(0);
            var pSurf  = g_pRenderTarget.GetSurfaceLevel(0);

            device.SetRenderTarget(0, pSurf);
            // hago lo mismo con el depthbuffer, necesito el que no tiene multisampling
            var pOldDS = device.DepthStencilSurface;

            device.DepthStencilSurface = g_pDepthStencil;



            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, SHIP.colisiona ? Color.Yellow : Color.Black, 1.0f, 0);
            device.BeginScene();
            effect.SetValue("eyePosition", TGCVector3.Vector3ToFloat4Array(Camara.Position));

            ESCENA.render(effect);
            sound.render(effect, ESCENA, SHIP);
            SHIP.Render(effect);

            // -------------------------------------
            device.EndScene();
            pSurf.Dispose();

            // Ultima pasada vertical va sobre la pantalla pp dicha
            device.SetRenderTarget(0, pOldRT);
            device.DepthStencilSurface = g_pDepthStencilOld;
            device.BeginScene();
            effect.Technique = motion_blur ? "FrameMotionBlur" : "FrameCopy";

            device.VertexFormat = CustomVertex.PositionTextured.Format;
            device.SetStreamSource(0, g_pVBV3D, 0);
            effect.SetValue("g_RenderTarget", g_pRenderTarget);
            effect.SetValue("g_RenderTarget2", g_pRenderTarget2);
            effect.SetValue("g_RenderTarget3", g_pRenderTarget3);
            effect.SetValue("g_RenderTarget4", g_pRenderTarget4);
            effect.SetValue("g_RenderTarget5", g_pRenderTarget5);
            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            effect.Begin(FX.None);
            effect.BeginPass(0);
            device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            effect.EndPass();
            effect.End();

            // dibujo el scoreboard, tiempo, vidas, etc (y fps)
            RenderHUD();

            device.EndScene();
            device.Present();

            ftime += ElapsedTime;
            if (ftime > 0.02f)
            {
                ftime = 0;
                var aux = g_pRenderTarget5;
                g_pRenderTarget5 = g_pRenderTarget4;
                g_pRenderTarget4 = g_pRenderTarget3;
                g_pRenderTarget3 = g_pRenderTarget2;
                g_pRenderTarget2 = g_pRenderTarget;
                g_pRenderTarget  = aux;
            }
        }
Esempio n. 13
0
        public override void Render()
        {
            ClearTextures();

            var device = D3DDevice.Instance.Device;

            effect.Technique = "DefaultTechnique";

            // guardo el Render target anterior y seteo la textura como render target
            var pOldRT = device.GetRenderTarget(0);
            var pSurf  = g_pRenderTarget.GetSurfaceLevel(0);

            device.SetRenderTarget(0, pSurf);
            // hago lo mismo con el depthbuffer, necesito el que no tiene multisampling
            var pOldDS = device.DepthStencilSurface;

            device.DepthStencilSurface = g_pDepthStencil;

            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);

            device.BeginScene();

            // -------------------------------------
            //Renderizar terreno
            terrain.Effect    = effect;
            terrain.Technique = "DefaultTechnique";
            terrain.Render();
            // skybox
            skyBox.Render();
            //Renderizar pista
            circuito.render(effect);
            //Renderizar auto
            car.Effect    = effect;
            car.Technique = "DefaultTechnique";
            car.Render();
            // -------------------------------------

            device.EndScene();

            pSurf.Dispose();

            // Ultima pasada vertical va sobre la pantalla pp dicha
            device.SetRenderTarget(0, pOldRT);
            device.DepthStencilSurface = g_pDepthStencilOld;
            device.BeginScene();

            effect.Technique    = "FrameMotionBlur";
            device.VertexFormat = CustomVertex.PositionTextured.Format;
            device.SetStreamSource(0, g_pVBV3D, 0);
            effect.SetValue("g_RenderTarget", g_pRenderTarget);
            effect.SetValue("g_RenderTarget2", g_pRenderTarget2);
            effect.SetValue("g_RenderTarget3", g_pRenderTarget3);
            effect.SetValue("g_RenderTarget4", g_pRenderTarget4);
            effect.SetValue("g_RenderTarget5", g_pRenderTarget5);
            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            effect.Begin(FX.None);
            effect.BeginPass(0);
            device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            effect.EndPass();
            effect.End();

            //TgcDrawText.Instance.drawText("Pos: " + this.Camara.Position, 0, 0, Color.Yellow);
            //TgcDrawText.Instance.drawText("Look At: " + CamaraManager.Instance.CurrentCamera.getLookAt(), 500, 0, Color.Yellow);

            if (circuito.en_ruta)
            {
                DrawText.drawText("Tramo:" + circuito.pos_en_ruta, 0, 15, Color.Yellow);
            }

            //TgcDrawText.Instance.drawText("dist_cam:" + dist_cam + "defY" + desf.Y, 0, 0, Color.Yellow);
            //TgcDrawText.Instance.drawText("vel:" + vel, 0, 0, Color.Yellow);

            RenderFPS();
            RenderAxis();
            device.EndScene();
            device.Present();

            ftime += ElapsedTime;
            if (ftime > 0.03f)
            {
                ftime = 0;
                var aux = g_pRenderTarget5;
                g_pRenderTarget5 = g_pRenderTarget4;
                g_pRenderTarget4 = g_pRenderTarget3;
                g_pRenderTarget3 = g_pRenderTarget2;
                g_pRenderTarget2 = g_pRenderTarget;
                g_pRenderTarget  = aux;
            }
        }
Esempio n. 14
0
        public override void Render()
        {
            PreRender();

            var lightPosition = lightPositionModifier.Value;

            //Cargar variables de shader
            effect.SetValue("fvLightPosition", TGCVector3.TGCVector3ToFloat3Array(lightPosition));
            effect.SetValue("fvEyePosition", TGCVector3.TGCVector3ToFloat3Array(Camera.Position));
            effect.SetValue("k_la", ambientModifier.Value);
            effect.SetValue("k_ld", diffuseModifier.Value);
            effect.SetValue("k_ls", specularModifier.Value);
            effect.SetValue("fSpecularPower", specularPowerModifier.Value);

            D3DDevice.Instance.Device.EndScene();

            // dibujo la escena una textura
            effect.Technique = "DefaultTechnique";
            // guardo el Render target anterior y seteo la textura como render target
            var pOldRT = D3DDevice.Instance.Device.GetRenderTarget(0);
            var pSurf  = g_pRenderTarget.GetSurfaceLevel(0);

            D3DDevice.Instance.Device.SetRenderTarget(0, pSurf);
            // hago lo mismo con el depthbuffer, necesito el que no tiene multisampling
            var pOldDS = D3DDevice.Instance.Device.DepthStencilSurface;

            // Probar de comentar esta linea, para ver como se produce el fallo en el ztest
            // por no soportar usualmente el multisampling en el render to texture.
            D3DDevice.Instance.Device.DepthStencilSurface = g_pDepthStencil;

            D3DDevice.Instance.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            D3DDevice.Instance.Device.BeginScene();
            foreach (var instance in instances)
            {
                instance.Technique = "DefaultTechnique";
                instance.Transform = TGCMatrix.Scaling(instance.Scale)
                                     * TGCMatrix.RotationYawPitchRoll(instance.Rotation.X, instance.Rotation.Y, instance.Rotation.Z)
                                     * TGCMatrix.Translation(instance.Position);
                instance.Render();
            }
            D3DDevice.Instance.Device.EndScene();
            //TextureLoader.Save("scene.bmp", ImageFileFormat.Bmp, g_pRenderTarget);

            // genero el normal map:
            pSurf = g_pNormals.GetSurfaceLevel(0);
            D3DDevice.Instance.Device.SetRenderTarget(0, pSurf);
            D3DDevice.Instance.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            D3DDevice.Instance.Device.BeginScene();
            foreach (var instance in instances)
            {
                instance.Technique = "NormalMap";
                instance.Transform = TGCMatrix.Scaling(instance.Scale)
                                     * TGCMatrix.RotationYawPitchRoll(instance.Rotation.X, instance.Rotation.Y, instance.Rotation.Z)
                                     * TGCMatrix.Translation(instance.Position);
                instance.Render();
            }

            D3DDevice.Instance.Device.EndScene();
            // restuaro el render target y el stencil
            D3DDevice.Instance.Device.DepthStencilSurface = pOldDS;
            D3DDevice.Instance.Device.SetRenderTarget(0, pOldRT);
            //TextureLoader.Save("normal.bmp", ImageFileFormat.Bmp, g_pNormals);

            // dibujo el quad pp dicho :
            D3DDevice.Instance.Device.BeginScene();
            effect.Technique = blurActivatedModifier.Value ? "CopyScreen" : "EdgeDetect";
            D3DDevice.Instance.Device.VertexFormat = CustomVertex.PositionTextured.Format;
            D3DDevice.Instance.Device.SetStreamSource(0, g_pVBV3D, 0);
            effect.SetValue("g_Normals", g_pNormals);
            effect.SetValue("g_RenderTarget", g_pRenderTarget);

            D3DDevice.Instance.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            effect.Begin(FX.None);
            effect.BeginPass(0);
            D3DDevice.Instance.Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            effect.EndPass();
            effect.End();

            RenderFPS();
            RenderAxis();
            D3DDevice.Instance.Device.EndScene();
            D3DDevice.Instance.Device.Present();
        }
Esempio n. 15
0
        /// <summary>
        /// Renders the highlighted terrain vertices.
        /// </summary>
        public void RenderVertices()
        {
            if (_buffers.VertexBuffer_Vertices != null && _page.TerrainPatch.NumVertices < 75 * 75)
            {
                if (_page.TerrainPatch.RefreshVertices || _buffers.VertexBuffer_Vertices == null)
                {
                    RefreshVertexBuffer_Vertices();
                    _page.TerrainPatch.RefreshVertices = false;
                }

                Matrix world = _viewport.Camera.WorldIdentity;
                world.Translate(_viewport.Camera.Offset + new Vector3(0f, 0.0001f, 0f));
                _viewport.Device.RenderState.FillMode = D3D.FillMode.Solid;
                _viewport.Device.SetStreamSource(0, _buffers.VertexBuffer_Vertices, 0);

                if (_vertexShaderVersion >= new Version(1, 1) &&
                    _viewport.Effects.Count > 1 && _viewport.Effects[1] != null)
                {
                    D3D.Effect effect = ((Effect)_viewport.Effects[1]).DXEffect;
                    int        passes;

                    // Set Effect technique
                    effect.Technique = effect.GetTechnique("TVertices");

                    // Set camera matrices
                    effect.SetValue("World", world);
                    effect.SetValue("View", _viewport.Camera.View);
                    effect.SetValue("Projection", _viewport.Camera.Projection);

                    // Begin the effect rendering
                    passes = effect.Begin(D3D.FX.None);

                    // Render each pass
                    for (int i = 0; i < passes; i++)
                    {
                        effect.BeginPass(i);

                        // Render vertices with or without index buffer
                        if (_buffers.IndexBuffer_Vertices != null)
                        {
                            _viewport.Device.Indices = _buffers.IndexBuffer_Vertices;
                            _viewport.Device.DrawIndexedPrimitives(D3D.PrimitiveType.TriangleList, 0, 0,
                                                                   _buffers.VertexBufferSize_Vertices, 0, _buffers.IndexBufferSize_Vertices / 3);
                        }
                        else
                        {
                            _viewport.Device.DrawPrimitives(D3D.PrimitiveType.TriangleList, 0,
                                                            _buffers.VertexBufferSize_Vertices);
                        }

                        effect.EndPass();
                    }

                    // End the effect rendering
                    effect.End();
                }
                else
                {
                    // Keeping Z-Buffer enabled will hide vertices obscured by terrain
                    //_viewport.Device.RenderState.ZBufferEnable = false;
                    _viewport.Device.Transform.World = world;

                    if (_viewport.Device.RenderState.Lighting)
                    {
                        _viewport.Device.RenderState.Lighting = false;
                    }

                    if (_buffers.IndexBuffer_Vertices != null)
                    {
                        _viewport.Device.Indices = _buffers.IndexBuffer_Vertices;
                        _viewport.Device.DrawIndexedPrimitives(D3D.PrimitiveType.TriangleList, 0, 0,
                                                               _buffers.VertexBufferSize_Vertices, 0, _buffers.IndexBufferSize_Vertices / 3);
                    }
                    else
                    {
                        _viewport.Device.DrawPrimitives(D3D.PrimitiveType.TriangleList, 0,
                                                        _buffers.VertexBufferSize_Vertices / 3);
                    }

                    //_viewport.Device.RenderState.ZBufferEnable = true;
                }
            }
        }
Esempio n. 16
0
        public void DrawWall()
        {
            // Disable alpha blend setting
            GameDevice.RenderState.AlphaBlendEnable = false;

            // Apply shaders to wall
            int numPasses = WallEffect.Begin(0);

            for (int iPass = 0; iPass < numPasses; iPass++)
            {
                WallEffect.BeginPass(iPass);
                for (int i = 0; i < WallMaterials.Length; i++)
                {
                    // Set texture tiling properties for parts of the wall.
                    if (i == 6)                    // Drain Texture
                    {
                        WallEffect.SetValue("xMultiply", 20.0f);
                        WallEffect.SetValue("yMultiply", 1.0f);
                    }
                    else if (i == 4)                    // Wall Texture
                    {
                        WallEffect.SetValue("xMultiply", 5.0f);
                        WallEffect.SetValue("yMultiply", 5.0f);
                    }
                    else if (i == 7)                    // Catwalk Texture
                    {
                        WallEffect.SetValue("xMultiply", 3.0f);
                        WallEffect.SetValue("yMultiply", 3.0f);
                    }
                    else
                    {
                        WallEffect.SetValue("xMultiply", 3.0f);
                        WallEffect.SetValue("yMultiply", 3.0f);
                    }
                    WallEffect.CommitChanges();
                    GameDevice.SetTexture(0, WallTextures[i]);
                    WallMesh.DrawSubset(i);
                }
                WallEffect.EndPass();
            }
            WallEffect.End();

            numPasses = PipeEffect.Begin(0);
            for (int iPass = 0; iPass < numPasses; iPass++)
            {
                PipeEffect.BeginPass(iPass);
                // Set texture tiling properties for parts of the pipe.
                for (int i = 0; i < PipeMaterials.Length; i++)
                {
                    if (i == 6)                    // Bars Texture
                    {
                        PipeEffect.SetValue("xMultiply", 1.0f);
                        PipeEffect.SetValue("yMultiply", 1.0f);
                    }
                    else if (i == 5)                    // Outside pipe
                    {
                        PipeEffect.SetValue("xMultiply", 1.0f);
                        PipeEffect.SetValue("yMultiply", 2.0f);
                    }
                    else if (i == 3)                    // Inside pipe
                    {
                        PipeEffect.SetValue("xMultiply", 3.0f);
                        PipeEffect.SetValue("yMultiply", 3.0f);
                    }
                    else
                    {
                        PipeEffect.SetValue("xMultiply", 1.0f);
                        PipeEffect.SetValue("yMultiply", 1.0f);
                    }
                    PipeEffect.CommitChanges();
                    GameDevice.SetTexture(0, PipeTextures[i]);
                    PipeMesh.DrawSubset(i);
                }
                PipeEffect.EndPass();
            }
            PipeEffect.End();

            // Restore alpha blend setting
            GameDevice.RenderState.AlphaBlendEnable = true;
        }
Esempio n. 17
0
        public void renderConEfectos(float elapsedTime)
        {
            var device = D3DDevice.Instance.Device;

            // dibujo la escena una textura
            effect.Technique = "DefaultTechnique";
            // guardo el Render target anterior y seteo la textura como render target
            var pOldRT = device.GetRenderTarget(0);
            var pSurf  = g_pRenderTarget.GetSurfaceLevel(0);

            device.SetRenderTarget(0, pSurf);
            // hago lo mismo con el depthbuffer, necesito el que no tiene multisampling
            var pOldDS = device.DepthStencilSurface;

            device.DepthStencilSurface = g_pDepthStencil;
            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);

            device.BeginScene();
            //Dibujamos todos los meshes del escenario
            renderScene(elapsedTime, "DefaultTechnique");
            //Render personames enemigos
            foreach (var m in enemigos)
            {
                m.UpdateMeshTransform();
                m.Render();
            }

            device.EndScene();

            pSurf.Dispose();

            // dibujo el glow map
            effect.Technique = "DefaultTechnique";
            pSurf            = g_pGlowMap.GetSurfaceLevel(0);
            device.SetRenderTarget(0, pSurf);
            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);

            device.BeginScene();

            //Dibujamos SOLO los meshes que tienen glow brillantes
            //Render personaje brillante
            //Render personames enemigos
            foreach (var m in enemigos)
            {
                m.UpdateMeshTransform();
                m.Render();
            }

            if (Input.keyDown(Key.F))
            {
                for (var i = 0; i < cant_balas; ++i)
                {
                    if (timer_firing[i] > 0)
                    {
                        var bala = new TgcArrow();
                        bala.PStart    = pos_bala[i];
                        bala.PEnd      = pos_bala[i] + dir_bala[i] * 3;
                        bala.Thickness = 0.05f;
                        bala.HeadSize  = new TGCVector2(0.01f, 0.01f);
                        bala.Effect    = effect;
                        bala.Technique = "DefaultTechnique";
                        bala.updateValues();
                        bala.Render();
                    }
                }
            }

            // El resto opacos
            renderScene(elapsedTime, "DibujarObjetosOscuros");

            device.EndScene();

            pSurf.Dispose();

            // Hago un blur sobre el glow map
            // 1er pasada: downfilter x 4
            // -----------------------------------------------------
            pSurf = g_pRenderTarget4.GetSurfaceLevel(0);
            device.SetRenderTarget(0, pSurf);

            device.BeginScene();
            effect.Technique    = "DownFilter4";
            device.VertexFormat = CustomVertex.PositionTextured.Format;
            device.SetStreamSource(0, g_pVBV3D, 0);
            effect.SetValue("g_RenderTarget", g_pGlowMap);

            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            effect.Begin(FX.None);
            effect.BeginPass(0);
            device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            effect.EndPass();
            effect.End();
            pSurf.Dispose();

            device.EndScene();

            device.DepthStencilSurface = pOldDS;

            // Pasadas de blur
            for (var P = 0; P < cant_pasadas; ++P)
            {
                // Gaussian blur Horizontal
                // -----------------------------------------------------
                pSurf = g_pRenderTarget4Aux.GetSurfaceLevel(0);
                device.SetRenderTarget(0, pSurf);
                // dibujo el quad pp dicho :

                device.BeginScene();
                effect.Technique    = "GaussianBlurSeparable";
                device.VertexFormat = CustomVertex.PositionTextured.Format;
                device.SetStreamSource(0, g_pVBV3D, 0);
                effect.SetValue("g_RenderTarget", g_pRenderTarget4);

                device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
                effect.Begin(FX.None);
                effect.BeginPass(0);
                device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
                effect.EndPass();
                effect.End();
                pSurf.Dispose();

                device.EndScene();

                pSurf = g_pRenderTarget4.GetSurfaceLevel(0);
                device.SetRenderTarget(0, pSurf);
                pSurf.Dispose();

                //  Gaussian blur Vertical
                // -----------------------------------------------------

                device.BeginScene();
                effect.Technique    = "GaussianBlurSeparable";
                device.VertexFormat = CustomVertex.PositionTextured.Format;
                device.SetStreamSource(0, g_pVBV3D, 0);
                effect.SetValue("g_RenderTarget", g_pRenderTarget4Aux);

                device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
                effect.Begin(FX.None);
                effect.BeginPass(1);
                device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
                effect.EndPass();
                effect.End();

                device.EndScene();
            }

            //  To Gray Scale
            // -----------------------------------------------------
            // Ultima pasada vertical va sobre la pantalla pp dicha
            device.SetRenderTarget(0, pOldRT);
            //pSurf = g_pRenderTarget4Aux.GetSurfaceLevel(0);
            //device.SetRenderTarget(0, pSurf);

            device.BeginScene();

            effect.Technique    = "GrayScale";
            device.VertexFormat = CustomVertex.PositionTextured.Format;
            device.SetStreamSource(0, g_pVBV3D, 0);
            effect.SetValue("g_RenderTarget", g_pRenderTarget);
            effect.SetValue("g_GlowMap", g_pRenderTarget4Aux);
            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            effect.Begin(FX.None);
            effect.BeginPass(0);
            device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            effect.EndPass();
            effect.End();

            device.EndScene();
        }
Esempio n. 18
0
        /// <summary>
        ///     Se llama cada vez que hay que refrescar la pantalla.
        ///     Escribir aquí todo el código referido al renderizado.
        ///     Borrar todo lo que no haga falta.
        /// </summary>
        public override void Render()
        {
            if (disposing)
            {
                return;
            }
            //ClearTextures();
            var device = D3DDevice.Instance.Device;

            // Capturamos las texturas de pantalla
            Surface screenRenderTarget = device.GetRenderTarget(0);
            Surface screenDepthSurface = device.DepthStencilSurface;

            // Especificamos que vamos a dibujar en una textura
            device.SetRenderTarget(0, renderTarget.GetSurfaceLevel(0));
            device.DepthStencilSurface = depthStencil;

            // Captura de escena en render target
            device.BeginScene();
            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);

            bool flagFuera = true;

            if (estaEnAlgunMenu)
            {
                oceano.Render();
                heightmap.Render();

                foreach (var pez in peces)
                {
                    if (IsInFrustum(pez.GetMesh()))
                    {
                        pez.Technique("RenderScene");
                        pez.Render();
                    }
                }

                if (IsInFrustum(shark.GetMesh()))
                {
                    shark.Technique("RenderScene");
                    shark.Render();
                }

                foreach (var coral in corales)
                {
                    if (IsInFrustum(coral.GetMesh()))
                    {
                        coral.Technique("RenderScene");
                        coral.Render();
                    }
                }

                Particulas.Render(ElapsedTime);

                foreach (var piedra in piedras)
                {
                    if (IsInFrustum(piedra.GetMesh()))
                    {
                        piedra.Render();
                    }
                }

                //Efecto metalico
                effect.SetValue("shininess", 30f);
                effect.SetValue("KSpecular", 1.0f);
                effect.SetValue("KAmbient", 1.0f);
                effect.SetValue("KDiffuse", 0.5f);
                if (IsInFrustum(nave.obtenerMeshes()))
                {
                    nave.Technique("RenderSceneLight");
                    nave.Render();
                }

                effect.SetValue("shininess", 10f);
                effect.SetValue("KSpecular", 1.1f);
                effect.SetValue("KAmbient", 1.2f);
                effect.SetValue("KDiffuse", 0.25f);
                foreach (var metal in metales)
                {
                    if (IsInFrustum(metal.GetMesh()))
                    {
                        metal.Technique("RenderSceneLight");
                        metal.Render();
                    }
                }

                Oceano.Render();
                Player.Render();
            }
            if (!estaEnAlgunMenu)
            {
                if (estaEnNave)
                {
                    efectoInterior.SetValue("shininess", 1f);
                    efectoInterior.SetValue("KSpecular", 0.1f);
                    efectoInterior.SetValue("KAmbient", 3.0f);
                    efectoInterior.SetValue("KDiffuse", 0f);
                    interiorNave.Render();

                    // constantes de iluminacion de la mesa
                    efectoInterior.SetValue("shininess", 1f);
                    efectoInterior.SetValue("KSpecular", 0.2f);
                    efectoInterior.SetValue("KAmbient", 3.0f);
                    efectoInterior.SetValue("KDiffuse", 0.1f);
                    mesaNave.Render();
                    // es el mismo material (madera) mantengo las mismas constantes
                    sillaInterior.Render();
                    timonInterior.Render();

                    // constantes de iluminacion de la soga
                    efectoInterior.SetValue("shininess", 1f);
                    efectoInterior.SetValue("KSpecular", 0.15f);
                    efectoInterior.SetValue("KAmbient", 2.0f);
                    efectoInterior.SetValue("KDiffuse", 0f);
                    sogaInterior.Render();

                    efectoInterior.SetValue("shininess", 5.0f);
                    efectoInterior.SetValue("KSpecular", 2.5f);
                    efectoInterior.SetValue("KAmbient", 5.0f);
                    efectoInterior.SetValue("KDiffuse", 0f);
                    lamparaNave.Render();
                    if (Player.Instance().puedoEnfrentarTiburon())
                    {
                        // renderizo arma
                        arma.Effect(effect);
                        arma.Technique("RenderScene");
                        arma.Render();
                    }
                }
                else
                {
                    flagFuera = false;
                    oceano.Render();
                    heightmap.Render();

                    foreach (var pez in peces)
                    {
                        if (IsInFrustum(pez.GetMesh()))
                        {
                            pez.Technique("RenderScene");
                            pez.Render();
                        }
                    }

                    foreach (var coral in corales)
                    {
                        if (IsInFrustum(coral.GetMesh()))
                        {
                            coral.Technique("RenderScene");
                            coral.Render();
                        }
                    }

                    foreach (var piedra in piedras)
                    {
                        if (IsInFrustum(piedra.GetMesh()))
                        {
                            piedra.Technique("RenderScene");
                            piedra.Render();
                        }
                    }

                    if (IsInFrustum(shark.GetMesh()))
                    {
                        shark.Technique("RenderScene");
                        shark.Render();
                    }
                    Particulas.Render(ElapsedTime);

                    //Efecto metalico
                    effect.SetValue("shininess", 30f);
                    effect.SetValue("KSpecular", 1.0f);
                    effect.SetValue("KAmbient", 1.0f);
                    effect.SetValue("KDiffuse", 0.5f);
                    if (IsInFrustum(nave.obtenerMeshes()))
                    {
                        nave.Technique("RenderSceneLight");
                        nave.Render();
                    }

                    effect.SetValue("shininess", 10f);
                    effect.SetValue("KSpecular", 1.1f);
                    effect.SetValue("KAmbient", 1.2f);
                    effect.SetValue("KDiffuse", 0.25f);
                    foreach (var metal in metales)
                    {
                        if (IsInFrustum(metal.GetMesh()))
                        {
                            metal.Technique("RenderSceneLight");
                            metal.Render();
                        }
                    }
                    if (Player.Instance().puedoEnfrentarTiburon())
                    {
                        // renderizo arma
                        arma.Effect(effect);
                        arma.Technique("RenderScene");
                        arma.Render();
                    }
                    Oceano.Render();
                }
                Player.Render();
            }

            device.EndScene();

            if (!flagFuera || estaEnAlgunMenu)
            {
                device.SetRenderTarget(0, coralesBrillantes.GetSurfaceLevel(0));
                device.DepthStencilSurface = depthStencil;

                device.BeginScene();

                device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
                // dibujo 15 corales con luz
                int j = 0; //todo: poner 10
                while (j < 25)
                {
                    if (IsInFrustum(corales[j].GetMesh()))
                    {
                        corales[j].Technique("Bloom");
                        corales[j].Render();
                    }
                    j++;
                }

                foreach (var pez in peces)
                {
                    if (IsInFrustum(pez.GetMesh()))
                    {
                        pez.Technique("BloomMask");
                        pez.Render();
                    }
                }

                if (shark.estoyVivo() && IsInFrustum(shark.GetMesh()))
                {
                    shark.Technique("BloomMask");
                    shark.Render();
                }

                if (IsInFrustum(nave.obtenerMeshes()))
                {
                    nave.Technique("BloomMask");
                    nave.Render();
                }

                foreach (var metal in metales)
                {
                    if (IsInFrustum(metal.GetMesh()))
                    {
                        metal.Technique("BloomMask");
                        metal.Render();
                    }
                }

                foreach (var piedra in piedras)
                {
                    if (IsInFrustum(piedra.GetMesh()))
                    {
                        piedra.Technique("BloomMask");
                        piedra.Render();
                    }
                }

                if (Player.Instance().puedoEnfrentarTiburon())
                {
                    // renderizo arma
                    arma.Effect(effect);
                    arma.Technique("BloomMask");
                    arma.Render();
                }

                device.EndScene();

                // aplico pasada de blur horizontal y vertical al FB de los corales q brillan
                var bufferPasada = coralesBrillantes;
                for (int index = 0; index < 4; index++)
                {
                    device.SetRenderTarget(0, FBHorizontalBool.GetSurfaceLevel(0));
                    device.DepthStencilSurface = depthStencil;

                    device.BeginScene();

                    device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);

                    effect.Technique    = "BlurHorizontal";
                    device.VertexFormat = CustomVertex.PositionTextured.Format;
                    device.SetStreamSource(0, fullScreenQuad, 0);
                    effect.SetValue("fBCoralesBrillantes", bufferPasada);

                    effect.Begin(FX.None);
                    effect.BeginPass(0);
                    device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
                    effect.EndPass();
                    effect.End();

                    device.EndScene();


                    device.SetRenderTarget(0, FBVerticalBloom.GetSurfaceLevel(0));
                    device.DepthStencilSurface = depthStencil;

                    device.BeginScene();

                    device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);

                    effect.Technique    = "BlurVertical";
                    device.VertexFormat = CustomVertex.PositionTextured.Format;
                    device.SetStreamSource(0, fullScreenQuad, 0);
                    effect.SetValue("fBCoralesBrillantes", FBHorizontalBool);

                    effect.Begin(FX.None);
                    effect.BeginPass(0);
                    device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
                    effect.EndPass();
                    effect.End();

                    device.EndScene();

                    bufferPasada = FBVerticalBloom;
                }
            }


            // Especificamos que vamos a dibujar en pantalla
            device.SetRenderTarget(0, screenRenderTarget);
            device.DepthStencilSurface = screenDepthSurface;

            device.BeginScene();
            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);

            if (estaEnAlgunMenu)
            {
                effect.Technique = "PostProcessMenu";
            }
            else if (flagFuera)
            {
                effect.Technique = "PostProcess";
            }
            else
            {
                effect.Technique = "PostProcessMar";
            }

            device.VertexFormat = CustomVertex.PositionTextured.Format;
            device.SetStreamSource(0, fullScreenQuad, 0);

            effect.SetValue("sceneFrameBuffer", renderTarget);
            effect.SetValue("verticalBlurFrameBuffer", FBVerticalBloom);

            // Dibujamos el full screen quad
            effect.Begin(FX.None);
            effect.BeginPass(0);
            device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            effect.EndPass();
            effect.End();

            Hud.Render();

            RenderFPS();
            RenderAxis();
            device.EndScene();

            device.Present();
        }
Esempio n. 19
0
        //CLM USED FOR EXPORT
        public unsafe void convertLayersToTexturingDataHandle(BTerrainLayerContainer input, List <Texture> tempAlphaTextures, BTerrainCompositeTexture output, int minXVert, int minZVert, int lod, int channelCount)
        {
            //  BTerrainLayerContainer input = node.mLayerContainer;
            //  BTerrainCompositeTexture output = node.getTextureData(lod).mCompositeTexture;

            Viewport vp = new Viewport();

            vp.X      = output.mXPixelOffset;
            vp.Y      = output.mYPixelOffset;
            vp.Width  = output.mWidth;
            vp.Height = output.mWidth;
            vp.MinZ   = 0;
            vp.MaxZ   = 1;
            BRenderDevice.getDevice().Viewport = vp;

            Microsoft.DirectX.Direct3D.Effect shader = TerrainGlobals.getTexturing().mCompositeShader;
            shader.Begin(0);
            shader.BeginPass(0);

            for (int i = 0; i < channelCount; i++)
            {
                for (int k = 0; k < output.mNumMips; k++)
                {
                    //actually render
                    Surface compositeTarget = null;
                    float   scale           = 1;

                    try
                    {
                        if (output.UsingAtlas == false)
                        {
                            compositeTarget = output.mTextures[i].GetSurfaceLevel(k);
                            BRenderDevice.getDevice().SetRenderTarget(0, compositeTarget);
                        }
                        else
                        {
                            BTerrainCompositeAtlasTexture atlas = output.mAtlas;

                            if (atlas.mTextures[i].Disposed == true)
                            {
                                atlas.reCreate();
                            }

                            scale           = atlas.mAtlasScale;
                            compositeTarget = atlas.mTextures[i].GetSurfaceLevel(k);
                            BRenderDevice.getDevice().SetRenderTarget(0, compositeTarget);
                        }


                        {
                            BTerrainTexturingLayer.eLayerType lastType = BTerrainTexturingLayer.eLayerType.cLayer_Splat;

                            float layerInc = 1.0f / (float)(cMaxNumBlends - 1);// (float)input.getNumLayers();
                            for (int j = 0; j < input.getNumLayers(); j++)
                            {
                                //    BRenderDevice.getDevice().Clear(ClearFlags.ZBuffer | ClearFlags.Target, unchecked((int)0xFFFF0000), 1.0f, 0);

                                //compose a splat
                                shader.SetValue(mShaderContribOverride, 1);
                                shader.SetValue(mShaderAlphaOverride, 1);
                                if (input.giveLayer(j).mLayerType == BTerrainTexturingLayer.eLayerType.cLayer_Splat)
                                {
                                    if (lastType != BTerrainTexturingLayer.eLayerType.cLayer_Splat)
                                    {
                                        shader.EndPass();
                                        shader.BeginPass(0);
                                        lastType = BTerrainTexturingLayer.eLayerType.cLayer_Splat;
                                    }

                                    if (TerrainGlobals.getEditor().getRenderMode() == BTerrainEditor.eEditorRenderMode.cRenderTextureSelectRender)
                                    {
                                        if (TerrainGlobals.getEditor().getMode() != BTerrainEditor.eEditorMode.cModeTexEdit)
                                        {
                                            if (j == 0)
                                            {
                                                shader.SetValue(mShaderContribOverride, 0);
                                                shader.SetValue(mShaderAlphaOverride, 0);
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            if (input.giveLayer(j).mActiveTextureIndex != TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex)
                                            {
                                                shader.SetValue(mShaderContribOverride, 0);
                                            }
                                            else
                                            {
                                                shader.SetValue(mShaderContribOverride, 1);
                                            }
                                            shader.SetValue(mShaderAlphaOverride, 0);
                                        }
                                    }


                                    float targetLayer = (float)(j * layerInc);
                                    shader.SetValue(mShaderNumLayersHandle, targetLayer);
                                    shader.SetValue(mShaderAlphaTexArrayHandle, tempAlphaTextures[j]);


                                    //lock in our target texture
                                    BTerrainActiveTextureContainer active = TerrainGlobals.getTexturing().getActiveTexture(input.giveLayer(j).mActiveTextureIndex);
                                    if (active == null)
                                    {
                                        compositeTarget.Dispose();
                                        continue;
                                    }

                                    shader.SetValue(mShaderTexArrayHandle, active.mTexChannels[i].mTexture);
                                    float[] uvs = new float[2];
                                    uvs[0] = active.mUScale;
                                    uvs[1] = active.mVScale;

                                    shader.SetValue(mShaderLayerUV, uvs);
                                }
                                else //compose a decal
                                {
                                    if (lastType != BTerrainTexturingLayer.eLayerType.cLayer_Decal)
                                    {
                                        shader.EndPass();
                                        shader.BeginPass(1);
                                        lastType = BTerrainTexturingLayer.eLayerType.cLayer_Decal;
                                    }

                                    bool doWhite = false;
                                    if (TerrainGlobals.getEditor().getRenderMode() == BTerrainEditor.eEditorRenderMode.cRenderTextureSelectRender)
                                    {
                                        if (TerrainGlobals.getEditor().getMode() == BTerrainEditor.eEditorMode.cModeTexEdit)
                                        {
                                            shader.SetValue(mShaderContribOverride, 0);
                                        }
                                        else if (TerrainGlobals.getEditor().getMode() == BTerrainEditor.eEditorMode.cModeDecalEdit)
                                        {
                                            doWhite = true;
                                            if (TerrainGlobals.getTexturing().getActiveDecalInstance(input.giveLayer(j).mActiveTextureIndex).mActiveDecalIndex != TerrainGlobals.getTerrainFrontEnd().SelectedDecalIndex)
                                            {
                                                shader.SetValue(mShaderContribOverride, 0);
                                            }
                                            else
                                            {
                                                shader.SetValue(mShaderContribOverride, 1);
                                                shader.SetValue(mShaderAlphaOverride, 1);
                                            }
                                        }
                                    }

                                    //Grab our decal instance
                                    BTerrainDecalInstance decal = getActiveDecalInstance(input.giveLayer(j).mActiveTextureIndex);
                                    if (decal == null)
                                    {
                                        compositeTarget.Dispose();
                                        continue;
                                    }
                                    Vector4 selColor = new Vector4(1, 1, 1, 1);
                                    if (decal.mIsSelected)
                                    {
                                        selColor.Y = 0.75f;
                                        selColor.Z = 0.75f;
                                    }
                                    shader.SetValue(mShaderColorOverload, selColor);



                                    //grab the decal we care about
                                    BTerrainActiveDecalContainer active = getActiveDecal(decal.mActiveDecalIndex);
                                    if (active == null)
                                    {
                                        compositeTarget.Dispose();
                                        continue;
                                    }
                                    if (doWhite)
                                    {
                                        shader.SetValue(mShaderAlphaTexArrayHandle, tempAlphaTextures[0]);
                                    }
                                    else
                                    {
                                        shader.SetValue(mShaderAlphaTexArrayHandle, tempAlphaTextures[j]);
                                    }
                                    shader.SetValue(mShaderAlphaTexDecalHandle, active.mTexChannels[(int)BTerrainTexturing.eTextureChannels.cOpacity].mTexture);
                                    shader.SetValue(mShaderTexDecalHandle, active.mTexChannels[i].mTexture);

                                    float[] decalDat = new float[4];
                                    decalDat[0] = decal.mRotation;


                                    //compute our U and V offset
                                    float vertsToHighResPixelSpaceRatio = BTerrainTexturing.getTextureWidth() / BTerrainQuadNode.cMaxWidth;
                                    decalDat[1] = (decal.mTileCenter.X - (minXVert * vertsToHighResPixelSpaceRatio)) / BTerrainTexturing.getTextureWidth();
                                    decalDat[2] = (decal.mTileCenter.Y - (minZVert * vertsToHighResPixelSpaceRatio)) / BTerrainTexturing.getTextureHeight();

                                    decalDat[3] = 0;

                                    shader.SetValue(mShaderLayerDecalData, decalDat);

                                    float[] uvs = new float[2];
                                    uvs[0] = decal.mUScale;
                                    uvs[1] = decal.mVScale;
                                    shader.SetValue(mShaderLayerUV, uvs);
                                }

                                shader.CommitChanges();
                                BRenderDevice.getDevice().Viewport = vp;
                                BRenderDevice.getDevice().DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 4, 0, 2);
                            }

                            shader.EndPass();
                            shader.BeginPass(0);
                        }
                    }
                    catch (Direct3DXException e)
                    {
                        CoreGlobals.getErrorManager().SendToErrorWarningViewer("An error has occured during the compositing process");
                    }
                    finally
                    {
                        if (compositeTarget != null)
                        {
                            compositeTarget.Dispose();
                        }
                    }
                }
            }
            shader.EndPass();
            shader.End();
        }
Esempio n. 20
0
        private void visionNoctura()
        {
            // dibujo la escena una textura
            otroEfecto.Technique = "DefaultTechnique";
            // guardo el Render target anterior y seteo la textura como render target
            var pOldRT = D3DDevice.Instance.Device.GetRenderTarget(0);
            var pSurf  = g_pRenderTarget.GetSurfaceLevel(0);

            D3DDevice.Instance.Device.SetRenderTarget(0, pSurf);
            // hago lo mismo con el depthbuffer, necesito el que no tiene multisampling
            var pOldDS = D3DDevice.Instance.Device.DepthStencilSurface;

            D3DDevice.Instance.Device.DepthStencilSurface = g_pDepthStencil;
            D3DDevice.Instance.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            //Dibujamos todos los meshes del escenario
            renderScene("DefaultTechnique");
            //Render personames enemigos

            D3DDevice.Instance.Device.EndScene();

            pSurf.Dispose();

            // dibujo el glow map
            otroEfecto.Technique = "DefaultTechnique";
            pSurf = g_pGlowMap.GetSurfaceLevel(0);
            D3DDevice.Instance.Device.SetRenderTarget(0, pSurf);
            D3DDevice.Instance.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);

            D3DDevice.Instance.Device.BeginScene();

            //Dibujamos SOLO los meshes que tienen glow brillantes
            //Render personaje brillante
            //Render personames enemigos
            monstruo.render();
            // El resto opacos
            renderScene("DibujarObjetosOscuros");

            D3DDevice.Instance.Device.EndScene();

            pSurf.Dispose();

            // Hago un blur sobre el glow map
            // 1er pasada: downfilter x 4
            // -----------------------------------------------------
            pSurf = g_pRenderTarget4.GetSurfaceLevel(0);
            D3DDevice.Instance.Device.SetRenderTarget(0, pSurf);

            D3DDevice.Instance.Device.BeginScene();
            otroEfecto.Technique = "DownFilter4";
            D3DDevice.Instance.Device.VertexFormat = CustomVertex.PositionTextured.Format;
            D3DDevice.Instance.Device.SetStreamSource(0, g_pVBV3D, 0);
            otroEfecto.SetValue("g_RenderTarget", g_pGlowMap);

            D3DDevice.Instance.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            otroEfecto.Begin(FX.None);
            otroEfecto.BeginPass(0);
            D3DDevice.Instance.Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            otroEfecto.EndPass();
            otroEfecto.End();
            pSurf.Dispose();

            D3DDevice.Instance.Device.EndScene();

            D3DDevice.Instance.Device.DepthStencilSurface = pOldDS;

            // Pasadas de blur
            for (var P = 0; P < cant_pasadas; ++P)
            {
                // Gaussian blur Horizontal
                // -----------------------------------------------------
                pSurf = g_pRenderTarget4Aux.GetSurfaceLevel(0);
                D3DDevice.Instance.Device.SetRenderTarget(0, pSurf);
                // dibujo el quad pp dicho :

                D3DDevice.Instance.Device.BeginScene();
                otroEfecto.Technique = "GaussianBlurSeparable";
                D3DDevice.Instance.Device.VertexFormat = CustomVertex.PositionTextured.Format;
                D3DDevice.Instance.Device.SetStreamSource(0, g_pVBV3D, 0);
                otroEfecto.SetValue("g_RenderTarget", g_pRenderTarget4);

                D3DDevice.Instance.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
                otroEfecto.Begin(FX.None);
                otroEfecto.BeginPass(0);
                D3DDevice.Instance.Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
                otroEfecto.EndPass();
                otroEfecto.End();
                pSurf.Dispose();

                D3DDevice.Instance.Device.EndScene();

                pSurf = g_pRenderTarget4.GetSurfaceLevel(0);
                D3DDevice.Instance.Device.SetRenderTarget(0, pSurf);
                pSurf.Dispose();

                //  Gaussian blur Vertical
                // -----------------------------------------------------

                D3DDevice.Instance.Device.BeginScene();
                otroEfecto.Technique = "GaussianBlurSeparable";
                D3DDevice.Instance.Device.VertexFormat = CustomVertex.PositionTextured.Format;
                D3DDevice.Instance.Device.SetStreamSource(0, g_pVBV3D, 0);
                otroEfecto.SetValue("g_RenderTarget", g_pRenderTarget4Aux);

                D3DDevice.Instance.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
                otroEfecto.Begin(FX.None);
                otroEfecto.BeginPass(1);
                D3DDevice.Instance.Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
                otroEfecto.EndPass();
                otroEfecto.End();

                D3DDevice.Instance.Device.EndScene();
            }

            //  To Gray Scale
            // -----------------------------------------------------
            // Ultima pasada vertical va sobre la pantalla pp dicha
            D3DDevice.Instance.Device.SetRenderTarget(0, pOldRT);
            //pSurf = g_pRenderTarget4Aux.GetSurfaceLevel(0);
            //device.SetRenderTarget(0, pSurf);

            D3DDevice.Instance.Device.BeginScene();

            otroEfecto.Technique = "GrayScale";
            D3DDevice.Instance.Device.VertexFormat = CustomVertex.PositionTextured.Format;
            D3DDevice.Instance.Device.SetStreamSource(0, g_pVBV3D, 0);
            otroEfecto.SetValue("g_RenderTarget", g_pRenderTarget);
            otroEfecto.SetValue("g_GlowMap", g_pRenderTarget4Aux);
            D3DDevice.Instance.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            otroEfecto.Begin(FX.None);
            otroEfecto.BeginPass(0);
            D3DDevice.Instance.Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            otroEfecto.EndPass();
            otroEfecto.End();

            D3DDevice.Instance.Device.EndScene();
        }
Esempio n. 21
0
        public override void Render(float elapsedTime)
        {
            TexturesManager.Instance.clearAll();

            var device = D3DDevice.Instance.Device;

            var pOldRT = device.GetRenderTarget(0);
            var pSurf  = g_pRenderTarget.GetSurfaceLevel(0);

            device.SetRenderTarget(0, pSurf);
            var pOldDS = device.DepthStencilSurface;

            device.DepthStencilSurface = g_pDepthStencil;

            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);

            time += elapsedTime;

            wavesEffect.SetValue("time", time);
            recoltableItemEffect.SetValue("time", time);


            bulletManager.Render();
            collectModel.Render(elapsedTime);

            //Render SkyBox
            //if (playerModel.UnderSurface())
            //{
            //    skyBoxUndersea.Render();
            //}
            //else
            //{
            //    skyBox.Render();
            //}

            fogEffect.SetValue("ColorFog", 2304311);
            fogEffect.SetValue("CameraPos", TGCVector3.Vector3ToFloat4Array(Camera.Position));
            fogEffect.SetValue("StartFogDistance", 2000);
            fogEffect.SetValue("EndFogDistance", 7000);
            fogEffect.SetValue("Density", 0.0025f);
            var heighmap = TgcTexture.createTexture(MediaDir + "Level1\\Textures\\perli2.jpg");

            fogEffect.SetValue("texHeighmap", heighmap.D3dTexture);
            fogEffect.SetValue("time", time);

            fogEffect.SetValue("spotLightDir", TGCVector3.Vector3ToFloat3Array(new TGCVector3(0, -1f, 0)));

            fogEffect.SetValue("spotLightAngleCos", FastMath.ToRad(55));

            foreach (var mesh in skyBox.Faces)
            {
                mesh.Effect    = fogEffect;
                mesh.Technique = "RenderScene";
                //mesh.Render();
            }

            skyBox.Render();

            underseaTerrain.Effect    = fogEffect;
            underseaTerrain.Technique = "RenderScene2";
            underseaTerrain.Render();

            //Render Surface
            surfacePlane.Render();

            //Render Meshes
            foreach (var item in meshes)
            {
                item.Mesh.Effect    = fogEffect;
                item.Mesh.Technique = "RenderScene";
                item.Mesh.Render();
            }

            if (playerModel.InventoryModel.RenderShipHelm)
            {
                foreach (var item in shipHelmMesh)
                {
                    item.Render();
                }
            }

            if (playerModel.InventoryModel.ShowShipHelm)
            {
                shipHelmPoster.Render();
            }

            playerModel.ShowHistory = historyModel.ShowHistory;
            if (historyModel.ShowHistory)
            {
                historyModel.Render(elapsedTime);
            }

            if (playerModel.Win)
            {
                youWinModel.Render(elapsedTime);
            }

            // restuaro el render target y el stencil
            device.DepthStencilSurface = pOldDS;
            device.SetRenderTarget(0, pOldRT);

            effect.Technique = "PostProcess";

            effect.SetValue("time", time);
            device.VertexFormat = CustomVertex.PositionTextured.Format;
            device.SetStreamSource(0, g_pVBV3D, 0);
            effect.SetValue("g_RenderTarget", g_pRenderTarget);
            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            effect.Begin(FX.None);
            effect.BeginPass(0);
            device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            effect.EndPass();
            effect.End();

            hudModel.Render();

            playerModel.Render(elapsedTime);
        }
Esempio n. 22
0
        public override void Render()
        {
            PreRender();

            var lightPosition = (Vector3)Modifiers["LightPosition"];

            if (TgcD3dInput.Instance.keyPressed(Key.Space))
            {
                efecto_blur = !efecto_blur;
            }

            //Cargar variables de shader
            effect.SetValue("fvLightPosition", TgcParserUtils.vector3ToFloat3Array(lightPosition));
            effect.SetValue("fvEyePosition",
                            TgcParserUtils.vector3ToFloat3Array(Camara.Position));
            effect.SetValue("k_la", (float)Modifiers["Ambient"]);
            effect.SetValue("k_ld", (float)Modifiers["Diffuse"]);
            effect.SetValue("k_ls", (float)Modifiers["Specular"]);
            effect.SetValue("fSpecularPower", (float)Modifiers["SpecularPower"]);

            D3DDevice.Instance.Device.EndScene();

            // dibujo la escena una textura
            effect.Technique = "DefaultTechnique";
            // guardo el Render target anterior y seteo la textura como render target
            var pOldRT = D3DDevice.Instance.Device.GetRenderTarget(0);
            var pSurf  = g_pRenderTarget.GetSurfaceLevel(0);

            D3DDevice.Instance.Device.SetRenderTarget(0, pSurf);
            // hago lo mismo con el depthbuffer, necesito el que no tiene multisampling
            var pOldDS = D3DDevice.Instance.Device.DepthStencilSurface;

            // Probar de comentar esta linea, para ver como se produce el fallo en el ztest
            // por no soportar usualmente el multisampling en el render to texture.
            D3DDevice.Instance.Device.DepthStencilSurface = g_pDepthStencil;

            D3DDevice.Instance.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            D3DDevice.Instance.Device.BeginScene();
            foreach (var instance in instances)
            {
                instance.Technique = "DefaultTechnique";
                instance.render();
            }
            D3DDevice.Instance.Device.EndScene();
            //TextureLoader.Save("scene.bmp", ImageFileFormat.Bmp, g_pRenderTarget);

            // genero el normal map:
            pSurf = g_pNormals.GetSurfaceLevel(0);
            D3DDevice.Instance.Device.SetRenderTarget(0, pSurf);
            D3DDevice.Instance.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            D3DDevice.Instance.Device.BeginScene();
            foreach (var instance in instances)
            {
                instance.Technique = "NormalMap";
                instance.render();
            }

            D3DDevice.Instance.Device.EndScene();
            // restuaro el render target y el stencil
            D3DDevice.Instance.Device.DepthStencilSurface = pOldDS;
            D3DDevice.Instance.Device.SetRenderTarget(0, pOldRT);
            //TextureLoader.Save("normal.bmp", ImageFileFormat.Bmp, g_pNormals);

            // dibujo el quad pp dicho :
            D3DDevice.Instance.Device.BeginScene();
            effect.Technique = efecto_blur ? "CopyScreen" : "EdgeDetect";
            D3DDevice.Instance.Device.VertexFormat = CustomVertex.PositionTextured.Format;
            D3DDevice.Instance.Device.SetStreamSource(0, g_pVBV3D, 0);
            effect.SetValue("g_Normals", g_pNormals);
            effect.SetValue("g_RenderTarget", g_pRenderTarget);

            D3DDevice.Instance.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            effect.Begin(FX.None);
            effect.BeginPass(0);
            D3DDevice.Instance.Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            effect.EndPass();
            effect.End();

            RenderFPS();
            RenderAxis();
            D3DDevice.Instance.Device.EndScene();
            D3DDevice.Instance.Device.Present();
        }
Esempio n. 23
0
        public override void Render()
        {
            if (toggle.Value != lastValue)
            {
                if (toggle.Value)
                {
                    meshes.ForEach(mesh => mesh.Technique = "Deferred");
                }
                else
                {
                    meshes.ForEach(mesh => mesh.Technique = "Default");
                }
                lastValue = toggle.Value;
            }
            if (!toggle.Value)
            {
                PreRender();
                meshes.ForEach(mesh => mesh.Render());
                PostRender();
            }
            else
            {
                var device = D3DDevice.Instance.Device;

                var defaultRenderTarget = device.GetRenderTarget(0);
                var defaultDepth        = device.DepthStencilSurface;

                var positionRenderTarget  = position.GetSurfaceLevel(0);
                var normalsRenderTarget   = normals.GetSurfaceLevel(0);
                var baseColorRenderTarget = baseColor.GetSurfaceLevel(0);

                #region Pasada MultipleRenderTargets

                // Le decimos a la API que dibuje en nuestras tres texturas
                device.SetRenderTarget(0, positionRenderTarget);
                device.SetRenderTarget(1, normalsRenderTarget);
                device.SetRenderTarget(2, baseColorRenderTarget);

                // Le decimos a la API que dibuje la profundidad en esta superficie
                device.DepthStencilSurface = depth;

                device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);

                device.BeginScene();

                meshes.ForEach(mesh => mesh.Render());

                device.EndScene();

                #endregion Pasada MultipleRenderTargets

                #region Pasada Integradora

                // Le decimos a la API que dibuje en pantalla, y anulamos los otros render targets
                device.SetRenderTarget(0, defaultRenderTarget);
                device.SetRenderTarget(1, null);
                device.SetRenderTarget(2, null);

                // Le decimos a la API que dibuje la profundidad en la superficie default
                device.DepthStencilSurface = defaultDepth;

                device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);

                device.BeginScene();

                // Asignamos la tecnica para esta pasada
                deferredEffect.Technique = "IntegrateDeferred";

                // Pasamos cada una de nuestras texturas al shader
                deferredEffect.SetValue("positionTexture", position);
                deferredEffect.SetValue("normalTexture", normals);
                deferredEffect.SetValue("baseColorTexture", baseColor);

                // Dibujamos nuestro full screen quad
                device.VertexFormat = CustomVertex.PositionTextured.Format;
                device.SetStreamSource(0, fullScreenQuad, 0);

                deferredEffect.Begin(FX.None);
                deferredEffect.BeginPass(0);
                device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
                deferredEffect.EndPass();
                deferredEffect.End();

                if (visualizeRenderTargets.Value)
                {
                    deferredEffect.Technique = "RenderTargets";

                    deferredEffect.SetValue("target", 0);
                    deferredEffect.SetValue("matQuad", (quadSizes * TGCMatrix.Translation(-0.5f, -0.5f, 0f)).ToMatrix());

                    deferredEffect.Begin(FX.None);
                    deferredEffect.BeginPass(0);
                    device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
                    deferredEffect.EndPass();
                    deferredEffect.End();

                    deferredEffect.SetValue("target", 1);
                    deferredEffect.SetValue("matQuad", (quadSizes * TGCMatrix.Translation(0f, -0.5f, 0f)).ToMatrix());

                    deferredEffect.Begin(FX.None);
                    deferredEffect.BeginPass(0);
                    device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
                    deferredEffect.EndPass();
                    deferredEffect.End();

                    deferredEffect.SetValue("target", 2);
                    deferredEffect.SetValue("matQuad", (quadSizes * TGCMatrix.Translation(0.5f, -0.5f, 0f)).ToMatrix());

                    deferredEffect.Begin(FX.None);
                    deferredEffect.BeginPass(0);
                    device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
                    deferredEffect.EndPass();
                    deferredEffect.End();
                }

                RenderAxis();
                RenderFPS();

                device.EndScene();

                device.Present();

                #endregion Pasada Integradora

                positionRenderTarget.Dispose();
                normalsRenderTarget.Dispose();
                baseColorRenderTarget.Dispose();
            }
        }