Beispiel #1
0
        }   // end of UIGridModularMenu RefreshTexture()

        public void Render(Camera camera)
        {
            try
            {
                ShaderGlobals.SetValues(effect);
                ShaderGlobals.SetCamera(effect, camera);

                effect.CurrentTechnique = effect.Techniques["NormalMappedWithEnv"];
                effect.Parameters["DiffuseTexture"].SetValue(diffuse);

                effect.Parameters["WorldMatrix"].SetValue(worldMatrix);
                effect.Parameters["WorldViewProjMatrix"].SetValue(worldMatrix * camera.ViewProjectionMatrix);

                effect.Parameters["Alpha"].SetValue(1.0f);
                effect.Parameters["DiffuseColor"].SetValue(new Vector4(1, 1, 1, 1));
                effect.Parameters["SpecularColor"].SetValue(specularColor);
                effect.Parameters["SpecularPower"].SetValue(specularPower);

                effect.Parameters["NormalMap"].SetValue(normalMap);

                geometry.Render(effect);
            }
            catch
            {
                // This Try/Catch is here since the first frame back from a device reset
                // the call to diffuse fails saying that the rendertarget is
                // still set on the device.  As far as I can tell it's not but I still
                // can't win the argument.
            }
        }   // end of UIGridModularMenu Render()
        }   // end of UIGridTextListElement SetValue()

        public override void LoadContent(bool immediate)
        {
            // Init the effect.
            if (effect == null)
            {
                effect = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\UI2D");
                ShaderGlobals.RegisterEffect("UI2D", effect);
            }

            // Load the check textures.
            if (checkbox == null)
            {
                checkbox = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\UI2D\WhiteCheckBox");
            }
            if (checkmark == null)
            {
                checkmark = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\UI2D\WhiteCheck");
            }

            // Load the normal map texture.
            if (normalMapName != null)
            {
                normalMap = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\UI2D\" + normalMapName);
            }
        }
Beispiel #3
0
        public void LoadContent(bool immediate)
        {
            contentLoaded = true;

            // Init the effect.
            if (effect == null)
            {
                effect = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\UI2D");
                ShaderGlobals.RegisterEffect("UI2D", effect);
            }

            // Load the textures.
            if (whiteTop == null)
            {
                whiteTop = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\GridElements\WhiteTop");
            }
            if (whiteHighlight == null)
            {
                whiteHighlight = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\GridElements\WhiteHighlight");
            }
            if (blackHighlight == null)
            {
                blackHighlight = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\GridElements\BlackHighlight");
            }
            if (greenBar == null)
            {
                greenBar = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\GridElements\GreenBar");
            }

            // Load the normal map texture.
            if (normalMapName != null)
            {
                normalMap = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\UI2D\" + normalMapName);
            }
        }
        }   // end of UIGridPictureListElement RefreshTexture()

        public override void LoadContent(bool immediate)
        {
            // Init the effect.
            if (effect == null)
            {
                effect = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\UI2D");
                ShaderGlobals.RegisterEffect("UI2D", effect);
            }

            // Load the normal map texture.
            if (normalMapName != null)
            {
                normalMap = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\UI2D\" + normalMapName);
            }

            // Load the arrow textures.
            if (leftArrow == null)
            {
                leftArrow = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\UI2D\WhiteLeftArrow");
            }
            if (rightArrow == null)
            {
                rightArrow = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\UI2D\WhiteRightArrow");
            }
        }
Beispiel #5
0
        public static void Load(GraphicsDevice device)
        {
            if (effect == null)
            {
                effect = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\Ripple");
                ShaderGlobals.RegisterEffect("Ripple", effect);
                effectCache.Load(effect);
            }
            if (texture == null)
            {
                texture = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\BullsEye1");
            }
            if (verts == null)
            {
                verts = new DynamicVertexBuffer(device, typeof(Vertex), kMaxVerts, BufferUsage.WriteOnly);
            }
            if (indices == null)
            {
                indices = new IndexBuffer(device, typeof(Int16), kMaxIndices, BufferUsage.WriteOnly);
                Int16[] localIdx = new Int16[kMaxIndices];
                for (int i = 0; i < kMaxTiles; ++i)
                {
                    localIdx[i * 6 + 0] = (short)(i * 4 + 0);
                    localIdx[i * 6 + 1] = (short)(i * 4 + 1);
                    localIdx[i * 6 + 2] = (short)(i * 4 + 2);

                    localIdx[i * 6 + 3] = (short)(i * 4 + 2);
                    localIdx[i * 6 + 4] = (short)(i * 4 + 1);
                    localIdx[i * 6 + 5] = (short)(i * 4 + 3);
                }
                indices.SetData <Int16>(localIdx);
            }
        }
