public override void OpenFrame(FrameDescription frame)
 {
     sceneManager.OpenFrame(frame);
     this.Scene = sceneManager.Scene;
     this.Settings.ImageWidth = sceneManager.width;
     this.Settings.ImageHeight = sceneManager.height;
 }
        public void Load(FrameDescription frame)
        {
            if (renderConfig == null)
            {
                renderConfig = new RayEngineConfiguration();
                Tracer.TraceLine("Render Config created");
            }

            renderConfig.OpenFrame(frame);
        }
Exemple #3
0
 public void OpenFrame(string frameName)
 {
     using (var frameFile = new FileStream(frameName, FileMode.Open, FileAccess.Read))
     {
         using (var reader = new StreamReader(frameFile))
             frame = (FrameDescription)SerializationService.Deserialize(reader.ReadToEnd(), typeof(FrameDescription));
     }
     frame.FrameName = Path.GetFileNameWithoutExtension(frameName);
     Tracer.TraceLine("Frame [[{0}]] loaded", frame.FrameName);
 }
Exemple #4
0
 public FrameArchive(string archivePath, string frameName, string tempFolder)
 {
     archive = new ArchiveFileSession(archivePath);
     archive.Extract(tempFolder, true);
     using (var frameFile = new FileStream(frameName, FileMode.Open, FileAccess.Read))
     {
         using (var reader = new StreamReader(frameFile))
             frame = (FrameDescription)SerializationService.Deserialize(reader.ReadToEnd(), typeof(FrameDescription));
     }
     frame.WorkingDir = tempFolder;
 }
Exemple #5
0
        public void LoadFrameDescription(FrameDescription frame)
        {
            this.Configuration.Merge(frame);
            this.OutputSettings = new OutputSettingsInfo(frame);
            this.QualitySettings = new QualitySettingsInfo(frame);

            this.FrameName = frame.FrameName;
            var width = frame.Get<int>("ImageWidth");
            var height = frame.Get<int>("ImageHeight");

            Directory.SetCurrentDirectory(frame.WorkingDir);
            /*
            foreach (var frameElement in frame.Elements.Where(frameElement => frameParsers.ContainsKey(frameElement.GetType()))) {
                frameParsers[frameElement.GetType()](frameElement);
            }*/

            if (Scene == null)
            {
                SceneGraphService svc = new SceneGraphService();
                svc.Populate(new GlobalIndexObjLoader(), new MaterialLoader());

                //svc.OpenFrame(frame);
                _builder = new SceneBuilder() { SGService = svc };
                _builder.Setup();
                this.Scene = _builder.OpenFrame(frame, AreaLightAsMeshLight);
                this.Scene.DefaultLightGain = Configuration.Get("LightGain", new RgbSpectrum(1.0f));
                this.Scene.MaxPathDepth = Configuration.Get("MaxPathDepth", 5);
                this.Scene.RussianRuletteImportanceCap = Configuration.Get("RRImportanceCap", 0.75f);
                this.Scene.MaxPaths = Configuration.Get("PathBufferSize", 65536 >> 10);
                this.Scene.ShadowRayCount = Configuration.Get("ShadowRayCount", 1);
                this.Scene.TextureSamplingQuality = this.QualitySettings.TextureSamplingQuality;
                this.Scene.LightSamplingStrategy = LightSamplingStrategy.UniformOneLight;

                var scene = _builder.SceneGeo;

                var sceneBound = new AABB(scene.BoundingSphereCenter - scene.BoundingSphereRadius,
                                          scene.BoundingSphereCenter + scene.BoundingSphereRadius);
                sceneBound.Expand(1f);

                //var viewBound = new AABB(Scene.Camera.Target - 5f, Scene.Camera.Target + 5f);
                var c = new Point(Scene.Camera.Target);
                var bb = new AABB(c - 1f, c + 1f);
                var volumeBound = sceneBound;
                Scene.VolumeIntegrator = new SingleScatteringIntegrator(volumeBound,
                                                                         volumeBound.Size.Length / 10f, //step
                                                                         0.005f, //Probability
                                                                         RgbSpectrum.UnitSpectrum() * 0.095f,  //Inscatering
                                                                         new RgbSpectrum(0.00005f)             //Emission
                                                                       );
            }

            this.Context = new EngineContext() { RenderThreads = Configuration.Get("RenderThreadsCount", 1), FrameConfiguration = frame, Scene = this.Scene };
            this.Initialize();
        }
