public void Run(ShaderData sd) { Texture outtex = sd.GetOutputTexture (0); float wq = 1f / (float)outtex.Width; float hq = 1f / (float)outtex.Height; if (Tracing.Enabled) Console.WriteLine ("wq {0} hq {1}", wq, hq); ShaderContext ctx = new ShaderContext (sd); EvalVisitor visitor = new EvalVisitor (ctx); float acc_w = wq / 2; for (int i = 0; i < outtex.Width; ++i) { float acc_h = hq / 2; for (int j = 0; j < outtex.Height; ++j) { if (Tracing.Enabled) Console.WriteLine ("----processing x {0} y {1}", i, j); ctx.ResetState (); ctx.SetTextureValue (0, acc_w, acc_h); acc_h += hq; foreach (var ins in shader) ins.Visit (visitor); ctx.WriteColor (0, i, j, outtex); } acc_w += wq; } }
internal EvalVisitor(ShaderContext ctx) { this.ctx = ctx; }