Ejemplo n.º 1
0
        /// <summary>
        ///     Creates a new instance of this shader.
        /// </summary>
        public Shader Instance()
        {
            Godot.Material mat;

            switch (Kind)
            {
            case ShaderKind.Source:
                mat = new Godot.ShaderMaterial
                {
                    Shader = Source.GodotShader
                };
                break;

            case ShaderKind.Canvas:
                mat = new Godot.CanvasItemMaterial
                {
                    LightMode = LightMode,
                    BlendMode = BlendMode,
                };
                break;

            default:
                throw new InvalidOperationException();
            }

            return(new Shader(mat));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Creates a new instance of this shader.
        /// </summary>
        public Shader Instance()
        {
            Godot.Material mat;

            switch (Kind)
            {
            case ShaderKind.Source:
                var shaderMat = new Godot.ShaderMaterial
                {
                    Shader = Source.GodotShader
                };
                mat = shaderMat;
                if (ShaderParams != null)
                {
                    foreach (var pair in ShaderParams)
                    {
                        shaderMat.SetShaderParam(pair.Key, pair.Value);
                    }
                }
                break;

            case ShaderKind.Canvas:
                mat = new Godot.CanvasItemMaterial
                {
                    LightMode = LightMode,
                    BlendMode = BlendMode,
                };
                break;

            default:
                throw new InvalidOperationException();
            }

            return(new Shader(mat));
        }