Exemple #6
0
        public void OpenFrame(FrameDescription frame)
        {
            this.frame = frame;
            width = frame.Get<int>("ImageWidth");
            height = frame.Get<int>("ImageHeight");

            render = this.SetupRender();

            imagePlane = new ImagePlane(width, height);
            render.Setup(frame);
        }
Exemple #7
0
        public void OpenFrame(FrameDescription frameDescription)
        {
            this.config = frameDescription;
            if (GlobalConfiguration.Instance.AdaptiveFilm)
                this.film = new AdaptiveImageFilm(this.Width, this.Height);
            else 
                this.film = new ImageFilm(this.Width, this.Height);
            this.integrator = 
                //new PathTracerIntegrator()
                //new PathTracerDL()
                //new RayTracer()
                new SpectralRayTracer()

                //new SingleRandomWavelengthPathTracerIntegrator()
                //new WavelengthClusterPathTracerIntegrator()
            {
                Scene = new SceneManager() { w = this.Width, h = this.Height },
                film = this.film,
                rnd = new FastRandom()
            };
        }
Exemple #8
0
        private static void CreateFrame(string outputDirectory, string frameName, string workingDir)
        {
            Console.WriteLine("Starting frame {0}.rdf", frameName);
            FrameDescription newFrame = new FrameDescription()
                {
                    WorkingDir =
                        //@"F:\3D\Models\3DSMAX\"
                        // @"F:\Dev\Scenes\OasisCornell\"
                       workingDir
                };
            newFrame.Add("ImageWidth", 1280);
            newFrame.Add("ImageHeight", 720);
            newFrame.AddNew(
                new FrameCamera()
                    {
                        Name = "Main Camera",
                        Position = new Vector(-132.237f,
                                              -26.684f,
                                              15.514f),
                        Target = new Vector(-69.374f,
                                            0.0f,
                                            11.601f
                    ),
                        Up = new Vector(0f, 0f, 1f),
                        Fov = 35f,
                    });

            newFrame.AddNew(
              new FrameCamera()
              {
                  Name = "Camera #2",
                  Position = new Vector(106.499f,
                                        -12.832f,
                                        3.318f),
                  Target = new Vector(50.815f,
                                     -11.904f,
                                     3.318f
              ),
                  Up = new Vector(0f, 0f, 1f)
              });

            newFrame.AddNew(
                new FrameObjFileReference()
                    {
                        MtlFilePath = frameName + ".mtl",
                        ObjFilePath = frameName + ".obj"
                    });
            newFrame.AddNew(
                new FrameLightsource()
                    {
                        LightType = LightSourceTypes.Sky,
                        Parameters = new ConfigurableEntity()
                          {
                                new KeyValuePair<string, object>(FrameLightsource.SkyLightSunDir, new Vector(0f,
                                                                                                                 1.845f,
                                                                                                                 1.216f)),
                                new KeyValuePair<string, object>(FrameLightsource.SkyLightTurbulence, 2.5f),
                            }
                    });
            newFrame.AddNew(
                new FrameLightsource()
                    {
                        LightType = LightSourceTypes.Point,
                        Parameters = new ConfigurableEntity()
                            {
                                new KeyValuePair<string, object>(FrameLightsource.PointLightPosition, new Vector(-63.798f,
                                                                                                                 -110.845f,
                                                                                                                 58.216f)),
                                new KeyValuePair<string, object>(FrameLightsource.LightsourcePower, new RgbSpectrum(3.78f)),
                            }
                    }
                );
            newFrame.AddNew(
                new FrameLightsource()
                    {
                        LightType = LightSourceTypes.Point,
                        Parameters = new ConfigurableEntity()
                            {
                                new KeyValuePair<string, object>(FrameLightsource.PointLightPosition, new Vector(150.607f,
                                                                                                                 6.237f,
                                                                                                                 28.866f)),
                                new KeyValuePair<string, object>(FrameLightsource.LightsourcePower, new RgbSpectrum(3.78f)),
                            }
                    }
                );
            newFrame.AddNew(
                new FrameLightsource()
                    {
                        LightType = LightSourceTypes.EnvironmentMap,
                        Parameters = new ConfigurableEntity() { new KeyValuePair<string, object>(FrameLightsource.InfiniteLightMapPath, @"skylight-blue.exr") }
                    }
                );

            //  newFrame.AddNew(
            //new FrameLightsource()
            //{
            //    LightType = LightSourceTypes.Point,
            //    Parameters = new ConfigurableEntity()
            //              {
            //                  new KeyValuePair<string, object>(FrameLightsource.PointLightPosition, new Vector(133.19f,
            //                                                                                                   592.194f,
            //                                                                                                   714.1383f)),
            //                  new KeyValuePair<string, object>(FrameLightsource.LightsourcePower,   new RgbSpectrum(0.78f)),
            //              }
            //}
            //);
            //  newFrame.AddNew(
            //      new FrameLightsource()
            //          {
            //              LightType = LightSourceTypes.EnvironmentMap,
            //              Parameters = new ConfigurableEntity() { new KeyValuePair<string, object>(FrameLightsource.InfiniteLightMapPath, @"F:\3D\HDRI\skylight-blue.exr") }
            //          }
            //      );
            Console.WriteLine("Writing file " + string.Format("{0}{1}.rdf", outputDirectory, frameName));
            Console.WriteLine(SerializationService.SerializeKnown(newFrame));
            using (
                var fs = new FileStream(string.Format("{0}{1}.rdf", outputDirectory, frameName), FileMode.OpenOrCreate,
                                        FileAccess.Write))
            {
                using (var wr = new StreamWriter(fs))
                {
                    wr.Write(SerializationService.SerializeKnown(newFrame));
                }
            }
        }
        public void OpenFrame(FrameDescription frame)
        {
            this.config.Merge(frame);
            this.OutputSettings = new OutputSettingsInfo(frame);
            this.QualitySettings = new QualitySettingsInfo(frame);

            this.FrameName = frame.FrameName;
            width = frame.Get<int>("ImageWidth");
            height = frame.Get<int>("ImageHeight");
            if (!string.IsNullOrWhiteSpace(frame.WorkingDir))
                Directory.SetCurrentDirectory(frame.WorkingDir);
   
            if (Scene == null) {
                var svc = new SceneGraphService();
                svc.Populate(new GlobalIndexObjLoader(), new MaterialLoader());

                var builder = new SceneBuilder() { SGService = svc };
                builder.Setup();
                this.Scene = builder.OpenFrame(frame, AreaLightAsMeshLight);
                this.Scene.DefaultLightGain = config.Get("LightGain", new RgbSpectrum(1.0f));
                this.Scene.MaxPathDepth = config.Get("MaxPathDepth", 15);
                this.Scene.RussianRuletteImportanceCap = config.Get("RRImportanceCap", 0.75f);
                this.Scene.MaxPaths = config.Get("PathBufferSize", 65536 >> 10);
                this.Scene.ShadowRayCount = config.Get("ShadowRayCount", 16);
                this.Scene.TextureSamplingQuality = this.QualitySettings.TextureSamplingQuality;
                this.Scene.AreaLightAsMesh = this.AreaLightAsMeshLight;
                this.Scene.MatLib = new OptimizedBsdfLibrary();

                this.Scene.MatLib.Populate(builder.MaterialInfos.ToArray());

                (this.Scene.MatLib as OptimizedBsdfLibrary) .Replace("Object_MaterialView_Test", this.ObjectMaterial);
                (this.Scene.MatLib as OptimizedBsdfLibrary).Replace("Plane_Material", this.PlaneMaterial);

                foreach (var brdf in ObjectMaterial.Where(brdf => brdf != null))
                {
                    builder.ProcessMaterial(0, brdf.MaterialData);
                }
                foreach (var brdf in PlaneMaterial.Where(brdf => brdf != null))
                {
                    builder.ProcessMaterial(1, brdf.MaterialData);
                }

                RenderThreadsCount = config.Get("RenderThreadsCount",1);
                this.scene = builder.SceneGeo;

                var sceneBound = new AABB(scene.BoundingSphereCenter - scene.BoundingSphereRadius,
                                          scene.BoundingSphereCenter + scene.BoundingSphereRadius);
                sceneBound.Expand(1f);

                //var viewBound = new AABB(Scene.Camera.Target - 5f, Scene.Camera.Target + 5f);
                Scene.VolumeIntegrator = new SingleScatteringIntegrator(sceneBound, sceneBound.Size.Length / 10f, 0.15f, RgbSpectrum.UnitSpectrum()*0.095f, new RgbSpectrum(0.0005f));
            }
         

            this.Initialize();

        }
        public void OpenFrame(FrameDescription frameDescription)
        {
           
            //width = frame.Get<int>("ImageWidth");
            //height = frame.Get<int>("ImageHeight");

            if (!string.IsNullOrWhiteSpace(frameDescription.WorkingDir))
                Directory.SetCurrentDirectory(frameDescription.WorkingDir);
            foreach (var frameElement in frameDescription.Elements.Where(frameElement => frameParsers.ContainsKey(frameElement.GetType())))
            {
                frameParsers[frameElement.GetType()](frameElement);
            }

            this.sceneGraph = this.CreateSceneGraph(scene, Transform.Scale(1f, 1f, 1f));
            this.SceneGraph.Parameters = frameDescription;
            this.SceneGraph.SceneName = frameDescription.FrameName;
        }
