/// <summary> /// Render Loop /// </summary> internal void Render() { //Frustum culling doFrustumCulling(); //Input handleInput(); //Renderizar terreno if (tgcTerrain != null) { tgcTerrain.Render(); } //Renderizar modelos visibles foreach (var meshObj in MeshObjects) { if (meshObj.visible) { meshObj.mesh.Render(); } } //Mostrar BoundingBox de modelos seleccionados foreach (var selectedMeshObj in SelectedMeshList) { selectedMeshObj.mesh.BoundingBox.Render(); } //Renderizar gizmo translateGizmo.render(); }
public void RenderEscenario() { tgcScene.Meshes.ForEach(mesh => mesh.UpdateMeshTransform()); tgcScene.Meshes.ForEach(mesh => mesh.Render()); heightmap.Render(); skyBox.Render(); }
public void Render() { //Se hace el transform a la posicion que devuelve el el Rigid Body del personaje personaje.Position = new TGCVector3(personajeBody.CenterOfMassPosition.X, personajeBody.CenterOfMassPosition.Y - 27, personajeBody.CenterOfMassPosition.Z);//-27 para que no toque el piso pero casi (para que toque el piso -30) personaje.Transform = TGCMatrix.Translation(personajeBody.CenterOfMassPosition.X, personajeBody.CenterOfMassPosition.Y, personajeBody.CenterOfMassPosition.Z); personaje.Render(); terreno.Render(); }
public override void Render() { //Inicio el render de la escena, para ejemplos simples. Cuando tenemos postprocesado o shaders es mejor realizar las operaciones según nuestra conveniencia. PreRender(); physicsExample.Render(); terrain.Render(); //Finaliza el render y presenta en pantalla, al igual que el preRender se debe para casos puntuales es mejor utilizar a mano las operaciones de EndScene y PresentScene PostRender(); }
public void renderScene(float elapsedTime, string Technique) { //Dibujamos todos los meshes del escenario Random rnd = new Random(1); pasto.Effect = effect; pasto.Technique = Technique; for (int i = 0; i < 10; ++i) { for (int j = 0; j < 10; ++j) { pasto.Position = new TGCVector3(-i * 200 + rnd.Next(0, 50), 0, -j * 200 + rnd.Next(0, 50)); pasto.Scale = new TGCVector3(3, 4 + rnd.Next(0, 4), 5); pasto.Render(); } } arbusto.Effect = effect; arbusto.Technique = Technique; for (int i = 0; i < 5; ++i) { for (int j = 0; j < 5; ++j) { arbusto.Position = new TGCVector3(-i * 400 + rnd.Next(0, 50), 0, -j * 400 + rnd.Next(0, 50)); arbusto.Render(); } } arbol.Effect = effect; arbol.Technique = Technique; for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { arbol.Position = new TGCVector3(-i * 700 + rnd.Next(0, 50), 0, -j * 700 + rnd.Next(0, 50)); arbol.Render(); } } // ------------------------------------- //Renderizar terreno terrain.Effect = effect; terrain.Technique = Technique; terrain.Render(); }
public void renderScene(string Technique) { //Dibujamos todos los meshes del escenario Random rnd = new Random(1); pasto.Effect = effect; pasto.Technique = Technique; for (int i = 0; i < 10; ++i) { for (int j = 0; j < 10; ++j) { pasto.Transform = TGCMatrix.Scaling(3, 4 + rnd.Next(0, 4), 5) * TGCMatrix.Translation(-i * 200 + rnd.Next(0, 50), 0, -j * 200 + rnd.Next(0, 50)); pasto.Render(); } } arbusto.Effect = effect; arbusto.Technique = Technique; for (int i = 0; i < 5; ++i) { for (int j = 0; j < 5; ++j) { arbusto.Transform = TGCMatrix.Translation(-i * 400 + rnd.Next(0, 50), 0, -j * 400 + rnd.Next(0, 50)); arbusto.Render(); } } arbol.Effect = effect; arbol.Technique = Technique; for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { arbol.Transform = TGCMatrix.Translation(-i * 700 + rnd.Next(0, 50), 0, -j * 700 + rnd.Next(0, 50)); arbol.Render(); } } // ------------------------------------- //Renderizar terreno terrain.Effect = effect; terrain.Technique = Technique; terrain.Render(); }
public void renderScene(float elapsedTime, bool cubemap) { //Renderizar terreno terrain.Render(); //Renderizar SkyBox skyBox.Render(); // dibujo el bosque foreach (var instance in bosque) { instance.Render(); } // avion //avion.Technique = cubemap ? "RenderCubeMap" : "RenderScene"; avion.Render(); if (!cubemap) { // dibujo el mesh mesh.Technique = "RenderCubeMap"; mesh.Render(); } }
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; } }
public unsafe override void Render() { Device device = GuiController.Instance.D3dDevice; time += ElapsedTime; TgcD3dInput d3dInput = GuiController.Instance.D3dInput; //Obtener variacion XY del mouse if (d3dInput.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT)) { float mouseX = d3dInput.XposRelative; float mouseY = d3dInput.YposRelative; float an = mouseX * 0.1f; float x = (float)(LookFrom.X * Math.Cos(an) + LookFrom.Z * Math.Sin(an)); float z = (float)(LookFrom.Z * Math.Cos(an) - LookFrom.X * Math.Sin(an)); LookFrom.X = x; LookFrom.Z = z; LookFrom.Y += mouseY * 150f; } //Determinar distancia de la camara o zoom segun el Mouse Wheel if (d3dInput.WheelPos != 0) { TGCVector3 vdir = LookFrom - LookAt; vdir.Normalize(); LookFrom = LookFrom - vdir * (d3dInput.WheelPos * 500); } device.Transform.View = TGCMatrix.LookAtLH(LookFrom, LookAt, new TGCVector3(0, 1, 0)); TGCMatrix ant_Proj = device.Transform.Projection; TGCMatrix ant_World = device.Transform.World; TGCMatrix ant_View = device.Transform.View; device.Transform.Projection = TGCMatrix.Identity; device.Transform.World = TGCMatrix.Identity; device.Transform.View = TGCMatrix.Identity; device.SetRenderState(RenderStates.AlphaBlendEnable, false); // rt1= velocidad Surface pOldRT = device.GetRenderTarget(0); Surface pSurf = g_pVelocidadOut.GetSurfaceLevel(0); device.SetRenderTarget(0, pSurf); Surface pOldDS = device.DepthStencilSurface; device.DepthStencilSurface = g_pDepthStencil; // rt2 = posicion Surface pSurf2 = g_pPosOut.GetSurfaceLevel(0); device.SetRenderTarget(1, pSurf2); device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); device.BeginScene(); effect.SetValue("elapsedTime", ElapsedTime); effect.Technique = "ComputeVel"; effect.SetValue("g_pVelocidad", g_pVelocidad); effect.SetValue("g_pPos", g_pPos); device.VertexFormat = CustomVertex.PositionTextured.Format; device.SetStreamSource(0, g_pVBV3D, 0); effect.Begin(FX.None); effect.BeginPass(1); device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); effect.EndPass(); effect.End(); device.EndScene(); // leo los datos de la textura de velocidades // ---------------------------------------------------------------------- Surface pDestSurf = g_pTempVel.GetSurfaceLevel(0); device.GetRenderTargetData(pSurf, pDestSurf); Surface pDestSurf2 = g_pTempPos.GetSurfaceLevel(0); device.GetRenderTargetData(pSurf2, pDestSurf2); float *pDataVel = (float *)pDestSurf.LockRectangle(LockFlags.None).InternalData.ToPointer(); float *pDataPos = (float *)pDestSurf2.LockRectangle(LockFlags.None).InternalData.ToPointer(); for (int i = 0; i < MAX_DS; i++) { for (int j = 0; j < MAX_DS; j++) { vel_x[i, j] = *pDataVel++; vel_z[i, j] = *pDataVel++; pDataVel++; // no usado pDataVel++; // no usado pos_x[i, j] = *pDataPos++; pos_z[i, j] = *pDataPos++; pos_y[i, j] = *pDataPos++; pDataPos++; // no usado } } pDestSurf.UnlockRectangle(); pDestSurf2.UnlockRectangle(); pSurf.Dispose(); pSurf2.Dispose(); device.SetRenderTarget(0, pOldRT); device.SetRenderTarget(1, null); device.DepthStencilSurface = pOldDS; // swap de texturas Texture aux = g_pVelocidad; g_pVelocidad = g_pVelocidadOut; g_pVelocidadOut = aux; aux = g_pPos; g_pPos = g_pPosOut; g_pPosOut = aux; // dibujo pp dicho ---------------------------------------------- device.Transform.Projection = ant_Proj; device.Transform.World = ant_World; device.Transform.View = ant_View; device.BeginScene(); device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); //Renderizar terreno if ((bool)Modifiers["dibujar_terreno"]) { terrain.Render(); } // dibujo las particulas como point sprites mesh.Effect = effect; mesh.Technique = "DefaultTechnique"; effect.SetValue("texDiffuseMap", g_pBaseTexture); CustomVertex.PositionColored[,] vertices = new CustomVertex.PositionColored[MAX_DS, MAX_DS]; for (int i = 0; i < MAX_DS; i++) { for (int j = 0; j < MAX_DS; j++) { float x0 = pos_x[i, j]; float z0 = pos_z[i, j]; float H = pos_y[i, j]; vertices[i, j] = new CustomVertex.PositionColored(x0, H + esfera_radio, z0, Color.Blue.ToArgb()); } } g_pVB.SetData(vertices, 0, LockFlags.None); device.VertexFormat = CustomVertex.PositionColored.Format; device.SetStreamSource(0, g_pVB, 0); device.SetTexture(0, null); device.SetRenderState(RenderStates.PointSize, 32); device.SetRenderState(RenderStates.PointScaleEnable, true); device.SetRenderState(RenderStates.PointSpriteEnable, true); device.DrawPrimitives(PrimitiveType.PointList, 0, MAX_DS * MAX_DS); device.EndScene(); }
/// <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(); }
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); }