public override FunctionBase GetExecuterInstance(int index, string value, RenderContext context, ScriptRuntime runtime, MMEEffectManager manager, MMEEffectTechnique technique, MMEEffectPass pass) { DrawFunction func = new DrawFunction(); if (pass == null) { throw new InvalidMMEEffectShaderException(string.Format("Drawはテクニックのスクリプトに関して適用できません。")); } func.targetPass = pass; func.context = context.DeviceManager.Context; switch (value) { case "Geometry": func.isDrawGeometry = true; break; case "Buffer": func.isDrawGeometry = false; break; default: throw new InvalidMMEEffectShaderException(string.Format("Draw={0}が指定されましたが、Drawに指定できるのはGeometryまたはBufferです。", value)); } if (func.isDrawGeometry && manager.EffectInfo.ScriptClass == ScriptClass.Scene) { throw new InvalidMMEEffectShaderException("Draw=Geometryが指定されましたが、STANDARDGLOBALのScriptClassに\"scene\"を指定している場合、これはできません。"); } if (!func.isDrawGeometry && manager.EffectInfo.ScriptClass == ScriptClass.Object) { throw new InvalidMMEEffectShaderException("Draw=Bufferが指定されましたが、STANDARDGLOBALのScriptClassに\"object\"を指定している場合、これはできません。"); } return(func); }
public override FunctionBase GetExecuterInstance(int index, string value, RenderContext context, ScriptRuntime runtime, MMEEffectManager manager, MMEEffectTechnique technique, MMEEffectPass pass) { LoopEndFunction func = new LoopEndFunction(); return(func); }
public override FunctionBase GetExecuterInstance(int index, string value, RenderContext context, ScriptRuntime runtime, MMEEffectManager manager, MMEEffectTechnique technique, MMEEffectPass pass) { LoopGetIndexFunction func = new LoopGetIndexFunction(); func.targetVariable = manager.EffectFile.GetVariableByName(value); func.runtime = runtime; return(func); }
public override FunctionBase GetExecuterInstance(int index, string value, RenderContext context, ScriptRuntime runtime, MMEEffectManager manager, MMEEffectTechnique technique, MMEEffectPass pass) { RenderDepthStencilTargetFunction func = new RenderDepthStencilTargetFunction(); if (index != 0) { throw new InvalidMMEEffectShaderException("RenderDepthStencilTargetにはインデックス値を指定できません。"); } func.context = context; if (!string.IsNullOrWhiteSpace(value) && !manager.RenderDepthStencilTargets.ContainsKey(value)) { throw new InvalidMMEEffectShaderException("スクリプトに指定された名前の深度ステンシルバッファは存在しません。"); } /* * valueが空なら→デフォルトの深度ステンシルバッファ * valueがあるなら→その名前のテクスチャ変数から取得 */ if (string.IsNullOrWhiteSpace(value)) { func.isDefaultTarget = true; } func.stencilView = string.IsNullOrWhiteSpace(value)?null: manager.RenderDepthStencilTargets[value]; return(func); }
public override FunctionBase GetExecuterInstance(int index, string value, RenderContext context, ScriptRuntime runtime, MMEEffectManager manager, MMEEffectTechnique technique, MMEEffectPass pass) { ClearSetColorFunction func = new ClearSetColorFunction(); func.sourceVariable = manager.EffectFile.GetVariableByName(value); func.context = context; if (func.sourceVariable == null) { throw new InvalidMMEEffectShaderException(string.Format("ClearSetColor={0};が指定されましたが、変数\"{0}\"は見つかりませんでした。", value)); } if (!func.sourceVariable.GetVariableType().Description.TypeName.ToLower().Equals("float4")) { throw new InvalidMMEEffectShaderException(string.Format("ClearSetColor={0};が指定されましたが、変数\"{0}\"はfloat4型ではありません。", value)); } return(func); }
public override FunctionBase GetExecuterInstance(int index, string value, RenderContext context, ScriptRuntime runtime, MMEEffectManager manager, MMEEffectTechnique technique, MMEEffectPass pass) { LoopByCountFunction func = new LoopByCountFunction(); func.runtime = runtime; if (string.IsNullOrWhiteSpace(value)) { throw new InvalidMMEEffectShaderException("LoopByCount=;は指定できません。int,float,boolいずれかの変数名を伴う必要があります。"); } EffectVariable rawVariable = manager.EffectFile.GetVariableByName(value); string typeName = rawVariable.GetVariableType().Description.TypeName.ToLower(); int loopCount = 0; switch (typeName) { case "bool": case "int": loopCount = rawVariable.AsScalar().GetInt(); break; case "float": loopCount = (int)rawVariable.AsScalar().GetFloat(); break; default: throw new InvalidMMEEffectShaderException("LoopByCountに指定できる変数の型はfloat,int,boolのいずれかです。"); } func.loopCount = loopCount; return(func); }
public ScriptRuntime(string script, RenderContext context, MMEEffectManager manager, MMEEffectPass pass) : this(script, context, manager, null, pass) { }
private void Parse(RenderContext context, MMEEffectManager manager, MMEEffectTechnique technique, MMEEffectPass pass) { ParsedExecuters = new List <FunctionBase>(); if (string.IsNullOrWhiteSpace(ScriptCode)) { return; } string[] splittedFunctions = ScriptCode.Split(';');//;で分割し1命令ごとにする foreach (string function in splittedFunctions) { if (string.IsNullOrWhiteSpace(function)) { continue; } int index = 0; string[] segments = function.Split('=');//=で分割し、関数名と引数を分ける if (segments.Length > 2) { throw new InvalidMMEEffectShaderException("スクリプト中の=の数が多すぎます。"); } char lastCharacter = segments[0][segments[0].Length - 1]; if (char.IsNumber(lastCharacter)) { segments[0] = segments[0].Remove(segments[0].Length - 1); index = int.Parse(lastCharacter.ToString()); } if (ScriptFunctions.ContainsKey(segments[0])) { ParsedExecuters.Add(ScriptFunctions[segments[0]].GetExecuterInstance(index, segments[1], context, this, manager, technique, pass)); } } }
private ScriptRuntime(string script, RenderContext context, MMEEffectManager manager, MMEEffectTechnique technique, MMEEffectPass pass) { ScriptCode = script; Parse(context, manager, technique, pass); }
public override FunctionBase GetExecuterInstance(int index, string value, RenderContext context, ScriptRuntime runtime, MMEEffectManager manager, MMEEffectTechnique technique, MMEEffectPass pass) { RenderColorTargetFunction func = new RenderColorTargetFunction(); if (index < 0 || index > 7) { throw new InvalidMMEEffectShaderException("RenderColorTarget[n](0<=n<=7)のnの制約が満たされていません。"); } func.index = index; func.context = context; if (!string.IsNullOrWhiteSpace(value) && !manager.RenderColorTargetViewes.ContainsKey(value)) { throw new InvalidMMEEffectShaderException("指定されたRENDERCOLORTARGETの変数は存在しません。"); } if (string.IsNullOrWhiteSpace(value)) { func.isDefaultTarget = true; } func.targetView = string.IsNullOrWhiteSpace(value)?index == 0?context.CurrentTargetContext.RenderTargetView:null:manager.RenderColorTargetViewes[value]; return(func); }
public override FunctionBase GetExecuterInstance(int index, string value, RenderContext context, ScriptRuntime runtime, MMEEffectManager manager, MMEEffectTechnique technique, MMEEffectPass pass) { ClearFunction func = new ClearFunction(); switch (value) { case "Color": func.isClearDepth = false; break; case "Depth": func.isClearDepth = true; break; default: throw new InvalidMMEEffectShaderException(string.Format("Clear={0}が指定されましたが、\"{0}\"は指定可能ではありません。ClearもしくはDepthが指定可能です。", value)); } func.context = context; func.index = index; return(func); }
public override FunctionBase GetExecuterInstance(int index, string value, RenderContext context, ScriptRuntime runtime, MMEEffectManager manager, MMEEffectTechnique technique, MMEEffectPass pass) { PassFunction func = new PassFunction(); if (technique == null) { throw new InvalidMMEEffectShaderException(string.Format("スクリプト内でPassを利用できるのはテクニックに適用されたスクリプトのみです。パスのスクリプトでは実行できません。")); } if (!technique.Passes.ContainsKey(value)) { throw new InvalidMMEEffectShaderException(string.Format("スクリプトで指定されたテクニック中では指定されたパス\"{0}\"は見つかりませんでした。(スペルミス?)", value)); } func.targetPass = technique.Passes[value]; return(func); }
public abstract FunctionBase GetExecuterInstance(int index, string value, RenderContext context, ScriptRuntime runtime, MMEEffectManager manager, MMEEffectTechnique technique, MMEEffectPass pass);