Beispiel #6
0
        }   // end of UIGrid2DDualTextureElement Render()

        public override void LoadContent(bool immediate)
        {
            // Init the effect.
            if (effect == null)
            {
                effect = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\UI2D");
                ShaderGlobals.RegisterEffect("UI2D", effect);
            }

            // Load the diffuse texture.
            if (foreTextureName != null)
            {
                foreTexture = Boku.Programming.CardSpace.Cards.CardFaceTexture(foreTextureName);
            }

            // Load the overlay texture.
            if (backSelectedTexture == null)
            {
                backSelectedTexture = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\HelpCard\GreenSquare");
            }
            if (backUnselectedTexture == null)
            {
                backUnselectedTexture = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\HelpCard\GreySquare");
            }
        }   // end of UIGrid2DDualTextureElement LoadContent()
Beispiel #7
0
        /// <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;
            }
        }
Beispiel #8
0
        /// <summary>
        /// Load up anything that doesn't require a device.
        /// </summary>
        /// <param name="immediate"></param>
        public static void LoadContent(bool immediate)
        {
            if (effect == null)
            {
                effect = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\ShowBudget");
                ShaderGlobals.RegisterEffect("ShowBudget", effect);
                effectCache.Load(effect, "");

                budgetTechnique = effect.Techniques["ShowBudget"];
                glowTechnique   = effect.Techniques["BorderGlow"];
            }

            if (background == null)
            {
                background = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\BudgetBackground");
            }
            if (mask == null)
            {
                mask = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\BudgetMask");
            }
            if (glow == null)
            {
                glow = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\BudgetGlow");
            }
        }
Beispiel #9
0
        }   // end of UIGrid2DLEDArray Render()

        public override void LoadContent(bool immediate)
        {
            // Init the effect.
            if (effect == null)
            {
                effect = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\UI2D");
                ShaderGlobals.RegisterEffect("UI2D", effect);
            }

            // Load the normal map texture.
            if (normalMapName != null)
            {
                normalMap = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\UI2D\" + normalMapName);
            }

            // Load the diffuse texture.
            if (diffuseTextureName != null)
            {
                diffuse = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\" + diffuseTextureName);
            }

            if (white == null)
            {
                white = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\White");
            }
        }   // end of UIGrid2DLEDArray LoadContent()
        /// <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)
        {
            if (InGame.inGame.renderEffects == InGame.RenderEffect.Normal)
            {
                if (numActiveBleeps > 0)
                {
                    GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;

                    effect.CurrentTechnique = effect.Techniques[@"BleepPass"];

                    // 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;

                    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);

                    float   radius     = 0.2f;
                    float   minPix     = 3.0f;
                    float   maxPix     = 6.0f;
                    Vector4 pixelLimit = ShaderGlobals.MakeParticleSizeLimit(radius, minPix, maxPix);
                    effect.Parameters["ParticleRadius"].SetValue(pixelLimit);

                    device.Indices = ibuf;

                    device.SetVertexBuffer(vbuf);
                }
            }
        }
        }   // end of UIGrid2DTextureElement Render()

        public override void LoadContent(bool immediate)
        {
            // Init the effect.
            if (effect == null)
            {
                effect = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\UI2D");
                ShaderGlobals.RegisterEffect("UI2D", effect);
            }

            // Load the normal map texture.
            if (normalMapName != null)
            {
                normalMap = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\UI2D\" + normalMapName);
            }

            // Load the diffuse texture.
            if (diffuseTextureName != null)
            {
                if (CardSpace)
                {
                    diffuse = Boku.Programming.CardSpace.Cards.CardFaceTexture(diffuseTextureName);
                }
                else
                {
                    diffuse = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\" + diffuseTextureName);
                }
            }

            // Load the overlay texture.
            if (overlayTextureName != null)
            {
                overlayTexture = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\" + overlayTextureName);
            }
        }   // end of UIGrid2DTextureElement LoadContent()
