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 virtual void Setup(IRayDenLibraryFrame newFrame) { var svc = new SceneGraphService(); svc.Populate(new GlobalIndexObjLoader(), new MaterialLoader()); sceneBuilder = new SceneBuilder() { SGService = svc }; sceneBuilder.Setup(this); sceneBuilder.OpenFrame(newFrame); }
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(); }
public void OpenFrame(Library.Entity.Frames.FrameDescription frame) { this.CurrentFrame = new FrameConfiguration(); this.config.Merge(frame); this.OutputSettings = new OutputSettingsInfo(frame); this.QualitySettings = new QualitySettingsInfo(frame); this.FrameName = frame.FrameName; 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", 10); 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.CurrentFrame.Width = frame.Get<int>("ImageWidth"); this.CurrentFrame.Height = frame.Get<int>("ImageHeight"); this.CurrentFrame.ImageSavePath = this.SavePath; this.CurrentFrame.LowLatency = lowLatency; this.CurrentFrame.MaxSamplesPerPixel = this.QualitySettings.SamplesPerPixel; this.Initialize(); this.Scene.BuildPrimitives(); }