Exemplo n.º 1
0
        public override SubscriberBase GetSubscriberInstance(EffectVariable variable, RenderContext context, MMEEffectManager effectManager, int semanticIndex)
        {
            EffectVariable annotation = EffectParseHelper.getAnnotation(variable, "Object", "string");

            if (annotation == null || string.IsNullOrWhiteSpace(annotation.AsString().GetString()))
            {
                throw new InvalidMMEEffectShaderException(
                          string.Format(
                              "変数「{0} {1}:{2}」にはアノテーション「string Object=\"Light\"」または「string object=\"Camera\"」が必須ですが指定されませんでした。",
                              variable.GetVariableType().Description.TypeName.ToLower(), variable.Description.Name,
                              variable.Description.Semantic));
            }
            string objectStr = annotation.AsString().GetString().ToLower();
            ObjectAnnotationType type;

            switch (objectStr)
            {
            case "camera":
                type = ObjectAnnotationType.Camera;
                break;

            case "light":
                type = ObjectAnnotationType.Light;
                break;

            default:
                throw new InvalidMMEEffectShaderException(
                          string.Format(
                              "変数「{0} {1}:{2}」にはアノテーション「string Object=\"Light\"」または「string object=\"Camera\"」が必須ですが指定されたのは,「string object=\"{3}\"でした。(スペルミス?)"
                              , variable.GetVariableType().Description.TypeName.ToLower(), variable.Description.Name,
                              variable.Description.Semantic, objectStr));
            }
            return(GetSubscriberInstance(type));
        }
Exemplo n.º 2
0
        /// <summary>
        ///     If the matrix each examine the Camera or Light?
        /// </summary>
        /// <param name="variable"></param>
        /// <param name="context"></param>
        /// <param name="effectManager"></param>
        /// <param name="semanticIndex"></param>
        /// <param name="effect">Effect of test</param>
        /// <param name="index">Inspect variable index</param>
        /// <returns></returns>
        public override SubscriberBase GetSubscriberInstance(EffectVariable variable, RenderContext context, MMEEffectManager effectManager, int semanticIndex)
        {
            string         obj;
            EffectVariable annotation = EffectParseHelper.getAnnotation(variable, "Object", "string");

            obj = annotation == null ? "" : annotation.AsString().GetString(); //The annotation is not present""とする
            if (string.IsNullOrWhiteSpace(obj))
            {
                return(GetSubscriberInstance(ObjectAnnotationType.Camera));
            }
            switch (obj.ToLower())
            {
            case "camera":
                return(GetSubscriberInstance(ObjectAnnotationType.Camera));

            case "light":
                return(GetSubscriberInstance(ObjectAnnotationType.Light));

            case "":
                throw new InvalidMMEEffectShaderException(
                          string.Format(
                              "変数「{0} {1}:{2}」には、アノテーション「string Object=\"Camera\"」または、「string Object=\"Light\"」が必須ですが指定されませんでした。",
                              variable.GetVariableType().Description.TypeName.ToLower(), variable.Description.Name,
                              variable.Description.Semantic));

            default:
                throw new InvalidMMEEffectShaderException(
                          string.Format(
                              "変数「{0} {1}:{2}」には、アノテーション「string Object=\"Camera\"」または、「string Object=\"Light\"」が必須ですが指定されたのは「string Object=\"{3}\"」でした。(スペルミス?)",
                              variable.GetVariableType().Description.TypeName.ToLower(), variable.Description.Name,
                              variable.Description.Semantic, obj));
            }
        }
Exemplo n.º 3
0
        public override SubscriberBase GetSubscriberInstance(EffectVariable variable, RenderContext context, MMEEffectManager effectManager, int semanticIndex)
        {
            bool isVector3 =
                variable.GetVariableType().Description.TypeName.ToLower().Equals("float3");

            if (!NeedAnnotation.Contains(Semantics))
            {
                return(GetSubscriberInstance(TargetObject.UnUsed, isVector3));
            }
            EffectVariable objectAnnotation = EffectParseHelper.getAnnotation(variable, "Object", "string");

            if (objectAnnotation == null)
            {
                throw new InvalidMMEEffectShaderException(
                          string.Format("このセマンティクス\"{0}\"にはアノテーション「Object」が必須ですが、記述されませんでした。", Semantics));
            }
            string annotation = objectAnnotation.AsString().GetString().ToLower();

            if (!string.IsNullOrWhiteSpace(annotation))
            {
                switch (annotation)
                {
                case "geometry":
                    return(GetSubscriberInstance(TargetObject.Geometry, isVector3));

                case "light":
                    return(GetSubscriberInstance(TargetObject.Light, isVector3));

                default:
                    throw new InvalidMMEEffectShaderException(string.Format("アノテーション\"{0}\"は認識されません。", annotation));
                }
            }
            throw new InvalidMMEEffectShaderException(
                      string.Format("このセマンティクス\"{0}\"にはアノテーション「Object」が必須ですが、記述されませんでした。", Semantics));
        }
Exemplo n.º 4
0
        public override 数管理  数登録インスタンスを生成して返す(EffectVariable variable, エフェクト effect, int semanticIndex)
        {
            // 行列の場合は、それぞれCameraかLightか調べる。

            EffectVariable Objectアノテーション = EffectParseHelper.アノテーションを取得する(variable, "Object", "string");

            string obj = (Objectアノテーション == null) ? "" : Objectアノテーション.AsString().GetString();               // アノテーションが存在しない時は""とする

            switch (obj.ToLower())
            {
            case "camera":
                return(行列変数登録インスタンスを生成して返す(Object種別.カメラ));

            case "light":
                return(行列変数登録インスタンスを生成して返す(Object種別.ライト));

            case "":
                return(行列変数登録インスタンスを生成して返す(Object種別.カメラ));        // 既定値

            default:
                throw new InvalidMMEEffectShader例外(
                          $"変数「{variable.TypeInfo.Description.TypeName.ToLower()} {variable.Description.Name}:{variable.Description.Semantic}」には、" +
                          $"アノテーション「string Object=\"Camera\"」または、「string Object=\"Light\"」が必須ですが指定されたのは「string Object=\"{obj}\"」でした。(スペルミス?)");
            }
        }
