ShaderProcessor CreateShaderProcessor(Camera camera) { ShaderProcessor processor = camera.gameObject.AddComponent <ShaderProcessor>(); processor.material = Instantiate(material) as Material; processor.material.SetTexture("_tex1", _oldSceneTexture); processor.material.SetFloat("_startTime", 0f); processor.material.SetFloat("_endTime", transitionInMinimalDuration); processor.material.SetFloat("_now", _now - _transitionStartTime); return(processor); }
public void Generate() { // Verify and add path to meta property cache for (int i = 0; i < Path.Nodes.Length; i++) { for (int j = Path.Nodes[i].Top; j <= Path.Nodes[i].Bottom; j++) { var mp = (MetaProperty)Path.Nodes[i].Block.Members[j]; var loc = new MetaLocation(i, j); MetaLocation ploc; if (MetaProperties.TryGetValue(mp.Name, out ploc)) { var pmp = GetProperty(ploc); // TODO: This is not correct if (!pmp.ReturnType.Equals(mp.ReturnType)) { Log.Error(mp.Source, ErrorCode.E5000, mp.Name.Quote() + " does not have the same type as the previous declaration at " + pmp.Source + " when exposed from " + Path.Quote() + " at " + Path.Source); } PrevProperties.Add(loc, ploc); } MetaProperties[mp.Name] = loc; } } // Resolve terminal properties foreach (var tp in Backend.ShaderBackend.OutputProperties) { MetaLocation loc; if (!MetaProperties.TryGetValue(tp.Name, out loc)) { Log.Error(Path.Source, ErrorCode.I5001, "Terminal property " + tp.Name.Quote() + " was not found in " + Path.Quote()); continue; } var mp = GetProperty(loc); var dt = ILFactory.GetType(Path.Source, tp.TypeString); if (!mp.ReturnType.Equals(dt)) { Log.Error(Path.Source, ErrorCode.I5001, "Terminal property " + tp.Name.Quote() + " was found with type " + mp.ReturnType.Quote() + " when " + dt.Quote() + " was expected"); continue; } var sym = ProcessMetaProperty(loc, tp.Required); if (sym.Value == null) { continue; } LocationStack.Add(loc); switch (tp.Stage) { case MetaStage.Vertex: sym = ProcessStage(sym, MetaStage.Vertex, MetaStage.Vertex); DrawState.VertexShader.Terminals[tp.Name] = sym.Value; break; case MetaStage.Pixel: sym = ProcessStage(sym, MetaStage.Pixel, MetaStage.Pixel); DrawState.PixelShader.Terminals[tp.Name] = sym.Value; break; default: sym = ProcessStage(sym, MetaStage.Volatile, MetaStage.Volatile); DrawState.Terminals[tp.Name] = sym.Value; break; } LocationStack.RemoveLast(); } if (!DrawState.Terminals.ContainsKey("VertexCount")) { var loc = MetaProperties["VertexCount"]; var mp = GetProperty(loc); if (DetectedVertexCounts.Count == 1) { LocationStack.Add(loc); var fc = new FunctionCompiler(Compiler, IL); DrawState.Terminals["VertexCount"] = fc.CompileImplicitCast(DetectedVertexCounts[0].Value.Source, mp.ReturnType, ProcessStage(DetectedVertexCounts[0], MetaStage.Volatile, MetaStage.Volatile).Value); LocationStack.RemoveLast(); } else { Log.Error(CreateTrace(mp, loc, null), ErrorCode.E5002, "Unable to auto detect 'VertexCount' in " + Path.Quote()); } } MetaPropertyEmitter.Emit(this); ShaderProcessor.ProcessShader(this, DrawState.VertexShader); ShaderProcessor.ProcessShader(this, DrawState.PixelShader); ProcessStructs(); var p = new IndirectionTransform(Compiler.Pass); DrawState.VertexShader.Visit(p); DrawState.PixelShader.Visit(p); }