public static AngleFunc MeshToAngleFunc(IRayTracer rayTracer, Point3D point, int nMu, int nPhi) { var result = new AngleFunc(nMu, nPhi, true); var pi2 = Math.PI / 2; for (int iMu = 0; iMu < result.Mu.Count; iMu++) { for (int iPhi = 0; iPhi < nPhi; iPhi++) { var theta = (float)(pi2 - Math.Acos(result.Mu[iMu])); var phi = result.Phi[iPhi]; Vector direction = new Vector(theta, phi); var intersection = rayTracer.Trace(point, direction, Constants.Epsilon); if (intersection == null) { //RayDebugStaticCollection.Add( new Ray( point, direction ), System.Drawing.Color.Red ); } else { var r = (intersection.Point - point).Length; result.R[iMu][iPhi] = r; //RayDebugStaticCollection.Add( new Ray( point, intersection.Point ), System.Drawing.Color.Green ); } } } return(result); }
public DoubleLocalEstimationCalculator( Scene scene, IRayTracer rayTracer, int nRays, float wMin ) { Scene = scene; RayTracer = rayTracer; NRays = nRays; WMin = wMin; }
public override Spectrum GetIlluminance(IRayTracer rayTracer, IMaterial material, Point3D point, Vector normal, Vector view) { var fakePoint = new Point3D(0, 0, (this.Position - point).Length); var formFactor = this.GetFormFactor(point, fakePoint); // если нет расчетных точек, то генерим их на источнике if (this.LightSamplePoints == null) { this.GenerateLightSamplePoints(); } var result = new Spectrum(); var toLightVector = new Vector(point, this.Position); //var toLightRay = new Ray( point, this.Position ); var cosR = Math.Abs(-Vector.Dot(toLightVector, this.Direction)); result += material.Reflectance.BRDF(toLightVector, normal, view) * cosR; // форм фактор уменьшаяется за счет не попавших лучей // (float) Math.PI - из ядра уравнения result = this.Illuminance * result * formFactor / Constants.PI; //result = result * this.Illuminance / (float)( this.Samples ); return(result); }
private static void RenderFunc( IRayTracer rayTracer, int pixelWidth, ConcurrentQueue <int> rowQueue, ConcurrentQueue <RenderLineResult> resultQueue, AutoResetEvent queueDataAvailableEvent) { try { while (rowQueue.TryDequeue(out int y)) { var rowPixels = new List <PixelData>(); for (var x = 0; x < pixelWidth; x++) { rowPixels.Add(rayTracer.GetPixelColor(x, y)); } resultQueue.Enqueue(new RenderLineResult(y, rowPixels)); queueDataAvailableEvent.Set(); } } catch (Exception ex) { Console.WriteLine(ex); } }
public DoubleLocalEstimation(IRayTracer rayTracer, int nPackets, int nRays, float wMin) { RayTracer = rayTracer; scene = rayTracer.Scene; NPackets = nPackets; NRays = nRays; WMin = wMin; }
public MRenderDoubleLocalEst(MScene scene, IRayTracer rayTracer, int nRays, float wMin, ILog log = null) { NRays = nRays; WMin = wMin; Scene = scene; RayTracer = rayTracer; Log = log; }
static void Main() { scene = (Scene)Activator.CreateInstance(Constants.SceneIndex); //Create the RayTracer setup you want to use here IRayTracer tracer = (IRayTracer)Activator.CreateInstance(Constants.RayTracer, scene); tracer.Render(); }
/// <summary> /// Sorts out all vertices form the relevantVertices list which /// aren't hit directly by a ray from the IRayTracer. /// </summary> public void SortOutUnhittedVertices(IRayTracer tracer) { for (int i = RelevantVertices.Count - 1; i >= 0; i--) { if (!tracer.CreateRay(GetRelevantVertexPosition(i))) { RelevantVertices.Remove(RelevantVertices[i]); } } }
private static async Task Render(IRayTracer rayTracer, RayTraceRenderData renderData, string filePath) { var pixelArray = new PixelArray(renderData.Width, renderData.Height); var renderer = new SceneRenderer(); renderer.Progress += (sender, eventArgs) => Console.Write($"...{eventArgs.PercentComplete}%"); await renderer.RayTraceSceneAsync(rayTracer.GetPixelColor, pixelArray, renderData.MaxParallelism).ConfigureAwait(false); pixelArray.SaveToPng(filePath); Console.WriteLine(); Console.WriteLine($"Saved image to {filePath}"); }
public virtual Spectrum GetIlluminance(IRayTracer rayTracer, IMaterial material, Point3D point, Vector normal, Vector view) { // проверяем что нормали сонаправлены var xx = Vector.Dot(normal, this.Direction); if (xx > Constants.Epsilon || point.Z > this.Position.Z) { return(new Spectrum()); } var formFactor = this.GetFormFactor(point); // если нет расчетных точек, то генерим их на источнике if (this.LightSamplePoints == null) { this.GenerateLightSamplePoints(); } var result = new Spectrum(); // цикл по всем расчетным точкам на источнике int raysHited = 0; foreach (var lightSamplePoint in this.LightSamplePoints) { var toLight = lightSamplePoint.Point - point; var toLightVector = new Vector(toLight, true); //var toLightRay = new Ray( point, lightSamplePoint.Point ); if (!rayTracer.Occluded(point, toLightVector, Constants.Epsilon, toLight.Length - Constants.Epsilon)) { // источник косинусный var cosR = Math.Abs(-Vector.Dot(toLightVector, this.Direction)); result += material.Reflectance.BRDF(toLightVector.Reverse(), normal, view) * cosR; raysHited++; } } if (raysHited == 0) { return(new Spectrum()); } // усредняем BRDF result = result / (float)raysHited; // форм фактор уменьшаяется за счет не попавших лучей // (float) Math.PI - из ядра уравнения result = this.Illuminance * result * formFactor * (raysHited / (float)(this.Samples)); //result = result * this.Illuminance / (float)( this.Samples ); return(result); }
public Spectrum GetIlluminance(IRayTracer rayTracer, IMaterial material, Point3D point, Vector normal, Vector view) { var toLight = this.Position - point; var toLightVector = new Vector(toLight, true); //var toLightRay = new Ray( point + normal * Constants.Epsilon, this.Position ); if (!rayTracer.Occluded(point + normal * Constants.Epsilon, toLightVector, 0, toLight.Length)) { return(this.Intensity * material.Reflectance.BRDF(toLightVector, normal, view) / toLight.Length2); } else { return(new Spectrum()); } }
private static void RenderFunc( IRayTracer rayTracer, ConcurrentQueue <int> rowQueue, ConcurrentQueue <RenderLineResult> resultQueue, AutoResetEvent queueDataAvailableEvent) { while (rowQueue.TryDequeue(out var y)) { // Console.WriteLine($"Thread {Thread.CurrentThread.ManagedThreadId} starting to render row: {y}"); var rowPixels = new List <ColorVector>(); for (var x = 0; x < rayTracer.RenderData.Width; x++) { rowPixels.Add(rayTracer.GetPixelColor(x, y)); } resultQueue.Enqueue(new RenderLineResult(y, rowPixels)); queueDataAvailableEvent.Set(); } }
private static void RenderFunc( IRayTracer rayTracer, ConcurrentQueue <RenderInput> inputQueue, ConcurrentQueue <RenderResult> resultQueue, AutoResetEvent queueDataAvailableEvent) { try { while (inputQueue.TryDequeue(out RenderInput input)) { var pixelData = rayTracer.GetPixelColor(input.X, input.Y); resultQueue.Enqueue(new RenderResult(input.X, input.Y, pixelData)); queueDataAvailableEvent.Set(); } } catch (Exception ex) { Console.WriteLine(ex); } }
public void SortOutUnhittedVerticesForZeroVerticesHitted_Test() { // setup SetUp(); controller.RelevantVertices = new List <int>() { 0, 1, 2 }; int expected = 0; IRayTracer rt = Substitute.For <IRayTracer>(); rt.CreateRay(controller.GetRelevantVerticePositions()[0]).Returns(false); rt.CreateRay(controller.GetRelevantVerticePositions()[1]).Returns(false); rt.CreateRay(controller.GetRelevantVerticePositions()[2]).Returns(false); // perform controller.SortOutUnhittedVertices(rt); // assert Assert.AreEqual(expected, controller.RelevantVertices.Count); }
public LoggingRayTracer(IRayTracer rayTracer) { this.rayTracer = rayTracer; }
public DoubleLocalEstimation(IRayTracer rayTracer, int nPackets, int nRays, float wMin, ILog log) : this(rayTracer, nPackets, nRays, wMin) { this.Log = log; }
public Scene(IRayTracer tracer, bool constructBVH) { _tracer = tracer; _constructBvh = constructBVH; }
public DoubleLocalEstimationCalculator( Scene scene, IRayTracer rayTracer, int nRays, float wMin, ILog log ) : this( scene, rayTracer, nRays, wMin ) { this.Log = log; }
public App(IRayTracer rayTracer, ISceneProvider sceneProvider) { _rayTracer = rayTracer; _sceneProvider = sceneProvider; }
public SimpleRenderer(IRayTracer rayTracer) { this.RayTracer = rayTracer; }
public RayTraceProcessHandler(IRayTraceConfigurationModel confguration, IRayTracer rayTracer, IRayTraceTarget target) { this.confguration = confguration; this.rayTracer = rayTracer; this.target = target; }
public IList <Spectrum> GetIlluminance(IRayTracer rayTracer, IMaterial material, Point3D point, Vector normal, IList <Vector> view) { throw new NotImplementedException(); }
public MRenderDirectLight(MScene scene, IRayTracer rayTracer, ILog log = null) { Scene = scene; RayTracer = rayTracer; Log = log; }