Exemplo n.º 5
0
        public override 数管理  数登録インスタンスを生成して返す(EffectVariable variable, エフェクト effectManager, int semanticIndex)
        {
            // アノテーション "string Object = ..." を取得

            EffectVariable annotation = EffectParseHelper.アノテーションを取得する(variable, "Object", "string");

            if (annotation == null || string.IsNullOrWhiteSpace(annotation.AsString().GetString()))
            {
                throw new InvalidMMEEffectShader例外(
                          string.Format(
                              "変数「{0} {1}:{2}」にはアノテーション「string Object=\"Light\"」または「string object=\"Camera\"」が必須ですが指定されませんでした。",
                              variable.TypeInfo.Description.TypeName.ToLower(), variable.Description.Name,
                              variable.Description.Semantic));
            }


            // Object の内容で type を決める。

            Object種別 type;
            string   objectStr = annotation.AsString().GetString().ToLower();

            switch (objectStr)
            {
            case "camera":
                type = Object種別.カメラ;
                break;

            case "light":
                type = Object種別.ライト;
                break;

            default:
                throw new InvalidMMEEffectShader例外(
                          string.Format(
                              "変数「{0} {1}:{2}」にはアノテーション「string Object=\"Light\"」または「string object=\"Camera\"」が必須ですが指定されたのは,「string object=\"{3}\"でした。(スペルミス?)",
                              variable.TypeInfo.Description.TypeName.ToLower(),
                              variable.Description.Name,
                              variable.Description.Semantic,
                              objectStr));
            }


            // 決定された type へ引き継ぐ。

            return(GetSubscriberInstance(type));
        }
Exemplo n.º 6
0
        /// <summary>
        ///     Gets the annotation techniques specified in string
        /// </summary>
        /// <param name="technique">Techniques</param>
        /// <param name="attrName">Annotation name</param>
        /// <returns>Value</returns>
        public static string getAnnotationString(EffectTechnique technique, string attrName)
        {
            EffectVariable annotationVariable = getAnnotation(technique, attrName, "string");

            if (annotationVariable == null)
            {
                return("");
            }
            return(annotationVariable.AsString().GetString());
        }
Exemplo n.º 7
0
        /// <summary>
        ///     指定したテクニックの指定したアノテーションを文字列で取得します
        /// </summary>
        /// <param name="technique">テクニック</param>
        /// <param name="attrName">アノテーション名</param>
        /// <returns>値</returns>
        public string getAnnotationString(EffectTechnique technique, string attrName)
        {
            EffectVariable annotationVariable = EffectParseHelper.アノテーションを取得する(technique, attrName);

            if (annotationVariable == null)
            {
                return("");
            }

            return(annotationVariable.AsString().GetString());
        }
Exemplo n.º 8
0
        public MMEEffectPass(RenderContext context, MMEEffectManager manager, EffectPass pass)
        {
            this.context = context;
            this.Pass    = pass;
            EffectVariable commandAnnotation = EffectParseHelper.getAnnotation(pass, "Script", "string");

            this.Command = commandAnnotation == null ? "" : commandAnnotation.AsString().GetString();
            if (!pass.VertexShaderDescription.Variable.IsValid)
            {
                //TODO この場合標準シェーダーの頂点シェーダを利用する
            }
            if (!pass.PixelShaderDescription.Variable.IsValid)
            {
                //TODO この場合標準シェーダーのピクセルシェーダを利用する
            }
            this.ScriptRuntime = new ScriptRuntime(this.Command, context, manager, this);
        }
Exemplo n.º 9
0
        public override 数管理  数登録インスタンスを生成して返す(EffectVariable d3dEffectVariable, エフェクト effect, int semanticIndex)
        {
            bool isVector3 = d3dEffectVariable.TypeInfo.Description.TypeName.ToLower().Equals("float3");


            if (!_Objectアノテーションが必須なセマンティクス.Contains(セマンティクス))
            {
                // (A) Object アノテーションが不要なセマンティクスの場合

                return(材質変数登録インスタンスを生成して返す(ターゲット種別.未使用, isVector3));
            }
            else
            {
                // (B) Object アノテーションが必須のセマンティクスの場合

                EffectVariable Objectアノテーション = EffectParseHelper.アノテーションを取得する(d3dEffectVariable, "Object", "string");

                if (Objectアノテーション == null)
                {
                    throw new InvalidMMEEffectShader例外($"このセマンティクス\"{セマンティクス}\"にはアノテーション「Object」が必須ですが、記述されませんでした。");
                }

                string annotation = Objectアノテーション.AsString().GetString().ToLower();

                if (string.IsNullOrWhiteSpace(annotation))
                {
                    throw new InvalidMMEEffectShader例外($"このセマンティクス\"{セマンティクス}\"にはアノテーション「Object」が必須ですが、記述されませんでした。");
                }

                switch (annotation)
                {
                case "geometry":
                    return(材質変数登録インスタンスを生成して返す(ターゲット種別.ジオメトリ, isVector3));

                case "light":
                    return(材質変数登録インスタンスを生成して返す(ターゲット種別.ライト, isVector3));

                default:
                    throw new InvalidMMEEffectShader例外($"アノテーション\"{annotation}\"は認識されません。");
                }
            }
        }
Exemplo n.º 10
0
        public パス(エフェクト effect, EffectPass d3dPass)
        {
            D3DPass = d3dPass;

            EffectVariable commandAnnotation = EffectParseHelper.アノテーションを取得する(d3dPass, "Script", "string");

            Command = (commandAnnotation == null) ? "" : commandAnnotation.AsString().GetString();

            if (!d3dPass.VertexShaderDescription.Variable.IsValid)
            {
                //TODO この場合標準シェーダーの頂点シェーダを利用する
            }

            if (!d3dPass.PixelShaderDescription.Variable.IsValid)
            {
                //TODO この場合標準シェーダーのピクセルシェーダを利用する
            }

            ScriptRuntime = new ScriptRuntime(Command, effect, null, this);
        }
Exemplo n.º 11
0
        public ImageShaderPass(EffectPass pd)
        {
            this.Mips         = false;
            this.CustomFormat = false;
            this.Scale        = 1.0f;
            this.DoScale      = false;
            this.Reference    = eImageScaleReference.Previous;

            this.ComputeData = new ImageComputeData(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)
            {
                this.Scale   = var.AsScalar().GetFloat();
                this.DoScale = true;
            }

            var = pd.GetAnnotationByName("initial");
            if (var.IsValid)
            {
                bool b = var.AsScalar().GetFloat() > 0.5f;
                this.Reference = b ? eImageScaleReference.Initial : eImageScaleReference.Previous;
            }
        }
