Esempio n. 1
0
        public virtual void AssignLightingParameters()
        {
            if (ParameterExists("AmbientLightColor"))
            {
                effect.Parameters["AmbientLightColor"].SetValue(AmbientLightColor.ToVector4());
            }

            if (ParameterExists("AmbientLightIntensity"))
            {
                effect.Parameters["AmbientLightIntensity"].SetValue(AmbientLightIntensity);
            }


            if (ParameterExists("ColorSaturation"))
            {
                effect.Parameters["ColorSaturation"].SetValue(1);
            }

            if (ParameterExists("DiffuseLightColor"))
            {
                effect.Parameters["DiffuseLightColor"].SetValue(DiffuseLightColor.ToVector4());
            }
            if (ParameterExists("DiffuseLightDirection"))
            {
                effect.Parameters["DiffuseLightDirection"].SetValue(DiffuseLightDirection);
            }
            if (ParameterExists("DiffuseLightIntensity"))
            {
                effect.Parameters["DiffuseLightIntensity"].SetValue(DiffuseLightIntensity);
            }
        }
        private void OnLandscapeShaderParams(GameTime gametime)
        {
            CustomEffect.Parameters["DecalViewProj"].SetValue(Utilitys.CreateDecalViewProjectionMatrix(Camera, 64));

            CustomEffect.Parameters["World"].SetValue(Matrix.Identity);
            CustomEffect.Parameters["View"].SetValue(Camera.View);
            CustomEffect.Parameters["Projection"].SetValue(Camera.Projection);

            CustomEffect.Parameters["AmbientLightColor"].SetValue(AmbientLightColor.ToVector4());
            CustomEffect.Parameters["AmbientLightIntensity"].SetValue(AmbientLightIntensity);

            CustomEffect.Parameters["DiffuseLightDirection"].SetValue(DiffuseLightDirection);
            CustomEffect.Parameters["DiffuseLightColor"].SetValue(DiffuseLightColor.ToVector4());
            CustomEffect.Parameters["DiffuseLightIntensity"].SetValue(DiffuseLightIntensity);

            CustomEffect.Parameters["CursorPosition"].SetValue(MouseCoords);
            CustomEffect.Parameters["CursorSize"].SetValue(BrushSize);

            switch (FillMode)
            {
            case FillMode.Solid:
                CustomEffect.CurrentTechnique = CustomEffect.Techniques["Solid"];
                break;

            case FillMode.WireFrame:
                CustomEffect.CurrentTechnique = CustomEffect.Techniques["WireFrame"];
                break;
            }

            // Send our Textures to our GPU
            if (Layer1 != null)
            {
                CustomEffect.Parameters["TextureLayer1"].SetValue(Layer1);
            }
            if (Layer2 != null)
            {
                CustomEffect.Parameters["TextureLayer2"].SetValue(Layer2);
            }
            if (Layer3 != null)
            {
                CustomEffect.Parameters["TextureLayer3"].SetValue(Layer3);
            }
            if (Layer4 != null)
            {
                CustomEffect.Parameters["TextureLayer4"].SetValue(Layer4);
            }

            if (PaintMask1 != null)
            {
                CustomEffect.Parameters["PaintMask"].SetValue(PaintMask1);
            }
        }