Exemple #1
0
        }   // 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()
Exemple #2
0
        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()
        private static void SetupWater()
        {
            /// parms => cycle.x, waveheight.y, invWaveLength.z
            float        waveCycle     = (float)Time.GameTimeTotalSeconds;
            float        waveHeight    = Terrain.WaveHeight;
            const double WaveLength    = 15.0;
            float        invWaveLength = (float)(2.0 * Math.PI / WaveLength);

            Vector2 waveCenter = new Vector2(127.0f, 600.0f);

            Vector2 waveSpeed = new Vector2(WaveSpeed, 1.0f / WaveSpeed);

            Vector2 rotRate = new Vector2((float)(Math.PI * 2.0 / 3.0), (float)(-Math.PI * 2.0 / 1.8));

            Parameter(EffectParams.WaveCycle).SetValue(waveCycle);
            Parameter(EffectParams.WaveHeight).SetValue(waveHeight);
            Parameter(EffectParams.InverseWaveLength).SetValue(invWaveLength);
            Parameter(EffectParams.WaveCenter).SetValue(waveCenter);
            Parameter(EffectParams.WaveSpeed).SetValue(waveSpeed);
            Parameter(EffectParams.RotRate).SetValue(rotRate);

            float halfCube = Terrain.Current.CubeSize * 0.5f;

            Parameter(EffectParams.HalfCube).SetValue(halfCube);
            Parameter(EffectParams.RippleTex).SetValue(texture);

            float currentTime = (float)(Time.GameTimeTotalSeconds - timeOffset);

            Parameter(EffectParams.CurrentTime).SetValue(currentTime);

            Vector4 tint = new Vector4(1.0f, 1.0f, 1.0f, 0.6f);

            tint *= ShaderGlobals.ParticleTint(false);
            Parameter(EffectParams.Tint).SetValue(tint);

            SetupAges();
        }