Exemplo n.º 12
0
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="technique"></param>
        /// <param name="subsetCount"></param>
        /// <param name="context"></param>
        public MMEEffectTechnique(MMEEffectManager manager, EffectTechnique technique, int subsetCount,
                                  RenderContext context)
        {
            this.Subset = new HashSet <int>();
            this.Passes = new Dictionary <string, MMEEffectPass>();
            if (!technique.IsValid)
            {
                throw new InvalidMMEEffectShaderException(string.Format("テクニック「{0}」の検証に失敗しました。",
                                                                        technique.Description.Name));
            }
            //Loading MMDPass
            string mmdpass = EffectParseHelper.getAnnotationString(technique, "MMDPass");

            if (String.IsNullOrWhiteSpace(mmdpass))
            {
                this.MMDPassAnnotation = MMEEffectPassType.Object;
            }
            else
            {
                mmdpass = mmdpass.ToLower();
                switch (mmdpass)
                {
                case "object":
                    this.MMDPassAnnotation = MMEEffectPassType.Object;
                    break;

                case "object_ss":
                    this.MMDPassAnnotation = MMEEffectPassType.Object_SelfShadow;
                    break;

                case "zplot":
                    this.MMDPassAnnotation = MMEEffectPassType.ZPlot;
                    break;

                case "shadow":
                    this.MMDPassAnnotation = MMEEffectPassType.Shadow;
                    break;

                case "edge":
                    this.MMDPassAnnotation = MMEEffectPassType.Edge;
                    break;

                default:
                    throw new InvalidOperationException("予期しない識別子");
                }
            }
            //Loading UseTexture
            this.UseTexture    = EffectParseHelper.getAnnotationBoolean(technique, "UseTexture");
            this.UseSphereMap  = EffectParseHelper.getAnnotationBoolean(technique, "UseSphereMap");
            this.UseToon       = EffectParseHelper.getAnnotationBoolean(technique, "UseToon");
            this.UseSelfShadow = EffectParseHelper.getAnnotationBoolean(technique, "UseSelfShadow");
            this.MulSphere     = EffectParseHelper.getAnnotationBoolean(technique, "MulSphere");
            GetSubsets(technique, subsetCount);
            EffectVariable rawScript = EffectParseHelper.getAnnotation(technique, "Script", "string");

            for (int i = 0; i < technique.Description.PassCount; i++)
            {
                EffectPass pass = technique.GetPassByIndex(i);
                this.Passes.Add(pass.Description.Name, new MMEEffectPass(context, manager, pass));
            }
            if (rawScript != null)
            {
                this.ScriptRuntime = new ScriptRuntime(rawScript.AsString().GetString(), context, manager, this);
            }
            else
            {
                this.ScriptRuntime = new ScriptRuntime("", context, manager, this);
            }
        }
Exemplo n.º 13
0
        public ImageShaderPass(EffectPass pd)
        {
            this.Mips         = false;
            this.CustomFormat = false;
            this.Scale        = 1.0f;
            this.DoScale      = false;
            this.Reference    = eImageScaleReference.Previous;
            this.BlendPreset  = "";
            this.DepthPreset  = "";
            this.UseDepth     = false;
            this.HasState     = false;
            this.KeepTarget   = false;


            this.ComputeData = new ImageComputeData(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)
            {
                this.Scale   = var.AsScalar().GetFloat();
                this.DoScale = true;
            }

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

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

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

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

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


            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;
            }
        }
Exemplo n.º 14
0
        public override SubscriberBase GetSubscriberInstance(EffectVariable variable, RenderContext context, MMEEffectManager effectManager, int semanticIndex)
        {
            TextureSubscriber subscriber = new TextureSubscriber();
            int    width, height, depth, mip;
            string typeName = variable.GetVariableType().Description.TypeName.ToLower();
            string type;
            Format format;

            TextureAnnotationParser.GetBasicTextureAnnotations(variable, context, Format.B8G8R8A8_UNorm, Vector2.Zero, true,
                                                               out width, out height, out depth, out mip, out format);
            EffectVariable rawTypeVariable   = EffectParseHelper.getAnnotation(variable, "ResourceType", "string");
            EffectVariable rawStringVariable = EffectParseHelper.getAnnotation(variable, "ResourceName", "string");

            if (rawTypeVariable != null)
            {
                switch (rawTypeVariable.AsString().GetString().ToLower())
                {
                case "cube":
                    if (!typeName.Equals("texturecube"))
                    {
                        throw new InvalidMMEEffectShaderException("ResourceTypeにはCubeが指定されていますが、型がtextureCUBEではありません。");
                    }
                    else
                    {
                        type = "texturecube";
                    }
                    break;

                case "2d":
                    if (!typeName.Equals("texture2d") && !typeName.Equals("texture"))
                    {
                        throw new InvalidMMEEffectShaderException("ResourceTypeには2Dが指定されていますが、型がtexture2Dもしくはtextureではありません。");
                    }
                    else
                    {
                        type = "texture2d";
                    }
                    break;

                case "3d":
                    if (!typeName.Equals("texture3d"))
                    {
                        throw new InvalidMMEEffectShaderException("ResourceTypeには3Dが指定されていますが、型がtexture3dではありません。");
                    }
                    else
                    {
                        type = "texture3d";
                    }
                    break;

                default:
                    throw new InvalidMMEEffectShaderException("認識できないResourceTypeが指定されました。");
                }
            }
            else
            {
                type = typeName;
            }
            if (rawStringVariable != null)
            {
                string resourceName          = rawStringVariable.AsString().GetString();
                ImageLoadInformation imgInfo = new ImageLoadInformation();
                Stream stream;
                switch (type)
                {
                case "texture2d":

                    imgInfo.Width          = width;
                    imgInfo.Height         = height;
                    imgInfo.MipLevels      = mip;
                    imgInfo.Format         = format;
                    imgInfo.Usage          = ResourceUsage.Default;
                    imgInfo.BindFlags      = BindFlags.ShaderResource;
                    imgInfo.CpuAccessFlags = CpuAccessFlags.None;
                    stream = effectManager.SubresourceLoader.getSubresourceByName(resourceName);
                    if (stream != null)
                    {
                        subscriber.resourceTexture = Texture2D.FromStream(context.DeviceManager.Device, stream, (int)stream.Length);
                    }
                    break;

                case "texture3d":
                    imgInfo.Width          = width;
                    imgInfo.Height         = height;
                    imgInfo.Depth          = depth;
                    imgInfo.MipLevels      = mip;
                    imgInfo.Format         = format;
                    imgInfo.Usage          = ResourceUsage.Default;
                    imgInfo.BindFlags      = BindFlags.ShaderResource;
                    imgInfo.CpuAccessFlags = CpuAccessFlags.None;
                    stream = effectManager.SubresourceLoader.getSubresourceByName(resourceName);
                    if (stream != null)
                    {
                        subscriber.resourceTexture = Texture3D.FromStream(context.DeviceManager.Device, stream, (int)stream.Length);
                    }
                    break;

                case "texturecube":
                    //TODO CUBEの場合に対応する
                    //imgInfo.Width = width;
                    //imgInfo.Height = height;
                    //imgInfo.Depth = depth;
                    //imgInfo.MipLevels = mip;
                    //imgInfo.Format = format;
                    //imgInfo.Usage=ResourceUsage.Default;
                    //imgInfo.BindFlags=BindFlags.ShaderResource;
                    //imgInfo.CpuAccessFlags=CpuAccessFlags.None;
                    //stream = effectManager.SubresourceLoader.getSubresourceByName(resourceName);
                    //subscriber.resourceTexture=.FromStream(context.DeviceManager.Device, stream, (int)stream.Length);
                    break;
                }
            }
            subscriber.resourceView = new ShaderResourceView(context.DeviceManager.Device, subscriber.resourceTexture);
            return(subscriber);
        }
