/// <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 void SetupWaterEffect(Water.Definition def, float baseHeight) { /// Give the water a shot at setting up body specific parameters. Parameter(EffectParams.Color).SetValue(def.Color); Parameter(EffectParams.BaseHeight).SetValue(baseHeight); Parameter(EffectParams.WaveHeight).SetValue(Terrain.WaveHeight); Parameter(EffectParams.Fresnel).SetValue(def.Fresnel); Parameter(EffectParams.Shininess).SetValue(def.Shininess); Parameter(EffectParams.Emissive).SetValue(def.Emissive); Parameter(EffectParams.TextureTile).SetValue(def.TextureTiling); ShaderGlobals.FixExplicitBloom(def.ExplicitBloom); }
} // end of SharedSmokeEmitter Update() /// <summary> /// Sets up all the common stuff needed for rendering. This includes /// setting the technique and any parameters that don't change from /// one batch to the next. /// </summary> public override void PreRender(Camera camera) { GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; if (InGame.inGame.renderEffects == InGame.RenderEffect.DistortionPass) { ShaderGlobals.FixExplicitBloom(0.004f); effect.CurrentTechnique = effect.Techniques[@"DistortionPass"]; } else { // Turn off bloom. ShaderGlobals.FixExplicitBloom(0.0f); effect.CurrentTechnique = effect.Techniques[TechniqueName]; } // Set up common rendering values. effect.Parameters["CurrentTime"].SetValue((float)Time.GameTimeTotalSeconds); // Set up world matrix. Matrix worldMatrix = Matrix.Identity; Matrix worldViewProjMatrix = worldMatrix * camera.ViewProjectionMatrix; Vector4 diffuseColor = ShaderGlobals.ParticleTint(false); effect.Parameters["DiffuseColor"].SetValue(diffuseColor); effect.Parameters["DiffuseTexture"].SetValue(texture); effect.Parameters["EyeLocation"].SetValue(new Vector4(camera.ActualFrom, 1.0f)); effect.Parameters["CameraUp"].SetValue(new Vector4(camera.ViewUp, 1.0f)); effect.Parameters["WorldMatrix"].SetValue(worldMatrix); effect.Parameters["WorldViewProjMatrix"].SetValue(worldViewProjMatrix); effect.Parameters["ParticleRadius"].SetValue( ShaderGlobals.MakeParticleSizeLimit(1.0f, 0.0f, 200.0f)); // Cloned from DistortFilter. Another casualty of the removal of gloabl shader values. Vector4 filterScroll = new Vector4(0.0f, 0.0f, 0.0f, 0.0f); Vector4 filterScale = new Vector4(0.5f, 0.5f, 0.5f, 0.5f); float filterStrength = 0.2f; effect.Parameters["BumpScroll"].SetValue(filterScroll); effect.Parameters["BumpScale"].SetValue(filterScale); effect.Parameters["BumpStrength"].SetValue(filterStrength); effect.Parameters["DepthTexture"].SetValue(InGame.inGame.EffectsRenderTarget); //effect.Parameters["Bump"].SetValue(DistortFilter.BumpTexture); effect.Parameters["Bump"].SetValue(DistortionManager.Bump); effect.Parameters["DOF_FarPlane"].SetValue(100.0f); device.Indices = ibuf; } // end of SharedSmokeEmitter PreRender()
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()
public void Render(Camera camera, Effect effect, EffectCache cache) { BoundingSphere bound = new BoundingSphere(WorldCenter, Radius); if (Frustum.CullResult.TotallyOutside != camera.Frustum.CullTest(bound)) { float bloom = Age; bloom *= bloom * bloom; bloom = 1.0f - bloom; bloom *= 0.2f; ShaderGlobals.FixExplicitBloom(bloom); GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; Sphere sphere = Sphere.GetInstance(); sphere.PreDraw(device); /// Set effect parameters here. float ageParm = 2.0f - 2.0f / (Age + 1.0f); Parameter(EffectParams.Age).SetValue(ageParm); Parameter(EffectParams.Center).SetValue(new Vector4(WorldCenter, Radius)); Parameter(EffectParams.TexU).SetValue(TexU); Parameter(EffectParams.TexV).SetValue(TexV); Parameter(EffectParams.TexW).SetValue(TexW); float colorParm = 1.0f - Age; colorParm *= colorParm * colorParm; colorParm = 1.0f - colorParm; Vector4 tint0 = new Vector4(0.5f * Tint.X, 1.0f * Tint.Y, 0.6f * Tint.Z, 1.0f); Vector4 tint1 = new Vector4(Tint, 1.0f); Vector4 tint = tint0 + (tint1 - tint0) * colorParm; Parameter(EffectParams.Tint0).SetValue(tint); Parameter(EffectParams.Tint1).SetValue(tint); sphere.DrawPrim(effect); } }
/// <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 } }
/// <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(); } }