public void AddEffect(MyEffect newEffect, float timeMillisecond)
 {
     if (newEffect != null)
     {
         effectManager.AddEffect(newEffect, timeMillisecond);
     }
 }
        private void ShadowChange()
        {
            if (UseShadows.get())
            {
                if (MyEffect.get() == null || MyEffect.getPath().Equals("Deferred/PointLightNoShadows"))
                {
                    MyEffect.set("Deferred/PointLightShadows");
                }

                ShadowCube = AssetManager.RequestCubeMap((int)ShadowMapSize.get(), SurfaceFormat.HalfSingle, DepthFormat.Depth24Stencil8, ShadowCube);
                if (MyEffect.Holder != null)
                {
                    DeferredLightEffect effect3D = (DeferredLightEffect)(MyEffect.Holder);
                    if (ShadowCube.Value != null)
                    {
                        effect3D.ShadowReference.SetValue(ShadowCube.Value);
                    }
                }

                DrawShadows();
            }
            else
            {
                if (MyEffect.get() == null || MyEffect.getPath().Equals("Effects/Deferred/PointLightShadows"))
                {
                    MyEffect.set("Deferred/PointLightNoShadows");
                }
                AssetManager.FreeRenderTarget(ShadowCube);
            }
        }
Exemplo n.º 3
0
        private void ApplyEffects()
        {
            EffectParameterCollection Parameters = MyEffect.get().Parameters;

            if (Parameters["AmbientLightColor"] != null)
            {
                Parameters["AmbientLightColor"].SetValue(ShipLighting.WorldAmbientLightColor);
            }
            if (Parameters["LightOneDirection"] != null)
            {
                Parameters["LightOneDirection"].SetValue(ShipLighting.WorldLightOneDirection);
            }
            if (Parameters["LightOneColor"] != null)
            {
                Parameters["LightOneColor"].SetValue(ShipLighting.WorldLightOneColor);
            }
            if (Parameters["LightTwoDirection"] != null)
            {
                Parameters["LightTwoDirection"].SetValue(ShipLighting.WorldLightTwoDirection);
            }
            if (Parameters["LightTwoColor"] != null)
            {
                Parameters["LightTwoColor"].SetValue(ShipLighting.WorldLightTwoColor);
            }

            base.CreateInGame();
        }
Exemplo n.º 4
0
        public override void Draw3D(Camera3D camera, GameObjectTag DrawTag)
        {
            if (lightState == BasicLight.LightState.Dead || MyEffect.get() != null)
            {
                base.Draw3D(camera, DrawTag);
                return;
            }

            MyEffect.get().CurrentTechnique.Passes[0].Apply();
            FullscreenQuad.Draw();

            base.Draw3D(camera, DrawTag);
        }
        public override void Draw3D(Camera3D camera, GameObjectTag DrawTag)
        {
            if (lightState == BasicLight.LightState.Dead)
            {
                base.Draw3D(camera, DrawTag);
                return;
            }

            if (DrawTag == GameObjectTag._3DPreDraw)
            {
                if (RealtimeShadows.get())
                {
                    DrawShadows();
                }
            }
            else
            {
#if EDITOR && WINDOWS
                if (DrawTag == GameObjectTag._3DForward)
                {
                    if (EditorSelected)
                    {
                        Vector4 Col = Vector4.One;
                        ShapeRenderer.DrawSphere(WorldMatrix, camera, Col);
                    }
                    if (ShadowCube != null)
                    {
                        ShapeRenderer.DrawSphere(WorldMatrix, camera, ShadowCube.Value);
                    }
                }
                else
#endif
                if (MyEffect.Holder != null)
                {
                    Game1.graphicsDevice.RasterizerState = RasterizerState.CullClockwise;
                    DeferredLightEffect effect3D = (DeferredLightEffect)MyEffect.Holder;

                    effect3D.SetTextureSize(ParentScene.WindowSize);
                    effect3D.SetUV(camera);
                    effect3D.SetInverseCamera(camera);
                    effect3D.SetLight(Position.get(), Scale.get() / 2);
                    effect3D.SetFromObject(this);
                    effect3D.SetFromCamera(camera);
                    effect3D.MyEffect.CurrentTechnique.Passes[0].Apply();
                    Render.DrawModel(SphereModel, MyEffect.get());
                }
            }
            base.Draw3D(camera, DrawTag);
        }
 public void AddEffect(MyEffect newEffect, float time)
 {
     lstEffect.Add(newEffect);
     lstTime.Add(time);
 }