Exemplo n.º 15
0
        /// <summary>
        ///     コンストラクタ
        /// </summary>
        /// <param name="effect"></param>
        /// <param name="D3DEffectTechnique"></param>
        /// <param name="subsetCount"></param>
        public テクニック(エフェクト effect, EffectTechnique d3dEffectTechnique, int subsetCount)
        {
            D3DEffectTechnique = d3dEffectTechnique;

            描画するサブセットIDの集合 = new HashSet <int>();

            パスリスト = new Dictionary <string, パス>();

            if (!D3DEffectTechnique.IsValid)
            {
                throw new InvalidMMEEffectShader例外(string.Format("テクニック「{0}」の検証に失敗しました。", D3DEffectTechnique.Description.Name));
            }


            // MMDPass アノテーション

            string mmdpass = getAnnotationString(D3DEffectTechnique, "MMDPass");

            if (String.IsNullOrWhiteSpace(mmdpass))
            {
                テクニックを適用する描画対象 = MMDPass種別.オブジェクト本体;
            }
            else
            {
                mmdpass = mmdpass.ToLower();
                switch (mmdpass)
                {
                case "object":
                    テクニックを適用する描画対象 = MMDPass種別.オブジェクト本体;
                    break;

                case "object_ss":
                    テクニックを適用する描画対象 = MMDPass種別.オブジェクト本体_セルフ影あり;
                    break;

                case "zplot":
                    テクニックを適用する描画対象 = MMDPass種別.セルフ影用Z値プロット;
                    break;

                case "shadow":
                    テクニックを適用する描画対象 = MMDPass種別.影;
                    break;

                case "edge":
                    テクニックを適用する描画対象 = MMDPass種別.エッジ;
                    break;

                case "skinning":
                    テクニックを適用する描画対象 = MMDPass種別.スキニング;
                    break;

                case "scene":
                    テクニックを適用する描画対象 = MMDPass種別.シーン;
                    break;

                default:
                    throw new InvalidOperationException("予期しない識別子");
                }
            }


            // その他アノテーション

            テクスチャを使用する = getAnnotationBoolean(D3DEffectTechnique, "UseTexture");

            スフィアマップを使用する = getAnnotationBoolean(D3DEffectTechnique, "UseSphereMap");

            トゥーンレンダリングを使用する = getAnnotationBoolean(D3DEffectTechnique, "UseToon");

            セルフ影を使用する = getAnnotationBoolean(D3DEffectTechnique, "UseSelfShadow");

            乗算スフィアを使用する = getAnnotationBoolean(D3DEffectTechnique, "MulSphere");


            // Subset アノテーション

            GetSubsets(D3DEffectTechnique, subsetCount);


            // Script アノテーション

            EffectVariable rawScript = EffectParseHelper.アノテーションを取得する(D3DEffectTechnique, "Script");

            for (int i = 0; i < D3DEffectTechnique.Description.PassCount; i++)
            {
                EffectPass pass = D3DEffectTechnique.GetPassByIndex(i);
                パスリスト.Add(pass.Description.Name, new パス(effect, pass));
            }


            // Scriptランタイムの生成

            if (rawScript != null)
            {
                ScriptRuntime = new ScriptRuntime(rawScript.AsString().GetString(), effect, this);     // Script アノテーションがあれば登録する
            }
            else
            {
                ScriptRuntime = new ScriptRuntime("", effect, this);
            }
        }
Exemplo n.º 16
0
        public override SubscriberBase GetSubscriberInstance(EffectVariable variable, RenderContext context, MMEEffectManager effectManager, int semanticIndex)
        {
            VariableType type     = 0;
            TargetObject target   = TargetObject.UnUsed;
            string       itemName = null;
            string       typeName = variable.GetVariableType().Description.TypeName.ToLower();

            switch (typeName)
            {
            case "bool":
                type = VariableType.Bool;
                break;

            case "float":
                type = VariableType.Float;
                break;

            case "float3":
                type = VariableType.Float3;
                break;

            case "float4":
                type = VariableType.Float4;
                break;

            case "float4x4":
                type = VariableType.Float4x4;
                break;

            default:
                break;
            }
            EffectVariable nameVariable = EffectParseHelper.getAnnotation(variable, "name", "string");

            if (nameVariable == null)
            {
                throw new InvalidMMEEffectShaderException(
                          string.Format("定義済みセマンティクス「CONTROLOBJECT」の適用されている変数「{0} {1}:CONTROLOBJECT」に対してはアノテーション「string name」は必須ですが、指定されませんでした。", typeName, variable.Description.Name));
            }
            string name = nameVariable.AsString().GetString();

            //Selfの場合はターゲットは自分自身となる
            if (name.ToLower().Equals("(self)"))
            {
                isSelf = true;
            }
            else
            {
            }
            //TODO (OffscreenOwner)がnameに指定されたときの対応
            EffectVariable itemVariable = EffectParseHelper.getAnnotation(variable, "item", "string");

            if (itemVariable != null)
            {
                itemName = itemVariable.AsString().GetString();
                switch (itemName.ToLower())
                {
                case "x":
                    target = TargetObject.X;
                    break;

                case "y":
                    target = TargetObject.Y;
                    break;

                case "z":
                    target = TargetObject.Z;
                    break;

                case "xyz":
                    target = TargetObject.XYZ;
                    break;

                case "rx":
                    target = TargetObject.Rx;
                    break;

                case "ry":
                    target = TargetObject.Ry;
                    break;

                case "rz":
                    target = TargetObject.Rz;
                    break;

                case "rxyz":
                    target = TargetObject.Rxyz;
                    break;

                case "si":
                    target = TargetObject.Si;
                    break;

                case "tr":
                    target = TargetObject.Tr;
                    break;

                default:
                    target = type == VariableType.Float ? TargetObject.FaceName : TargetObject.BoneName;
                    break;
                }
                if (NeedFloat.Contains(target) && type != VariableType.Float)
                {
                    throw new InvalidMMEEffectShaderException(
                              string.Format("定義済みセマンティクス「CONTROLOBJECT」の適用されている変数「{0} {1}:CONTROLOBJECT」にはアノテーション「string item=\"{2}\"」が適用されていますが、「{2}」の場合は「float {1}:CONTROLOBJECT」である必要があります。", typeName, variable.Description.Name, itemName));
                }
                if (NeedFloat3.Contains(target) && type != VariableType.Float3)
                {
                    throw new InvalidMMEEffectShaderException(
                              string.Format("定義済みセマンティクス「CONTROLOBJECT」の適用されている変数「{0} {1}:CONTROLOBJECT」にはアノテーション「string item=\"{2}\"」が適用されていますが、「{2}」の場合は「float3 {1}:CONTROLOBJECT」である必要があります。", typeName, variable.Description.Name, itemName));
                }
            }
            return(new ControlObjectSubscriber(type, itemName, name, target, isSelf));
        }
