コード例 #1
0
        public ImageShaderPassInfo(EffectPass pd)
        {
            this.effectPass   = pd;
            this.Mips         = false;
            this.CustomFormat = false;
            this.ScaleVector  = new Vector2(1, 1);
            this.DoScale      = false;
            this.Reference    = eImageScaleReference.Previous;
            this.BlendPreset  = "";
            this.DepthPreset  = "";
            this.UseDepth     = false;
            this.HasState     = false;
            this.KeepTarget   = false;
            this.Absolute     = false;

            this.ComputeData = new ImagePassComputeInfo(pd);

            EffectVariable var = pd.GetAnnotationByName("format");

            if (var.IsValid)
            {
                string fmt = var.AsString().GetString();
                this.CustomFormat = true;
                this.Format       = (SlimDX.DXGI.Format)Enum.Parse(typeof(SlimDX.DXGI.Format), fmt, true);
            }

            var = pd.GetAnnotationByName("mips");
            if (var.IsValid)
            {
                bool b = var.AsScalar().GetFloat() > 0.5f;
                this.Mips = b;
            }

            var = pd.GetAnnotationByName("scale");
            if (var.IsValid)
            {
                if (var.GetVariableType().Description.Class == ShaderVariableClass.Scalar)
                {
                    float s = var.AsScalar().GetFloat();
                    this.ScaleVector = new Vector2(s, s);
                    this.DoScale     = true;
                }
                if (var.GetVariableType().Description.Class == ShaderVariableClass.Vector)
                {
                    Vector4 s = var.AsVector().GetVector();
                    this.ScaleVector = new Vector2(s.X, s.Y);
                    this.DoScale     = true;
                }
                var = pd.GetAnnotationByName("absolute");
                if (var.IsValid && var.GetVariableType().Description.Class == ShaderVariableClass.Scalar)
                {
                    this.Absolute = var.AsScalar().GetFloat() > 0.5f;
                }
            }

            var = pd.GetAnnotationByName("initial");
            if (var.IsValid)
            {
                bool b = var.AsScalar().GetFloat() > 0.5f;
                this.Reference = b ? eImageScaleReference.Initial : eImageScaleReference.Previous;
            }

            this.Clear      = pd.GetBoolPassAnnotationByName("clear", this.Clear);
            this.UseDepth   = pd.GetBoolPassAnnotationByName("usedepth", this.UseDepth);
            this.KeepTarget = pd.GetBoolPassAnnotationByName("keeptarget", this.KeepTarget);
            this.HasState   = pd.GetBoolPassAnnotationByName("hasstate", this.HasState);

            var = pd.GetAnnotationByName("blendpreset");
            if (var.IsValid)
            {
                string blend = var.AsString().GetString();
                this.BlendPreset = blend;
            }

            var = pd.GetAnnotationByName("depthpreset");
            if (var.IsValid)
            {
                string depth = var.AsString().GetString();
                this.DepthPreset = depth;
            }
        }