/// <summary> /// Render all ghost effects /// </summary> /// <param name="camera"></param> private void RenderGhosts(Camera camera) { if (ghostList.Count > 0) { if (ghostList.Count > 1) { ghostList.Sort(_CompareGhostByDist); } RenderEffect was = renderEffects; renderEffects = RenderEffect.GhostPass; for (int i = 0; i < ghostList.Count; ++i) { float opacity = ghostList[i].Opacity; float glow = ghostList[i].Glow; ShaderGlobals.FixExplicitBloom(glow); ShaderGlobals.FixBloomColor(new Vector4(opacity, opacity, opacity, 1.0f)); ghostList[i].Actor.RenderObject.Render(camera); } ShaderGlobals.ReleaseExplicitBloom(); ShaderGlobals.ReleaseBloomColor(); renderEffects = was; } }
public static void Render(Camera camera) { Parameter(EffectParams.WorldMatrix).SetValue(Matrix.Identity); Parameter(EffectParams.WorldViewProjMatrix).SetValue(camera.ViewProjectionMatrix); Parameter(EffectParams.CrossTexture).SetValue(CrossTexture); effect.CurrentTechnique = Technique(InGame.inGame.renderEffects); Impact.RenderActive(camera, effect, effectCache); ShaderGlobals.ReleaseExplicitBloom(); }
public static void DrawFatLine(Camera camera, List <Vector3> pts, Vector4 color, ref Matrix localToWorld) { if (pts.Count > 0) { Matrix viewMatrix = camera.ViewMatrix; Matrix projMatrix = camera.ProjectionMatrix; Matrix worldViewProjMatrix = localToWorld * viewMatrix * projMatrix; effect.Parameters["WorldViewProjMatrix"].SetValue(worldViewProjMatrix); effect.Parameters["WorldMatrix"].SetValue(localToWorld); int numSegs = pts.Count / 2; int numTris = numSegs * 2; SetupRunwayPos(pts, color); effect.CurrentTechnique = effect.Techniques["RunwayAlphaBack"]; effect.Parameters["RunCount"].SetValue(5.0f); effect.Parameters["RunPhase"].SetValue(0.0f); effect.Parameters["RunEndColor"].SetValue(Vector4.UnitW); effect.Parameters["Ramps"].SetValue(white); Vector2 runSkinny = new Vector2( 1.0f / camera.Resolution.X, 1.0f / camera.Resolution.Y) * 1.0f; effect.Parameters["RunWidth"].SetValue(runSkinny); ShaderGlobals.FixExplicitBloom(0.0f); DrawPrimRunwayVerts(numTris); effect.CurrentTechnique = effect.Techniques["RunwayAlpha"]; effect.Parameters["RunCount"].SetValue(1.666f); effect.Parameters["RunPhase"].SetValue(0.0f); effect.Parameters["RunEndColor"].SetValue(color); effect.Parameters["Ramps"].SetValue(white); Vector2 runWidth = new Vector2( 1.0f / camera.Resolution.X, 1.0f / camera.Resolution.Y) * 4.0f; effect.Parameters["RunWidth"].SetValue(runWidth); DrawPrimRunwayVerts(numTris); ShaderGlobals.ReleaseExplicitBloom(); } }
public override void Render(Camera camera) { if (active && particleList.Count > 0 && (!Texture.IsDisposed)) { // We're getting rendered, set up the shared vertex buffer to suit us. UpdateVerts(); GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; // Get the effect we need. Effect effect = manager.Effect2d; // Set up common rendering values. effect.CurrentTechnique = Technique; Vector4 diffuseColor = ShaderGlobals.ParticleTint(IsEmissive); diffuseColor *= Color; manager.Parameter(ParticleSystemManager.EffectParams2d.DiffuseColor).SetValue(diffuseColor); // Set up world matrix. Matrix worldMatrix = Matrix.Identity; Matrix worldViewProjMatrix = worldMatrix * camera.ViewProjectionMatrix; manager.Parameter(ParticleSystemManager.EffectParams2d.DiffuseTexture).SetValue(Texture); manager.Parameter(ParticleSystemManager.EffectParams2d.EyeLocation).SetValue(new Vector4(camera.ActualFrom, 1.0f)); manager.Parameter(ParticleSystemManager.EffectParams2d.CameraUp).SetValue(new Vector4(camera.ViewUp, 1.0f)); manager.Parameter(ParticleSystemManager.EffectParams2d.WorldMatrix).SetValue(worldMatrix); manager.Parameter(ParticleSystemManager.EffectParams2d.WorldViewProjMatrix).SetValue(worldViewProjMatrix); manager.Parameter(ParticleSystemManager.EffectParams2d.TileOffset).SetValue(NumTiles > 0 ? 1.0f / (float)NumTiles : 1.0f); manager.Parameter(ParticleSystemManager.EffectParams2d.ParticleRadius).SetValue( ShaderGlobals.MakeParticleSizeLimit(1.0f, 0.0f, 100.0f * endRadius)); ShaderGlobals.FixExplicitBloom(ExplicitBloom); // Render all passes. for (int i = 0; i < effect.CurrentTechnique.Passes.Count; i++) { EffectPass pass = effect.CurrentTechnique.Passes[i]; pass.Apply(); device.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, localVerts, 0, particleList.Count * 4, localIndices, 0, particleList.Count * 2); } ShaderGlobals.ReleaseExplicitBloom(); } // end of if active } // end of Emitter Render()
/// <summary> /// Draw stripped lines connecting the input dots. /// </summary> /// <param name="camera"></param> /// <param name="pts"></param> /// <param name="col"></param> /// <param name="colorOff"></param> /// <param name="phase"></param> public static void DrawRunway(Camera camera, List <Vector3> pts, List <Vector4> col, Vector4 colorOff, float phase, float bloom) { Debug.Assert((pts.Count & 1) == 0, "Even number of points for line segments"); Debug.Assert(col.Count * 2 == pts.Count, "Mismatch between color and segment counts"); int numSegs = col.Count; int numTris = numSegs * 2; int numVerts = numTris * 3; SetupRunwayVerts(pts, col); Matrix viewMatrix = camera.ViewMatrix; Matrix projMatrix = camera.ProjectionMatrix; Matrix worldViewProjMatrix = viewMatrix * projMatrix; effect.Parameters["WorldViewProjMatrix"].SetValue(worldViewProjMatrix); effect.Parameters["WorldMatrix"].SetValue(Matrix.Identity); effect.Parameters["RunCount"].SetValue(0.666f); effect.Parameters["RunPhase"].SetValue(phase); effect.Parameters["RunEndColor"].SetValue(colorOff); effect.Parameters["Ramps"].SetValue(ramps); DrawPrimRunwayVerts(numTris); effect.CurrentTechnique = effect.Techniques["RunwayAlpha"]; ShaderGlobals.FixExplicitBloom(bloom); Vector2 runWidth = new Vector2( 1.0f / camera.Resolution.X, 1.0f / camera.Resolution.Y) * 4.0f; effect.Parameters["RunWidth"].SetValue(runWidth); DrawPrimRunwayVerts(numTris); ShaderGlobals.ReleaseExplicitBloom(); }
private static void RenderEffects(List <ScoreEffect> scoreEffects, Camera camera, Vector3 forward) { if (scoreEffects.Count > 0) { GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; Effect.CurrentTechnique = Effect.Techniques[0]; ShaderGlobals.FixExplicitBloom(0.15f); for (int i = 0; i < Effect.CurrentTechnique.Passes.Count; ++i) { EffectPass pass = Effect.CurrentTechnique.Passes[i]; pass.Apply(); for (int j = 0; j < scoreEffects.Count; ++j) { ScoreEffect scoreEffect = scoreEffects[j]; RenderEffect(scoreEffect, camera, forward); } } ShaderGlobals.ReleaseExplicitBloom(); } }
public static void Render(Camera camera) { if (numTilesReady > 0) { GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; Debug.Assert(InGame.inGame.renderEffects == InGame.RenderEffect.Normal); Parameter(EffectParams.WorldViewProjMatrix).SetValue(camera.ViewProjectionMatrix); SetupWater(); #if !ALLOW_BLOOM ShaderGlobals.FixExplicitBloom(0); #endif // !ALLOW_BLOOM #if !LLLLLL //device.RasterizerState = UI2D.Shared.RasterStateWireframe; device.Indices = indices; device.SetVertexBuffer(verts); EffectTechnique tech = effect.CurrentTechnique; int numPasses = tech.Passes.Count; for (int i = 0; i < numPasses; ++i) { EffectPass pass = tech.Passes[i]; pass.Apply(); int firstVert = lastCulled * 4; int lastVert = nextVert; if (firstVert < lastVert) { int numVerts = lastVert - firstVert; int firstTri = firstVert / 4 * 2; int numTris = numVerts * 2 / 4; int firstIndex = firstTri * 3; device.DrawIndexedPrimitives( PrimitiveType.TriangleList, 0, firstVert, numVerts, firstIndex, numTris); } else { int firstTopTri = firstVert / 4 * 2; int numTopVerts = kMaxVerts - firstVert; int numTopTris = numTopVerts * 2 / 4; int firstTopIndex = firstTopTri * 3; if (numTopTris > 0) { device.DrawIndexedPrimitives( PrimitiveType.TriangleList, 0, firstVert, numTopVerts, firstTopIndex, numTopTris); } int firstBotVert = 0; int numBotVerts = lastVert; int numBotTris = numBotVerts / 4 * 2; int firstBotIndex = 0; if (numBotTris > 0) { device.DrawIndexedPrimitives( PrimitiveType.TriangleList, 0, firstBotVert, numBotVerts, firstBotIndex, numBotTris); } } } //device.RasterizerState = RasterizerState.CullCounterClockwise; #if !ALLOW_BLOOM ShaderGlobals.ReleaseExplicitBloom(); #endif // !ALLOW_BLOOM #endif /// LLLLLL } }
private void EndWaterEffect() { ShaderGlobals.ReleaseExplicitBloom(); }
/// <summary> /// Renders all the registered health bars. /// </summary> /// <param name="camera"></param> public static void Render(Camera camera) { if (actors.Count > 0) { GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; Vector3 forward = Vector3.Normalize(new Vector3(camera.ViewDir.X, camera.ViewDir.Y, 0)); Parameter(EffectParams.BackTexture).SetValue(BackTexture); Parameter(EffectParams.LifeTexture).SetValue(LifeTexture); Parameter(EffectParams.BackSize).SetValue(kBackSize); Parameter(EffectParams.LifeSize).SetValue(kLifeSize); Array arr = actors.ToArray(); Array.Sort(arr, new GameActorCompare(camera)); Effect.CurrentTechnique = Effect.Techniques[0]; ShaderGlobals.FixExplicitBloom(0.25f); GameActor firstPersonActor = null; for (int i = 0; i < Effect.CurrentTechnique.Passes.Count; ++i) { EffectPass pass = Effect.CurrentTechnique.Passes[i]; float prevDist = float.MaxValue; pass.Apply(); for (int j = 0; j < arr.Length; ++j) { GameActor actor = arr.GetValue(j) as GameActor; // By design, the actor list CAN contain nulls. if (actor == null) { continue; } // We'll handle first-person render separately. if (actor.FirstPerson) { firstPersonActor = actor; continue; } float dist = (actor.Movement.Position - camera.ActualFrom).Length(); Debug.Assert(dist <= prevDist); prevDist = dist; Debug.Assert(actor.HealthBarHandle != HealthBarManager.kInvalidHandle); RenderHealthBar(actor, camera, forward); } } if (firstPersonActor != null) { RenderFirstPersonHealthBar(firstPersonActor, camera, forward); } ShaderGlobals.ReleaseExplicitBloom(); } }
} // end of SharedSmokeEmitter PreRender() /// <summary> /// Any post-render stuff that needs to be restored after rendering a batch. /// </summary> public override void PostRender() { // Restore bloom. ShaderGlobals.ReleaseExplicitBloom(); } // end of SharedSmokeEmitter PostRender()