Exemplo n.º 17
0
        public override 数管理  数登録インスタンスを生成して返す(EffectVariable variable, エフェクト effect, int semanticIndex)
        {
            数型           type     = 0;
            TargetObject target   = TargetObject.UnUsed;
            string       itemName = null;
            string       typeName = variable.TypeInfo.Description.TypeName.ToLower();

            switch (typeName)
            {
            case "bool":
                type = 数型.Bool;
                break;

            case "float":
                type = 数型.Float;
                break;

            case "float3":
                type = 数型.Float3;
                break;

            case "float4":
                type = 数型.Float4;
                break;

            case "float4x4":
                type = 数型.Float4x4;
                break;

            default:
                break;
            }

            EffectVariable nameVariable = EffectParseHelper.アノテーションを取得する(variable, "name", "string");

            if (nameVariable == null)
            {
                throw new InvalidMMEEffectShader例外($"定義済みセマンティクス「CONTROLOBJECT」の適用されている変数「{typeName} {variable.Description.Name}:CONTROLOBJECT」に対してはアノテーション「string name」は必須ですが、指定されませんでした。");
            }

            string name = nameVariable.AsString().GetString();

            // Selfの場合はターゲットは自分自身となる

            if (name.ToLower().Equals("(self)"))
            {
                _isSelf = true;
            }
            else
            {
                // TODO: (OffscreenOwner)がnameに指定されたときの対応
            }


            EffectVariable itemVariable = EffectParseHelper.アノテーションを取得する(variable, "item", "string");

            if (itemVariable != null)
            {
                itemName = itemVariable.AsString().GetString();

                switch (itemName.ToLower())
                {
                case "x":
                    target = TargetObject.X;
                    break;

                case "y":
                    target = TargetObject.Y;
                    break;

                case "z":
                    target = TargetObject.Z;
                    break;

                case "xyz":
                    target = TargetObject.XYZ;
                    break;

                case "rx":
                    target = TargetObject.Rx;
                    break;

                case "ry":
                    target = TargetObject.Ry;
                    break;

                case "rz":
                    target = TargetObject.Rz;
                    break;

                case "rxyz":
                    target = TargetObject.Rxyz;
                    break;

                case "si":
                    target = TargetObject.Si;
                    break;

                case "tr":
                    target = TargetObject.Tr;
                    break;

                default:
                    target = type == 数型.Float ? TargetObject.FaceName : TargetObject.BoneName;
                    break;
                }

                if (NeedFloat.Contains(target) && type != 数型.Float)
                {
                    throw new InvalidMMEEffectShader例外($"定義済みセマンティクス「CONTROLOBJECT」の適用されている変数「{typeName} {variable.Description.Name}:CONTROLOBJECT」にはアノテーション「string item=\"{itemName}\"」が適用されていますが、「{itemName}」の場合は「float {variable.Description.Name}:CONTROLOBJECT」である必要があります。");
                }

                if (NeedFloat3.Contains(target) && type != 数型.Float3)
                {
                    throw new InvalidMMEEffectShader例外($"定義済みセマンティクス「CONTROLOBJECT」の適用されている変数「{typeName} {variable.Description.Name}:CONTROLOBJECT」にはアノテーション「string item=\"{itemName}\"」が適用されていますが、「{itemName}」の場合は「float3 {variable.Description.Name}:CONTROLOBJECT」である必要があります。");
                }
            }

            return(new CONTROLOBJECT変数(type, itemName, name, target, _isSelf));
        }
Exemplo n.º 18
0
        public override 数管理  数登録インスタンスを生成して返す(EffectVariable variable, エフェクト effect, int semanticIndex)
        {
            var    subscriber = new テクスチャ変数();
            string typeName   = variable.TypeInfo.Description.TypeName.ToLower();

            int    width, height, depth, mip;
            Format textureFormat, viewFormat, resourceFormat;

            テクスチャのアノテーション解析.解析する(variable, Format.B8G8R8A8_UNorm, Vector2.Zero, true, out width, out height, out depth, out mip, out textureFormat, out viewFormat, out resourceFormat);

            EffectVariable rawTypeVariable   = EffectParseHelper.アノテーションを取得する(variable, "ResourceType", "string");
            EffectVariable rawStringVariable = EffectParseHelper.アノテーションを取得する(variable, "ResourceName", "string");


            // type を決定

            string type;

            if (rawTypeVariable != null)
            {
                switch (rawTypeVariable.AsString().GetString().ToLower())
                {
                case "cube":
                    type = (typeName.Equals("texturecube")) ? "texturecube" : throw new InvalidMMEEffectShader例外("ResourceTypeにはCubeが指定されていますが、型がtextureCUBEではありません。");
                    break;

                case "2d":
                    type = (typeName.Equals("texture2d") || typeName.Equals("texture")) ? "texture2d" : throw new InvalidMMEEffectShader例外("ResourceTypeには2Dが指定されていますが、型がtexture2Dもしくはtextureではありません。");
                    break;

                case "3d":
                    type = (typeName.Equals("texture3d")) ? "texture3d" : throw new InvalidMMEEffectShader例外("ResourceTypeには3Dが指定されていますが、型がtexture3dではありません。");
                    break;

                default:
                    throw new InvalidMMEEffectShader例外("認識できないResourceTypeが指定されました。");
                }
            }
            else
            {
                type = typeName;
            }


            // テクスチャリソースを読み込む

            if (rawStringVariable != null)
            {
                string resourceName = rawStringVariable.AsString().GetString();
                Stream stream;

                switch (type)
                {
                case "texture2d":
                    stream = effect.テクスチャなどのパスの解決に利用するローダー.リソースのストリームを返す(resourceName);
                    if (stream != null)
                    {
                        subscriber._resourceTexture = MMFTexture2D.FromStream(RenderContext.Instance.DeviceManager.D3DDevice, stream);
                    }
                    break;

                case "texture3d":
                    stream = effect.テクスチャなどのパスの解決に利用するローダー.リソースのストリームを返す(resourceName);
                    if (stream != null)
                    {
                        subscriber._resourceTexture = MMFTexture3D.FromStream(RenderContext.Instance.DeviceManager.D3DDevice, stream);
                    }
                    break;

                case "texturecube":
                    //TODO CUBEの場合を実装する
                    //stream = effectManager.SubresourceLoader.getSubresourceByName(resourceName);
                    //subscriber.resourceTexture=.FromStream(context.DeviceManager.Device, stream, (int)stream.Length);
                    break;
                }
            }

            // シェーダーリソースビューを割り当て
            subscriber._resourceView = new ShaderResourceView(RenderContext.Instance.DeviceManager.D3DDevice, subscriber._resourceTexture);

            return(subscriber);
        }
