예제 #1
0
        public void InitializeEngine(Buffer outputBuffer)
        {
            var scene = ComponentPipeline.Instance.LoadScene(sceneFile);
            var frameName = Path.GetFileNameWithoutExtension(sceneFile);

            this.Context = ComponentPipeline.Instance.Session.OptixContext;
            if (Config == null)
            {
                Config = new RendererConfig()
                {
                    FramesCount = 1,
                    FrameTime = TimeSpan.Zero,
                    Gamma = 2.4f,
                    SamplesPerPixel = 5000,
                    MaxShadowRays = 1,
                    SavePath = GlobalConfiguration.Instance.ImageSaveDir,
                    SaveOnFinish = true,
                };
            }
            ComponentPipeline.Instance.CreateEngine();
            this.UpdateConfig();
            ComponentPipeline.Instance.RenderingEngine.SetOutputBuffer(outputBuffer);
            ComponentPipeline.Instance.RenderingEngine.Initialize();
            //ComponentPipeline.Instance.RenderingEngine.SetCommands(ref Commands);
            ComponentPipeline.Instance.RenderingEngine.SetupScene(scene);

            this.activeMaterial = scene.Find<Phantom.Library.Scene.SceneMaterial>(materialName);
            if (activeMaterial == null)
            {
                throw new ApplicationException("Material not found");
            }
            this.MaterialModel.Exponent = (float)activeMaterial["exponent"];
            this.MaterialModel.Roughness = activeMaterial.Get("roughness", 1.0f);
            this.MaterialModel.Reflectivity = activeMaterial.Get("reflectivity", 0.75f);
            this.MaterialModel.IndexOfRefraction = activeMaterial.Get("index_of_refraction", 1.5f);

            ComponentPipeline.Instance.Session.Frame.CurrentCamera.BuildView();
        }
예제 #2
0
 public bool FrameDone(RendererConfig config)
 {
     return config.FrameDone(sw != null ? sw.Elapsed : (TimeSpan?)null, mFrame);
 }
예제 #3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (string.IsNullOrWhiteSpace(sceneFile))
            {
                if (openFileDialog.ShowDialog() != DialogResult.OK)
                {
                    this.Close();
                }
                else
                {
                    sceneFile = openFileDialog.FileName;
                }
            }

            var scene = ComponentPipeline.Instance.LoadScene(sceneFile, false);
            frameName = Path.GetFileNameWithoutExtension(sceneFile);

            this.Context = ComponentPipeline.Instance.Session.OptixContext;
            Config = new RendererConfig()
            {
                FramesCount = 1,
                FrameTime = TimeSpan.FromMinutes(60),
                Gamma = 2.4f,
                SamplesPerPixel = -1,
                SavePath = GlobalConfiguration.Instance.ImageSaveDir,
                SaveOnFinish = true,
            };
            CreateOutputBuffer(Format.Float4);
            ComponentPipeline.Instance.CreateEngine();
            ComponentPipeline.Instance.RenderingEngine.SetOutputBuffer(this.OutputBuffer);
            ComponentPipeline.Instance.RenderingEngine.Initialize();
            ComponentPipeline.Instance.RenderingEngine.SetCommands(ref Commands);
            ComponentPipeline.Instance.RenderingEngine.SetupScene(scene);
            ComponentPipeline.Instance.Session.Frame.CurrentCamera.BuildView();
            SetCamera(ComponentPipeline.Instance.Session.Frame.CurrentCamera);
            RaysTracedPerFrame = ComponentPipeline.Instance.RenderingEngine.RaysTracedPerFrame;
            sw = Stopwatch.StartNew();

            Tracer.Print("Engine", "Start Rendering.");
        }