Beispiel #12
0
        /// <summary>
        /// Set all lights' parameters to effect.
        /// Note this completely clobbers any transitional effects.
        /// </summary>
        /// <param name="effect"></param>
        public void SetToEffect(Effect effect)
        {
            if (LightList != null)
            {
                for (int i = 0; i < LightList.Length; ++i)
                {
                    Light light = LightList[i];

                    Vector3 color   = light.Color;
                    float   maxChan = Math.Max(color.X, Math.Max(color.Y, color.Z));

                    lightColors[i] = light.Color;
                    lightDir[i]    = new Vector4(light.Direction, maxChan);

                    string dirParam = "LightDirection" + i.ToString();
                    if (effect.Parameters[dirParam] != null)
                    {
                        effect.Parameters[dirParam].SetValue(new Vector4(light.Direction, maxChan));
                    }
                    string colorParam = "LightColor" + i.ToString();
                    if (effect.Parameters[colorParam] != null)
                    {
                        effect.Parameters[colorParam].SetValue(light.Color);
                    }
                }

                lightWrap = Wrap;
                Parameter(EffectParams.Wrap).SetValue(ShaderGlobals.MakeWrapVec(Wrap));
            }
        }
        }   // end of UIGridModularButtonElement Render()

        public override void LoadContent(bool immediate)
        {
            // Init the effect.
            if (effect == null)
            {
                effect = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\UI2D");
                ShaderGlobals.RegisterEffect("UI2D", effect);
            }

            // Load the normal map texture.
            if (normalMapName != null)
            {
                normalMap = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\UI2D\" + normalMapName);
            }

            // Load the check textures.
            if (checkboxWhite == null)
            {
                checkboxWhite = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\GridElements\CheckboxWhite");
            }
            if (blackSquare == null)
            {
                blackSquare = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\GridElements\BlackSquare");
            }
        }   // end of UIGridModularButtonElement LoadContent()
Beispiel #14
0
        public override void LoadContent(bool immediate)
        {
            // Init the effect.
            if (effect == null)
            {
                effect = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\UI2D");
                ShaderGlobals.RegisterEffect("UI2D", effect);
            }

            // Load the normal map texture.
            if (normalMapName != null)
            {
                normalMap = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\UI2D\" + normalMapName);
            }

            // Load the textures.
            if (sliderWhite == null)
            {
                sliderWhite = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\GridElements\SliderWhite");
            }
            if (sliderBlack == null)
            {
                sliderBlack = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\GridElements\SliderBlack");
            }
            if (sliderBeadEnd == null)
            {
                sliderBeadEnd = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\GridElements\SliderBeadEnd");
            }
            if (sliderBeadMiddle == null)
            {
                sliderBeadMiddle = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\GridElements\SliderBeadMiddle");
            }
        }   // end of UIGridBaseModularSliderElement LoadContent()
Beispiel #15
0
        public void ExecuteRow(
            Vector2 screenUV, Vector2 objUV,
            int cols, float screenUVdx, float objUVdx,
            Color[] backbuffer, int backbufferOffset,
            ref Texture texture, ref ShaderGlobals globals)
        {
            int   texY     = Shaders.SampleTextureY(texture, objUV);
            float darkXfac = -0.5f + globals.CosTime1000 * 0.1f;

            screenUV.x += darkXfac;
            float darkY        = screenUV.y - 0.5f + globals.CosTime600 * 0.1f;
            float darkY2       = darkY * darkY;
            float darkFac      = 1.0f - 4.0f * darkY2;
            uint  ditherOffset = (uint)(backbufferOffset + (int)globals.Time);

            for (int x = 0; x < cols; ++x, screenUV.x += screenUVdx, objUV.x += objUVdx, backbufferOffset++, ++ditherOffset)
            {
                Color result = new Color(0xFF000000);

                float darkX = screenUV.x;
                float dark  = darkFac - 4f * darkX * darkX;
                if (dark > 0.0f)
                {
                    result = Shaders.SampleTextureX(texture, texY, objUV);

                    uint darkI = (uint)(dark * 255.0f);
                    result.Scale(darkI);

                    result = Shaders.Dither(result, ditherOffset);
                }
                backbuffer[backbufferOffset] = result;
            }
        }
        /// <summary>
        /// Set our envmap as current, render, then restore.
        /// </summary>
        public override void Render(Camera camera, ref Matrix rootToWorld, List <List <PartInfo> > listPartsReplacement)
        {
            ShaderGlobals.PushEnvMap(RoverGreeter.EnvMap);

            base.Render(camera, ref rootToWorld, listPartsReplacement);

            ShaderGlobals.PopEnvMap();
        }
 internal static void LoadContent(bool immediate)
 {
     if (effect == null)
     {
         effect = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\ScoreEffect");
         ShaderGlobals.RegisterEffect("ScoreEffect", effect);
     }
 }
Beispiel #18
0
        }   // end of UtilsVertex


        public static void Init(GraphicsDevice device)
        {
            // Init the effect.
            effect = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\Utils");
            ShaderGlobals.RegisterEffect("Utils", effect);

            ramps = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\Ramps");
            white = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\White");
        }   // end of Utils Init()