Exemplo n.º 19
0
        /// <summary>
        /// テクスチャのアノテーション解釈に一般的に必要な項目を取得するメソッド
        /// </summary>
        /// <param name="variable">エフェクト変数</param>
        /// <param name="context">レンダーコンテキスト</param>
        /// <param name="defaultFormat"></param>
        /// <param name="defaultViewPortRatio"></param>
        /// <param name="width">テクスチャの幅</param>
        /// <param name="height">テクスチャの高さ</param>
        /// <param name="depth">テクスチャの深さ(ない場合は-1)</param>
        /// <param name="mip">mipレベル</param>
        /// <param name="textureFormat">指定されているフォーマット</param>
        public static void GetBasicTextureAnnotations(EffectVariable variable, RenderContext context, Format defaultFormat, Vector2 defaultViewPortRatio, bool isTextureSubscriber, out int width, out int height, out int depth,
                                                      out int mip, out Format textureFormat)
        {
            width         = -1;
            height        = -1;
            depth         = -1;
            mip           = 0;
            textureFormat = defaultFormat;
            EffectVariable rawWidthVal  = EffectParseHelper.getAnnotation(variable, "width", "int");
            EffectVariable rawHeightVal = EffectParseHelper.getAnnotation(variable, "height", "int");
            EffectVariable rawDepthVal  = EffectParseHelper.getAnnotation(variable, "depth", "int");

            if (rawWidthVal != null)
            {
                width = rawWidthVal.AsScalar().GetInt();
            }
            if (rawHeightVal != null)
            {
                height = rawHeightVal.AsScalar().GetInt();
            }
            if (rawDepthVal != null)
            {
                depth = rawDepthVal.AsScalar().GetInt();
            }
            EffectVariable rawViewportRatio = EffectParseHelper.getAnnotation(variable, "viewportratio", "float2");

            if (rawViewportRatio != null)
            {
                if (width != -1 || height != -1 || depth != -1)
                {
                    throw new InvalidMMEEffectShaderException(
                              string.Format("変数「{0} {1}」のサイズ指定が不正です。Width,Height,Depth/ViewportRatio/Dimensionsはそれぞれ同時に使用できません。",
                                            variable.GetVariableType().Description.TypeName.ToLower(), variable.Description.Name));
                }
                else
                {
                    Vector4  rawRatio = rawViewportRatio.AsVector().GetVector();
                    Viewport vp       = context.DeviceManager.Context.Rasterizer.GetViewports()[0];
                    width  = (int)(vp.Width * rawRatio.X);
                    height = (int)(vp.Height * rawRatio.Y);
                }
            }
            EffectVariable rawDimensions = EffectParseHelper.getAnnotation(variable, "dimension", "uint2/uint3");

            if (rawDimensions != null)
            {
                if (width != -1 || height != -1 || depth != -1)
                {
                    throw new InvalidMMEEffectShaderException(
                              string.Format(
                                  "変数「{0} {1}」のサイズ指定が不正です。Width,Height,Depth/ViewportRatio/Dimensionsはそれぞれ同時に使用できません。",
                                  variable.GetVariableType().Description.TypeName.ToLower(), variable.Description.Name));
                }
                else
                {
                    string typeName = rawDimensions.GetVariableType().Description.TypeName.ToLower();
                    if (typeName == "int2")
                    {
                        int[] rawDimension = rawDimensions.AsVector().GetIntVectorArray(2);
                        width  = rawDimension[0];
                        height = rawDimension[1];
                    }
                    else
                    {
                        int[] rawDimension = rawDimensions.AsVector().GetIntVectorArray(3);
                        width  = rawDimension[0];
                        height = rawDimension[1];
                        depth  = rawDimension[2];
                    }
                }
            }
            if (width == -1 || height == -1)
            {
                if (defaultViewPortRatio != Vector2.Zero)
                {
                    Viewport port = context.DeviceManager.Context.Rasterizer.GetViewports()[0];
                    width  = (int)(port.Width * defaultViewPortRatio.X);
                    height = (int)(port.Height * defaultViewPortRatio.Y);
                }
                else
                {
                    if (!isTextureSubscriber)
                    {
                        throw new InvalidMMEEffectShaderException(string.Format("width,heightのどちらかの指定は必須です。"));
                    }
                }
            }
            EffectVariable rawMipLevel = EffectParseHelper.getAnnotation(variable, "MipLevels", "int");
            EffectVariable rawLevel    = EffectParseHelper.getAnnotation(variable, "levels", "int");

            if (rawMipLevel != null && rawLevel != null)
            {
                throw new InvalidMMEEffectShaderException(
                          string.Format("変数「{0} {1}」のミップマップレベルが重複して指定されています。「int Miplevels」、「int Levels」は片方しか指定できません。",
                                        variable.GetVariableType().Description.TypeName.ToLower(), variable.Description.Name));
            }
            else if (rawMipLevel != null || rawLevel != null)
            {
                EffectVariable mipVal = rawMipLevel ?? rawLevel;
                mip = mipVal.AsScalar().GetInt();
            }
            EffectVariable rawFormat = EffectParseHelper.getAnnotation(variable, "format", "string");

            if (rawFormat != null)
            {
                string formatString = rawFormat.AsString().GetString();
                textureFormat = TextureFormat(formatString);
            }
        }
Exemplo n.º 20
0
        public ImageShaderPass(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.IterationCount = 1;

            this.ComputeData = new ImageComputeData(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;
            }

            var = pd.GetAnnotationByName("iterations");
            if (var.IsValid)
            {
                try
                {
                    int i = var.AsScalar().GetInt();

                    this.IterationCount = Math.Max(1, i);
                }
                catch
                {
                }
            }

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

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

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

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


            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;
            }
        }
