public static byte[] Start() { // create objects var scene = new Scene(); scene.Objects = new Sphere[] { new Sphere(new Vec3(0.0f, -10002.0f, -20.0f), 10000, new Vec3(.8f, .8f, .8f)), new Sphere(new Vec3(0.0f, 2.0f, -20.0f), 4, new Vec3(.8f, .5f, .5f), 0.5f), new Sphere(new Vec3(5.0f, 0.0f, -15.0f), 2, new Vec3(.3f, .8f, .8f), 0.2f), new Sphere(new Vec3(-5.0f, 0.0f, -15.0f), 2, new Vec3(.3f, .5f, .8f), 0.2f), new Sphere(new Vec3(-2.0f, -1.0f, -10.0f), 1, new Vec3(.1f, .1f, .1f), 0.1f, 0.8f) }; scene.Lights = new Light[] { new Light(new Vec3(-10, 20, 30), new Vec3(2, 2, 2)) }; int pixelsLength = Benchmark.Width * Benchmark.Height * 3; byte[] pixels = new byte[pixelsLength]; // give the system a little time Console.WriteLine("Starting test..."); // run test // var watch = new Stopwatch(); // watch.Start(); var data = Benchmark.Render(scene, pixels); // watch.Stop(); // Console.WriteLine("Sec: " + (watch.ElapsedMilliseconds / 1000d)); // save image return(pixels); }
public static void Start() #endif { // create objects var scene = new Scene(); scene.Objects = new Sphere[] { new Sphere(new Vec3(0.0f, -10002.0f, -20.0f), 10000, new Vec3(.8f, .8f, .8f), 0, 0), new Sphere(new Vec3(0.0f, 2.0f, -20.0f), 4, new Vec3(.8f, .5f, .5f), 0.5f, 0), new Sphere(new Vec3(5.0f, 0.0f, -15.0f), 2, new Vec3(.3f, .8f, .8f), 0.2f, 0), new Sphere(new Vec3(-5.0f, 0.0f, -15.0f), 2, new Vec3(.3f, .5f, .8f), 0.2f, 0), new Sphere(new Vec3(-2.0f, -1.0f, -10.0f), 1, new Vec3(.1f, .1f, .1f), 0.1f, 0.8f) }; scene.Lights = new Light[] { new Light(new Vec3(-10, 20, 30), new Vec3(2, 2, 2)) }; int pixelsLength = Benchmark.Width * Benchmark.Height * 3; byte[] pixels = new byte[pixelsLength]; // give the system a little time #if !JSIL GC.Collect(); Console.WriteLine("Give the system a little time..."); Thread.Sleep(2000); #endif Console.WriteLine("Starting test..."); // run test #if WIN32 Win32OptimizedStopwatch(); #endif var watch = new Stopwatch(); watch.Start(); var data = Benchmark.Render(scene, pixels); watch.Stop(); TimeToComplete = "Sec: " + (watch.ElapsedMilliseconds / 1000d).ToString(); Console.WriteLine(TimeToComplete); #if WIN32 Win32EndOptimizedStopwatch(); #endif //return; // save image #if UWP || WIN8 || WP8 || WP7 || ANDROID || IOS || VITA if (SaveImageCallback != null) { SaveImageCallback(data); } #elif !JSIL && !UNITY3D /*Console.ReadLine(); * using (var file = new FileStream("Image.rgb", FileMode.Create, FileAccess.Write)) * using (var writer = new BinaryWriter(file)) * { * for (int i = 0; i != pixelsLength; ++i) * { * file.WriteByte(data[i]); * } * }*/ #else return(pixels); #endif }