Beispiel #19
0
 public void LoadContent(bool immediate)
 {
     // Init the effect.  Doesn't really matter which one, just
     // has to be one that uses the same shared parameters.
     if (effect == null)
     {
         effect = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\Standard");
         ShaderGlobals.RegisterEffect("Standard", effect);
     }
 }   // end of UIShim RenderObj LoadContent()
Beispiel #20
0
        public void Render()
        {
            ///  render entire pie
            if (Active)
            {
                ShaderGlobals.SetValues(effect);
                ShaderGlobals.SetCamera(effect, camera);

                RenderDisk(rootDisk);
            }
        }
Beispiel #21
0
        }   // end of SkyBox Render()

        public override void LoadContent(bool immediate)
        {
            // Init the effect.
            if (effect == null)
            {
                effect = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\SkyBox");
                ShaderGlobals.RegisterEffect("SkyBox", effect);
            }

            base.LoadContent(immediate);
        }   // end of SkyBox LoadContent()
Beispiel #22
0
 private static void Postfix(ShaderGlobals __instance, int band, float power)
 {
     if (ReactiveLights.Count == 0)
     {
         return;
     }
     else if (band == 1)
     {
         Update(power);
     }
 }
Beispiel #23
0
        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 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);
        }
Beispiel #25
0
 /// <summary>
 /// Load up resource needed for rendering, all shared statics.
 /// </summary>
 /// <param name="immediate"></param>
 public static void LoadContent(bool immediate)
 {
     if (bump == null)
     {
         bump = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\DistortionWake");
     }
     if (effect == null)
     {
         effect = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\Standard");
         ShaderGlobals.RegisterEffect("Standard", effect);
         effectCache.Load(effect, "");
     }
 }
Beispiel #26
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()
Beispiel #27
0
        /// <summary>
        /// This Init function also doubles as an update function
        /// in case the position or size of the billboard changes.
        /// </summary>
        public void InitDeviceResources(GraphicsDevice device)
        {
            // Init the vertex buffer.
            if (vbuf == null)
            {
                vbuf = new VertexBuffer(device, typeof(Vertex), 4, BufferUsage.WriteOnly);

                // Create local vertices.
                Vertex[] localVerts = new Vertex[4];
                {
                    localVerts[0] = new Vertex(new Vector3(-size.X / 2.0f, size.Y / 2.0f, 0.0f), new Vector2(0, 0));
                    localVerts[1] = new Vertex(new Vector3(size.X / 2.0f, size.Y / 2.0f, 0.0f), new Vector2(1, 0));
                    localVerts[2] = new Vertex(new Vector3(size.X / 2.0f, -size.Y / 2.0f, 0.0f), new Vector2(1, 1));
                    localVerts[3] = new Vertex(new Vector3(-size.X / 2.0f, -size.Y / 2.0f, 0.0f), new Vector2(0, 1));
                }

                // Copy to vertex buffer.
                vbuf.SetData <Vertex>(localVerts);
            }

            // Init the effect.
            if (effect == null)
            {
                effect = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\Billboard");
                ShaderGlobals.RegisterEffect("Billboard", effect);
                effectCache.Load(effect);
                technique = premultipliedAlpha
                    ? effect.Techniques["PremultipliedAlphaColorPass"]
                    : effect.Techniques["NormalAlphaColorPass"];
            }

            // Load the texture.
            if (textureFilename != null)
            {
                // First try and load it as a programming tile.
                texture = CardSpace.Cards.CardFaceTexture(textureFilename);

                // If that didn't work, treat it as an asset name.
                if (texture == null)
                {
                    texture = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + textureFilename);
                }
            }
            if (texture != null && size == Vector2.Zero)
            {
                UiCamera c = new UiCamera();
                size.X = texture.Width / c.Dpi;  // 96 DPI
                size.Y = texture.Height / c.Dpi;
            }
        }   // end of InitDeviceResources()
Beispiel #28
0
        public static void Load()
        {
            if (effect == null)
            {
                effect = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\Shield");
                ShaderGlobals.RegisterEffect("Shield", effect);
                effectCache.Load(effect, "");
            }

            if (crossTexture == null)
            {
                crossTexture = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\Ring");
            }
        }
Beispiel #29
0
        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();
            }
        }
Beispiel #30
0
        }   // end of Compass Render()

        public void LoadContent(bool immediate)
        {
            // Init the effect.
            if (effect == null)
            {
                effect = BokuGame.Load <Effect>(BokuGame.Settings.MediaPath + @"Shaders\Billboard");
                ShaderGlobals.RegisterEffect("Billboard", effect);
            }

            // Load the texture.
            if (texture == null)
            {
                texture = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\Compass");
            }
        }   // end of Compass LoadContent()