public static void m000001() { f000058 = new SpriteBatch(c000074.m0000d4()); f0000c1 = c000074.f0000b0.Load<Effect>("Blur"); f0000e0 = f0000c1.Parameters["pixelSize"]; f0000e0.SetValue(new Vector2(1f / ((float) c000074.m00000f()), 1f / ((float) c000074.m000010()))); f0000c1.CommitChanges(); f00000a = true; }
public void Draw(Effect effect) { this.graphics.Vertices[0].SetSource(this.vertBuffer, 0, 28); for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { effect.Parameters["Texture1"].SetValue(this.zon.GetBottomTexture(this.til.GetTile(i, j).tileID)); effect.Parameters["Texture2"].SetValue(this.zon.GetTopTexture(this.til.GetTile(i, j).tileID)); effect.CommitChanges(); for (int k = 0; k < effect.CurrentTechnique.Passes.Count; k++) { effect.CurrentTechnique.Passes[k].Begin(); this.graphics.DrawIndexedPrimitives(PrimitiveType.TriangleStrip, i * 400 + j * 25, 0, 25, 0, 44); effect.CurrentTechnique.Passes[k].End(); } } } }
/// <summary> /// DrawPart draws the actual ModelMeshPart /// </summary> /// <param name="transforms"></param> /// <param name="animations"></param> /// <param name="effect"></param> /// <param name="part"></param> private void DrawPart(Matrix [] transforms, int [] animations, Effect effect, ModelMeshPart part) { for (int i = 0; i < transforms.Length; i += maxInstances) { // How many instances can we fit into this batch? int instanceCount = transforms.Length- i; if (instanceCount > maxInstances) instanceCount = maxInstances; // Copy transform and animation data Array.Copy(transforms, i, tempTransforms, 0, instanceCount); Array.Copy(animations, i, tempAnimations, 0, instanceCount); // Send the transform and animation data to the shader effect.Parameters["InstanceTransforms"].SetValue(tempTransforms); effect.Parameters["InstanceAnimations"].SetValue(tempAnimations); effect.CommitChanges(); // Draw maxInstances copies of our geometry in a single batch. this.graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, part.BaseVertex, 0, part.NumVertices * instanceCount, part.StartIndex, part.PrimitiveCount * instanceCount); } }
/// <summary> /// Loads all effects and initializes effect variables /// </summary> /// <remarks> /// This method is automatically called when FlatRedBall is Initialized if /// post processing is suppoted in the current build of the engine. /// </remarks> #endregion internal static void InitializeEffects() { #if !MONOGAME // Create the sprite batch mSpriteBatch = new SpriteBatch(FlatRedBallServices.GraphicsDevice); // Shared parameters #region Get and initialize shared parameters // Get the effect // If modifying the shaders uncomment the following file: //mSharedParametersEffect = FlatRedBallServices.Load<Effect>(@"Assets\Shaders\PostProcessing\Blur"); // Otherwise, keep the following line uncommented so the .xnb files in the // resources are used. mSharedParametersEffect = FlatRedBallServices.mResourceContentManager.Load<Effect>(@"Blur"); // Get shared effect parameters mPixelSize = mSharedParametersEffect.Parameters["pixelSize"]; // Initialize shared effect parameters mPixelSize.SetValue(new Vector2( 1f / (float)FlatRedBallServices.ClientWidth, 1f / (float)FlatRedBallServices.ClientHeight)); // Commit #if !XNA4 mSharedParametersEffect.CommitChanges(); #endif #endregion #endif mIsInitialized = true; }
public void Draw( GraphicsDevice device, Effect effect, EffectParameter worldParam, EffectParameter colorParam ) { foreach ( MeshParticle particle in particles ) { colorParam.SetValue( new Vector4( .69f, .75f, .82f, particle.Alpha ) ); ModelBone startBone; Matrix originTransform = XFileUtils.GetOriginTransform( particle.Mesh.ParentBone, out startBone ); Matrix rotate = Matrix.CreateFromAxisAngle( particle.Axis, particle.Angle ); Matrix translate = Matrix.CreateTranslation( particle.Position ); Matrix offsetTransform = XFileUtils.GetTransform( startBone ); worldParam.SetValue( originTransform * rotate * translate * offsetTransform * worldTransform ); effect.CommitChanges(); foreach ( ModelMeshPart part in particle.Mesh.MeshParts ) { device.Vertices[0].SetSource( particle.Mesh.VertexBuffer, part.StreamOffset, part.VertexStride ); device.Indices = particle.Mesh.IndexBuffer; device.DrawIndexedPrimitives( PrimitiveType.TriangleList, part.BaseVertex, 0, part.NumVertices, part.StartIndex, part.PrimitiveCount ); } } }
public void Draw(Effect effect, string colorMapParamName, string normalMapParamName, string heightMapParamName, Texture2D wallColorMap, Texture2D wallNormalMap, Texture2D wallHeightMap, Texture2D floorColorMap, Texture2D floorNormalMap, Texture2D floorHeightMap, Texture2D ceilingColorMap, Texture2D ceilingNormalMap, Texture2D ceilingHeightMap, bool drawingCeiling) { graphicsDevice.VertexDeclaration = vertexDeclaration; graphicsDevice.Vertices[0].SetSource(vertexBuffer, 0, NormalMappedVertex.SizeInBytes); // Draw the scene geometry. effect.Begin(); // Draw the walls. effect.Parameters[colorMapParamName].SetValue(wallColorMap); effect.Parameters[normalMapParamName].SetValue(wallNormalMap); effect.Parameters[heightMapParamName].SetValue(wallHeightMap); effect.CommitChanges(); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Begin(); graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, wallsIndex, 8); pass.End(); } if (drawingCeiling) { // Draw the ceiling. effect.Parameters[colorMapParamName].SetValue(ceilingColorMap); effect.Parameters[normalMapParamName].SetValue(ceilingNormalMap); effect.Parameters[heightMapParamName].SetValue(ceilingHeightMap); effect.CommitChanges(); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Begin(); graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, ceilingIndex, 2); pass.End(); } } // Draw the floor. effect.Parameters[colorMapParamName].SetValue(floorColorMap); effect.Parameters[normalMapParamName].SetValue(floorNormalMap); effect.Parameters[heightMapParamName].SetValue(floorHeightMap); effect.CommitChanges(); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Begin(); graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, floorIndex, 2); pass.End(); } effect.End(); }
public void prepare_effect(ref Matrix view, ref Matrix project, Effect effect) { this.matrices_combined[0] = this.world_matrix; this.matrices_combined[1] = (this.world_matrix * view) * project; this.matrices_combined[2] = this.inverse_scale_transpose; this.shader_matrices.SetValue(this.matrices_combined); this.v4colors[0] = this.colors[0].ToVector4(); this.v4colors[1] = this.colors[1].ToVector4(); this.v4colors[0].W = this.heat; this.thrust_color.SetValue(this.v4colors); this.effect_tick.SetValue(this.tick); this.effect_noise.SetValue(this.Noise); effect.CommitChanges(); }
public void Draw(Effect effect) { Update(0); effect.Parameters["world"].SetValue(rot); effect.Parameters["k"].SetValue(k); effect.Parameters["uv"].SetValue(uv); effect.Parameters["tex"].SetValue(tex); effect.CommitChanges(); foreach (ModelMesh mesh in model.Meshes) { p.gd.VertexDeclaration = mesh.MeshParts[0].VertexDeclaration; p.gd.Vertices[0].SetSource(mesh.VertexBuffer, 0, mesh.MeshParts[0].VertexStride); p.gd.Indices = mesh.IndexBuffer; p.gd.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 4, 0, 2); } }
public void Draw(Effect VertexShader, Effect PixelShader, Matrix ProjectionMatrix, Matrix ViewMatrix, Matrix WorldMatrix) { float FisoScale = (float)Math.Sqrt(0.5 * 0.5 * 2) / 5.10f; // is 5.10 on far zoom float ZisoScale = (float)Math.Sqrt(0.5 * 0.5 * 2) / 144f; // currently set 144 to near zoom float IsoScale = (1 - m_ZoomProgress) * FisoScale + (m_ZoomProgress) * ZisoScale; float HB = m_GraphicsDevice.Viewport.Width * IsoScale; float VB = m_GraphicsDevice.Viewport.Height * IsoScale; ProjectionMatrix *= Matrix.CreateOrthographicOffCenter(-HB + m_ViewOffX, HB + m_ViewOffX, -VB + m_ViewOffY, VB + m_ViewOffY, 0.1f, 1000000); ViewMatrix *= Matrix.Identity; ViewMatrix *= Matrix.CreateTranslation(new Vector3(-360, 0, -512)); ViewMatrix *= Matrix.CreateRotationX((30 / 180) * (float)Math.PI); ViewMatrix *= Matrix.CreateRotationY((45 / 180) * (float)Math.PI); ViewMatrix *= Matrix.CreateScale(new Vector3(1, 0.5f + (1 - m_ZoomProgress) / 2, 1)); VertexShader.CurrentTechnique = VertexShader.Techniques[0]; VertexShader.Parameters["ViewMatrix"].SetValue(ViewMatrix); VertexShader.Parameters["ProjectionViewMatrix"].SetValue(ProjectionMatrix); VertexShader.Parameters["WorldMatrix"].SetValue(WorldMatrix); VertexShader.CommitChanges(); PixelShader.CurrentTechnique = PixelShader.Techniques[0]; //PixelShader.Parameters["LightCol"].SetValue(new Vector4(0.356f, 0.451f, 0.541f, 1)); //night PixelShader.Parameters["LightCol"].SetValue(new Vector4(1, 1, 1, 1)); //day PixelShader.Parameters["VertexColorTex"].SetValue(m_VertexColor); PixelShader.Parameters["TextureAtlasTex"].SetValue(Atlas); PixelShader.Parameters["TransAtlasTex"].SetValue(TransAtlas); PixelShader.CommitChanges(); VertexShader.Begin(); VertexShader.CurrentTechnique.Passes[0].Begin(); PixelShader.Begin(); PixelShader.CurrentTechnique.Passes[0].Begin(); m_GraphicsDevice.DrawUserPrimitives<MeshVertex>(PrimitiveType.TriangleFan, m_Verts, 0, m_Verts.Length / 3); VertexShader.CurrentTechnique.Passes[0].End(); VertexShader.End(); PixelShader.CurrentTechnique.Passes[0].End(); PixelShader.End(); }