public Q3BSPMaterialStageContent(Q3BSPMaterialContent parent)
        {
            this.TextureFilename = "";
            this.Parent          = parent;

            this.IsLightmapStage        = false;
            this.IsWhiteStage           = false;
            this.SourceBlendFactor      = Q3BSPBlendFuncFactor.Invalid;
            this.DestinationBlendFactor = Q3BSPBlendFuncFactor.Invalid;
        }
        public void Finalize(ref List <Q3BSPMaterialStageTcMod> tcMods)
        {
            if (tcMods.Count > 0)
            {
                TcModStatements = new Q3BSPMaterialStageTcMod[tcMods.Count];
                tcMods.CopyTo(this.TcModStatements);
            }

            if (SourceBlendFactor == Q3BSPBlendFuncFactor.Invalid || DestinationBlendFactor == Q3BSPBlendFuncFactor.Invalid)
            {
                SourceBlendFactor      = Q3BSPBlendFuncFactor.One;
                DestinationBlendFactor = Q3BSPBlendFuncFactor.Zero;
            }
        }
        static string WriteBlendFuncEquationSide(string side, Q3BSPBlendFuncFactor blendFactor, string source, string destination)
        {
            switch (blendFactor)
            {
            case Q3BSPBlendFuncFactor.One:
                return(side);

            case Q3BSPBlendFuncFactor.Zero:
                return("");

            case Q3BSPBlendFuncFactor.Destination:
                return(side + " * " + destination);

            case Q3BSPBlendFuncFactor.InverseDestination:
                return(side + " * float4(1.0 - " + destination + ".r, 1.0 - " + destination + ".g, 1.0 - " + destination + ".b, 1.0 - " + destination + ".a)");

            case Q3BSPBlendFuncFactor.DestinationAlpha:
                return(side + " * " + destination + ".a");

            case Q3BSPBlendFuncFactor.InverseDestinationAlpha:
                return(side + " * (1.0 -" + destination + ".a)");

            case Q3BSPBlendFuncFactor.Source:
                return(side + " * " + source);

            case Q3BSPBlendFuncFactor.InverseSource:
                return(side + " * float4(1.0 - " + source + ".r, 1.0 - " + source + ".g, 1.0 - " + source + ".b, 1.0 - " + source + ".a)");

            case Q3BSPBlendFuncFactor.SourceAlpha:
                return(side + " * " + source + ".a");

            case Q3BSPBlendFuncFactor.InverseSourceAlpha:
                return(side + " * (1.0 -" + source + ".a)");

            default:
                return(side);
            }
        }
 /// <summary>
 /// Validates the input blend factors and assigns them to the material stage.
 /// </summary>
 public void SetBlendFunction(Q3BSPBlendFuncFactor sourceBlendFactor, Q3BSPBlendFuncFactor destinationBlendFactor)
 {
     this.SourceBlendFactor      = sourceBlendFactor;
     this.DestinationBlendFactor = destinationBlendFactor;
 }