Exemple #11
0
 public virtual void OpenFrame(FrameDescription frame)
 {
 }
        public SceneConfiguration ExportConfiguration(FrameDescription frame)
        {
            var result = new SceneConfiguration();

            result["frame", "global", "name"] = FrameName;
            result["frame", "global", "width"] = width;
            result["frame", "global", "height"] = height;
            result["frame", "global", "directory"] = Directory.GetCurrentDirectory();

            result.SetFrame("samplesperpixel", QualitySettings.SamplesPerPixel);
            result.SetFrame("supersampling", QualitySettings.SuperSamplingSize);
            result.SetFrame("maxpathdepth", Scene.MaxPathDepth);
            result.SetFrame("lightgain", this.Scene.DefaultLightGain);
            result.SetFrame("rrimportancecap", this.Scene.RussianRuletteImportanceCap);
            result.SetFrame("shadowraysperlight", this.Scene.ShadowRayCount);
            result.SetFrame("texturesampling", (int)this.QualitySettings.TextureSamplingQuality);
            result.SetFrame("pathbuffersize", this.Scene.MaxPaths);
            result.SetFrame("arealightasmesh", this.AreaLightAsMeshLight);

            /*
            foreach (var frameElement in frame.Elements.Where(frameElement => frameParsers.ContainsKey(frameElement.GetType()))) {
                frameParsers[frameElement.GetType()](frameElement);
            }*/

            if ((Scene.Camera is FiniteAppertureCamera))
            {
                result.FiniteAppertureCameras.AddItem("camera1", new CameraFactory().Serialize(Scene.Camera), ".");
            }
            else
            {
                result.PinholeCameras.AddItem("camera1", new CameraFactory().Serialize(Scene.Camera), ".");
            }


            var objTag = frame.Elements.OfType<FrameObjFileReference>().FirstOrDefault();
            result.SetMesh("objfilename", objTag.ObjFilePath);
            result.SetMesh("mtlfilename", objTag.MtlFilePath);
            result.SetMesh("invertnormals", objTag.InvertNormals);

            var serializer = new LightFactory();
            foreach (var light in Scene.Lights)
            {
                EntityCollection lightCollection = null;


                if (light is PointLight)
                {
                    lightCollection = result.PointLights;

                }
                else if (light is MeshLight)
                {
                    lightCollection = result.AreaLights;
                }
                else if (light is BaseInfiniteLight)
                {
                    lightCollection = result.InfiniteLights;
                }

                if (lightCollection != null)
                    lightCollection.AddItem(light.Name, serializer.Serialize(light), ".");
            }

            /*
            var matSer = new MaterialFactory();

            foreach (var material in Scene.MatLib)
            {
                EntityCollection mats = null;
                switch (material.Class)
                {
                    case BrdfClass.Alloy:
                        mats = result.AlloyMaterials;
                        break;
                    case BrdfClass.DiffuseLambert:
                        mats = result.MatteMaterials;
                        break;

                }
                if (mats != null)
                {
                    var mat = matSer.Serialize(material);
                    mats.AddItem(mat.Name, mat,".");
                }
            }

            */
            return result;
        }
        public void OpenFrame(FrameDescription frame)
        {
            this.config.Merge(frame);
            this.OutputSettings = new OutputSettingsInfo(frame);
            this.QualitySettings = new QualitySettingsInfo(frame);

            this.FrameName = frame.FrameName;
            width = frame.Get<int>("ImageWidth");
            height = frame.Get<int>("ImageHeight");

            if (!string.IsNullOrWhiteSpace(frame.WorkingDir))
                Directory.SetCurrentDirectory(frame.WorkingDir);
            /*
            foreach (var frameElement in frame.Elements.Where(frameElement => frameParsers.ContainsKey(frameElement.GetType()))) {
                frameParsers[frameElement.GetType()](frameElement);
            }*/

            if (Scene == null)
            {
                SceneGraphService svc = new SceneGraphService();
                svc.Populate(
                    //new ObjLoader(),
                    new GlobalIndexObjLoader(),
                    new MaterialLoader());

                //svc.OpenFrame(frame);
                _builder = new SceneBuilder() { SGService = svc };
                _builder.Setup();
                this.SceneGraph = _builder.SGService.SceneGraph;
                this.Scene = _builder.OpenFrame(frame, this.AreaLightAsMeshLight);
                this.Scene.DefaultLightGain = config.Get("LightGain", new RgbSpectrum(1.0f));
                this.Scene.MaxPathDepth = config.Get("MaxPathDepth", 32);
                this.Scene.RussianRuletteImportanceCap = config.Get("RRImportanceCap", 0.75f);
                this.Scene.MaxPaths = config.Get("PathBufferSize", 65536);
                this.Scene.ShadowRayCount = config.Get("ShadowRayCount", 1);
                this.Scene.TextureSamplingQuality = this.QualitySettings.TextureSamplingQuality;
                this.Scene.LightSamplingStrategy = this.QualitySettings.LightSamplingStrategy;
                RgbSpectrum.Gamma = true;
                /*
                if (GlobalConfiguration.Instance.SpectralRendering)
                {
                    this.Scene.SpectralMats = new BxDFLibrary(new LambertianBrdf(new[] { 0.5f, 0.5f, 0.5f }));
                    this.Scene.SpectralMats.Populate(_builder.MaterialInfos.ToArray());
                }
                else*/

                {
                    this.Scene.MatLib = this.dependencyManager.GetMaterialPlugin(_builder.MaterialInfos.ToArray());
                    if (_builder.FrameMaterialBuilder != null)
                    {
                        this.Scene.MatLib.Add(_builder.FrameMaterialBuilder.Materials);
                        _builder.FrameMaterialBuilder.CreateRayEngineMaterials(this.Scene);
                    }
                    if (EnableMaterialOverrides)
                        FrameMaterialBuilder.ApplyMaterialOverrides((this.Scene.MatLib as OptimizedBsdfLibrary).Materials, Scene);
                }


                RenderThreadsCount = config.Get("RenderThreadsCount", 1);
                this.scene = _builder.SceneGeo;

                var sceneBound = new AABB(scene.BoundingSphereCenter - scene.BoundingSphereRadius,
                                          scene.BoundingSphereCenter + scene.BoundingSphereRadius);
                sceneBound.Expand(1f);

                //var viewBound = new AABB(Scene.Camera.Target - 5f, Scene.Camera.Target + 5f);
                var c = new Point(Scene.Camera.Target);
                var bb = new AABB(c - 1f, c + 1f);
                var volumeBound = sceneBound;

                Scene.VolumeIntegrator = new SingleScatteringIntegrator(volumeBound,
                                                                         volumeBound.Size.Length / 10f, //step
                                                                         0.05f, //Probability
                                                                         RgbSpectrum.UnitSpectrum() * 0.05f,  //Inscatering
                                                                         new RgbSpectrum(0.000f)             //Emission

                                                                       );
                new RayEngineMaterialBuilder().BuildMaterials(this.Scene);
            }

            this.Initialize();
            ExportConfiguration(frame).Save(@"F:\Dev\Frames\Config\" + Path.GetFileNameWithoutExtension(FrameName) + ".sceneconfig");
        }
 public void OpenFrame(FrameDescription frameDescription)
 {
     this.Engine.OpenFrame(frameDescription);
     this.Width = frameDescription.Get<int>("ImageWidth");
     this.Height = frameDescription.Get<int>("ImageHeight");
 }
Exemple #15
0
        public void OpenFrame(FrameDescription frame)
        {
            this.config = frame;

            this.FrameName = frame.FrameName;
            Width = frame.Get<int>("ImageWidth");
            Height = frame.Get<int>("ImageHeight");

            Directory.SetCurrentDirectory(frame.WorkingDir);
            foreach (var frameElement in frame.Elements.Where(frameElement => frameParsers.ContainsKey(frameElement.GetType())))
            {
                frameParsers[frameElement.GetType()](frameElement);
            }

            primitives = new List<GLScenePrimitive>();

            bboxes = new List<AABB>();
            var helper = new BoundingVolumeHierarchyAccelerationHelper();
            var s = new RayEngineScene();
               //(scene, null);
            helper.Init( s, s.Meshes.ToArray());
            
            bboxes.AddRange(helper.nodes.Select(item=>item.Bounds));
        }