Exemplo n.º 21
0
        private void ParseStandardGlobal(Effect effect, EffectVariable sg)
        {
            if (!sg.Description.Name.ToLower().Equals("script"))
            {
                throw new InvalidMMEEffectShaderException(
                          string.Format("STANDARDGLOBALセマンティクスの指定される変数名は\"Script\"である必要があります、指定された変数名は\"{0}\"でした。",
                                        sg.Description.Name));
            }
            if (!sg.GetVariableType().Description.TypeName.ToLower().Equals("float"))
            {
                throw new InvalidMMEEffectShaderException(
                          string.Format("STANDARDGLOBALセマンティクスの指定される変数型は\"float\"である必要があります、指定された変数名は\"{0}\"でした。",
                                        sg.GetVariableType().Description.TypeName.ToLower()));
            }
            if (sg.AsScalar().GetFloat() != 0.8f)
            {
                throw new InvalidMMEEffectShaderException(
                          string.Format("STANDARDGLOBALセマンティクスの指定される値は\"0.8\"である必要があります、指定された値は\"{0}\"でした。",
                                        sg.AsScalar().GetFloat()));
            }
            //ScriptOutput analysis
            EffectVariable soVal = EffectParseHelper.getAnnotation(sg, "ScriptOutput", "string");

            if (soVal != null)
            {
                if (!soVal.AsString().GetString().Equals("color"))
                {
                    throw new InvalidMMEEffectShaderException(
                              string.Format(
                                  "STANDARDGLOBALセマンティクスの指定される変数のアノテーション「string ScriptOutput」は、\"color\"でなくてはなりません。指定された値は\"{0}\"でした。",
                                  soVal.AsString().GetString().ToLower()));
                }
            }
            EffectVariable scVal = EffectParseHelper.getAnnotation(sg, "ScriptClass", "string");

            if (scVal != null)
            {
                string sc = scVal.AsString().GetString();
                switch (sc.ToLower())
                {
                case "object":
                    this.ScriptClass = ScriptClass.Object;
                    break;

                case "scene":
                    this.ScriptClass = ScriptClass.Scene;
                    break;

                case "sceneorobject":
                    this.ScriptClass = ScriptClass.SceneOrObject;
                    break;

                default:
                    throw new InvalidMMEEffectShaderException(
                              string.Format(
                                  "STANDARDGLOBALセマンティクスの指定される変数のアノテーション「string ScriptClass」は、\"object\",\"scene\",\"sceneorobject\"でなくてはなりません。指定された値は\"{0}\"でした。(スペルミス?)",
                                  sc.ToLower()));
                }
            }
            EffectVariable sorVal = EffectParseHelper.getAnnotation(sg, "ScriptOrder", "string");

            if (sorVal != null)
            {
                string sor = sorVal.AsString().GetString();
                switch (sor.ToLower())
                {
                case "standard":
                    this.ScriptOrder = ScriptOrder.Standard;
                    break;

                case "preprocess":
                    this.ScriptOrder = ScriptOrder.Preprocess;
                    break;

                case "postprocess":
                    this.ScriptOrder = ScriptOrder.Postprocess;
                    break;

                default:
                    throw new InvalidMMEEffectShaderException(
                              string.Format(
                                  "STANDARDGLOBALセマンティクスの指定される変数のアノテーション「string ScriptOrder」は、\"standard\",\"preprocess\",\"postprocess\"でなくてはなりません。指定された値は\"{0}\"でした。(スペルミス?)",
                                  sor.ToLower()));
                }
            }
            EffectVariable scrVal = EffectParseHelper.getAnnotation(sg, "Script", "string");

            if (scrVal != null)
            {
                this.StandardGlobalScript = scrVal.AsString().GetString();
                if (string.IsNullOrEmpty(this.StandardGlobalScript))
                {
                    for (int i = 0; i < effect.Description.TechniqueCount; i++)
                    {
                        this.SortedTechnique.Add(effect.GetTechniqueByIndex(i));
                    }
                }
                else
                {
                    string[] scriptChunks = this.StandardGlobalScript.Split(';');
                    if (scriptChunks.Length == 1)
                    {
                        throw new InvalidMMEEffectShaderException(
                                  string.Format("STANDARDGLOBALセマンティクスの指定される変数のスクリプト「{0}」は読み込めませんでした。\";\"が足りません。", this.StandardGlobalScript));
                    }
                    string targetScript = scriptChunks[scriptChunks.Length - 2]; //Non-script with a final semicolon is ignored
                    if (this.StandardGlobalScript.IndexOf("?") == -1)            //When not found
                    {
                        string[] args = targetScript.Split('=');
                        if (args.Length > 2)
                        {
                            throw new InvalidMMEEffectShaderException(
                                      string.Format("STANDARDGLOBALセマンティクスの指定される変数のスクリプト「{0}」は読み込めませんでした。\"=\"の数が多すぎます。",
                                                    targetScript));
                        }
                        if (!args[0].ToLower().Equals("technique"))
                        {
                            throw new InvalidMMEEffectShaderException(
                                      string.Format(
                                          "STANDARDGLOBALセマンティクスの指定される変数のスクリプト「{0}」は読み込めませんでした。\"{1}\"は\"Technique\"であるべきです。(スペルミス?)",
                                          targetScript, args[0]));
                        }
                        EffectTechnique technique = effect.GetTechniqueByName(args[1]);
                        if (technique != null)
                        {
                            this.SortedTechnique.Add(technique);
                        }
                        else
                        {
                            throw new InvalidMMEEffectShaderException(
                                      string.Format(
                                          "STANDARDGLOBALセマンティクスの指定される変数のスクリプト「{0}」は読み込めませんでした。テクニック\"{1}\"は存在しません。(スペルミス?)",
                                          targetScript, args[1]));
                        }
                    }
                    else //?が見つかるとき
                    {
                        string[] args = targetScript.Split('?');
                        if (args.Length == 2)
                        {
                            string[] techniques = args[1].Split(':');
                            foreach (string technique in techniques)
                            {
                                EffectTechnique effectTechnique = effect.GetTechniqueByName(technique);
                                if (effectTechnique != null)
                                {
                                    this.SortedTechnique.Add(effectTechnique);
                                }
                                else
                                {
                                    throw new InvalidMMEEffectShaderException(
                                              string.Format(
                                                  "STANDARDGLOBALセマンティクスの指定される変数のスクリプト「{0}」は読み込めませんでした。テクニック\"{1}\"は見つかりません。(スペルミス?)",
                                                  targetScript, technique));
                                }
                            }
                        }
                        else if (args.Length > 2)
                        {
                            throw new InvalidMMEEffectShaderException(
                                      string.Format("STANDARDGLOBALセマンティクスの指定される変数のスクリプト「{0}」は読み込めませんでした。\"?\"の数が多すぎます。",
                                                    targetScript));
                        }
                    }
                    if (scriptChunks.Length > 2)
                    {
                        Debug.WriteLine(
                            string.Format(
                                "STANDARDGLOBALセマンティクスの指定される変数のスクリプト「{0}」では、複数回Techniqueの代入が行われていますが、最後の代入以外は無視されます。", this.StandardGlobalScript));
                    }
                }
            }
        }
        /// <summary>
        /// テクスチャのアノテーション解釈に一般的に必要な項目を取得するメソッド
        /// </summary>
        /// <param name="variable">エフェクト変数</param>
        /// <param name="context">レンダーコンテキスト</param>
        /// <param name="defaultFormat"></param>
        /// <param name="defaultViewPortRatio"></param>
        /// <param name="width">テクスチャの幅</param>
        /// <param name="height">テクスチャの高さ</param>
        /// <param name="depth">テクスチャの深さ(ない場合は-1)</param>
        /// <param name="mip">mipレベル</param>
        /// <param name="textureFormat">指定されているフォーマット</param>
        public static void 解析する(EffectVariable variable, Format defaultFormat, Vector2 defaultViewPortRatio, bool isTextureSubscriber, out int width, out int height, out int depth, out int mip, out Format textureFormat, out Format viewFormat, out Format resourceFormat)
        {
            width          = -1;
            height         = -1;
            depth          = -1;
            mip            = 0;
            textureFormat  = defaultFormat;
            viewFormat     = defaultFormat;
            resourceFormat = defaultFormat;

            #region " int width = ... "
            //----------------
            EffectVariable rawWidthVal = EffectParseHelper.アノテーションを取得する(variable, "width", "int");
            if (rawWidthVal != null)
            {
                width = rawWidthVal.AsScalar().GetInt();
            }
            //----------------
            #endregion

            #region " int height = ... "
            //----------------
            EffectVariable rawHeightVal = EffectParseHelper.アノテーションを取得する(variable, "height", "int");
            if (rawHeightVal != null)
            {
                height = rawHeightVal.AsScalar().GetInt();
            }
            //----------------
            #endregion

            #region " int depth = ... "
            //----------------
            EffectVariable rawDepthVal = EffectParseHelper.アノテーションを取得する(variable, "depth", "int");
            if (rawDepthVal != null)
            {
                depth = rawDepthVal.AsScalar().GetInt();
            }
            //----------------
            #endregion

            #region " float2 ViewportRatio = ... "
            //----------------
            EffectVariable rawViewportRatio = EffectParseHelper.アノテーションを取得する(variable, "viewportratio", "float2");
            if (rawViewportRatio != null)

            {
                if (width != -1 || height != -1 || depth != -1)
                {
                    throw new InvalidMMEEffectShader例外(
                              string.Format("変数「{0} {1}」のサイズ指定が不正です。Width,Height,Depth/ViewportRatio/Dimensionsはそれぞれ同時に使用できません。", variable.TypeInfo.Description.TypeName.ToLower(), variable.Description.Name));
                }
                else
                {
                    Vector4 rawRatio = rawViewportRatio.AsVector().GetFloatVector();
                    var     vp       = RenderContext.Instance.DeviceManager.D3DDeviceContext.Rasterizer.GetViewports <ViewportF>()[0];
                    width  = (int)(vp.Width * rawRatio.X);
                    height = (int)(vp.Height * rawRatio.Y);
                }
            }
            //----------------
            #endregion

            #region " uing2/uint3 Dimensions = ... "
            //----------------
            EffectVariable rawDimensions = EffectParseHelper.アノテーションを取得する(variable, "dimensions", "uint2/uint3");

            if (rawDimensions != null)
            {
                if (width != -1 || height != -1 || depth != -1)
                {
                    throw new InvalidMMEEffectShader例外(
                              string.Format(
                                  "変数「{0} {1}」のサイズ指定が不正です。Width,Height,Depth/ViewportRatio/Dimensionsはそれぞれ同時に使用できません。",
                                  variable.TypeInfo.Description.TypeName.ToLower(), variable.Description.Name));
                }
                else
                {
                    string typeName = rawDimensions.TypeInfo.Description.TypeName.ToLower();
                    if (typeName == "int2")
                    {
                        var rawDimension = rawDimensions.AsVector().GetIntVector();
                        width  = rawDimension.X;
                        height = rawDimension.Y;
                    }
                    else
                    {
                        var rawDimension = rawDimensions.AsVector().GetIntVector();
                        width  = rawDimension.X;
                        height = rawDimension.Y;
                        depth  = rawDimension.Z;
                    }
                }
            }
            //----------------
            #endregion

            #region "width, height チェック "
            //----------------
            if (width == -1 || height == -1)
            {
                if (defaultViewPortRatio != Vector2.Zero)
                {
                    var port = RenderContext.Instance.DeviceManager.D3DDeviceContext.Rasterizer.GetViewports <ViewportF>()[0];
                    width  = (int)(port.Width * defaultViewPortRatio.X);
                    height = (int)(port.Height * defaultViewPortRatio.Y);
                }
                else
                {
                    if (!isTextureSubscriber)
                    {
                        throw new InvalidMMEEffectShader例外(string.Format("width,heightのどちらかの指定は必須です。"));
                    }
                }
            }
            //----------------
            #endregion

            #region " int MipLevels = ... / int RawLevel = ... "
            //----------------
            EffectVariable rawMipLevel = EffectParseHelper.アノテーションを取得する(variable, "MipLevels", "int");
            EffectVariable rawLevel    = EffectParseHelper.アノテーションを取得する(variable, "levels", "int");

            if (rawMipLevel != null && rawLevel != null)
            {
                throw new InvalidMMEEffectShader例外(
                          string.Format("変数「{0} {1}」のミップマップレベルが重複して指定されています。「int Miplevels」、「int Levels」は片方しか指定できません。",
                                        variable.TypeInfo.Description.TypeName.ToLower(), variable.Description.Name));
            }
            else if (rawMipLevel != null || rawLevel != null)
            {
                EffectVariable mipVal = rawMipLevel ?? rawLevel;
                mip = mipVal.AsScalar().GetInt();
            }
            //----------------
            #endregion

            #region " string Format = ... "
            //----------------
            EffectVariable rawFormat = EffectParseHelper.アノテーションを取得する(variable, "format", "string");

            if (rawFormat != null)
            {
                string formatString = rawFormat.AsString().GetString();
                テクスチャフォーマットを返す(formatString, out textureFormat, out viewFormat, out resourceFormat);
            }
            //----------------
            #endregion
        }