private Vector3 FindRecursiveIntensity() { var reflectedRay = GetReflectedRay(); var intersection = new Intersection(reflectedRay); var intersectionInfo = intersection.FindClosestIntersection(); var colorFinder = new ColorFinder(reflectedRay, intersectionInfo, ++_recursionLevel); return(colorFinder.FindColor()); }
private static void CreateImage() { var p = new Bitmap(ImageWidth, ImageHeight); for (var i = 0; i < ImageWidth; i++) { for (var j = 0; j < ImageHeight; j++) { var ray = new Ray(i + 0.5f, j + 0.5f); var intersection = new Intersection(ray); var intersectionInfo = intersection.FindClosestIntersection(); var colorFinder = new ColorFinder(ray, intersectionInfo, 0); var pixelColor = colorFinder.FindColor(); var rgb = pixelColor.ToArray().Select(x => (int)x.Map(0, 1, 0, 255)).ToArray(); p.SetPixel(i, j, Color.FromArgb(255, rgb[0], rgb[1], rgb[2])); } } //p.Save(@"D:\Docs\Courses\Computer graphics edx\img.png", ImageFormat.Png); p.Save(GetFileNameGen(), ImageFormat.Png); }