private Texture buildCameraCalculateAt(SceneDescription description, double time) { CameraWrapper camw = description.CameraWrapper; Tuple<List<RenderItem>,List<Light>> scene = description.SceneGraph.Inject(time, camw); List<RenderItem> ris = scene.Item1; Light[] lights = scene.Item2.ToArray(); EnvironmentSettings es = description.EnvironmentSettings; #if DEBUG DateTime old = DateTime.Now; #endif IAccelerator acc = description.AcceleratorWrapper.CreateAccelerator(description.SceneGraph, time, ris); #if DEBUG DateTime now = DateTime.Now; Console.Write("{0}\t", (now-old).TotalMilliseconds.ToString("0.000")); #endif switch(this.RenderingTechnology) { case RenderingTechnology.Normal: Camera cam = camw.Camera(acc, lights, es); cam.CalculateImage(); return cam.Raster; case RenderingTechnology.Anaglyph: Camera camL = camw.Camera(acc, lights, es); camL.Displacement = -0.01*camL.ScreenDistance; camL.CalculateImage(); Camera camR = camw.Camera(acc, lights, es); camR.Displacement = 0.01*camR.ScreenDistance; camR.CalculateImage(); return Texture.ToCyanRed(camL.Raster, camR.Raster); default : return null; } }
private void fillMotionBlurCache(SceneDescription sd, Texture[] motionblurCache, CacheTexture sum, double t0, double dt) { double t = t0-dt; Texture tex; for(int i = motionblurCache.Length-0x02; i >= 0x00; i--) { tex = buildCameraCalculateAt(sd, t); motionblurCache[i] = tex; sum.AddTexture(tex); t -= dt; } }
public void Execute(SceneDescription description) { double min = Math.Max(this.T0, description.SceneGraph.T0); double max = this.T1; double dt = (max-min)/this.TimeSamples; uint nDelta = (uint)Math.Round(this.ClosureTime/dt)+0x01; Texture[] motionblurCache = new Texture[nDelta]; CacheTexture blurCache = new CacheTexture((int)description.CameraWrapper.Width, (int)description.CameraWrapper.Height); Texture tex; this.fillMotionBlurCache(description, motionblurCache, blurCache, min, dt); if(this.Task == SuperCameraTask.MakeImage) { blurCache.AddTexture(this.buildCameraCalculateAt(description, min)); blurCache.MixWithAlpha(nDelta).Save(this.outputFile); } else if(this.Task == SuperCameraTask.MakeMovie) { this.clearTmpFolder(); int index = 0; Process proc = new Process(); proc.StartInfo.FileName = "convert"; string imagename; string jpegname; uint j = nDelta-0x01; for(double t = min; t <= max; t += dt) { imagename = string.Format("/tmp/output{0}.png", index.ToString("00000")); jpegname = string.Format("{0} /tmp/output{1}.jpg", imagename, index.ToString("00000")); tex = this.buildCameraCalculateAt(description, t); blurCache.RemoveTexture(motionblurCache[j]); blurCache.AddTexture(tex); blurCache.MixWithAlpha(nDelta).Save(imagename); motionblurCache[j++] = tex; j %= nDelta; index++; proc.WaitForExit(); proc.StartInfo.Arguments = jpegname; proc.Start(); } proc.WaitForExit(); this.convertToMovie(); this.clearTmpFolder(); } }