Better readme
This commit is contained in:
parent
ff28d1d0c4
commit
5a0393115e
36
README.md
36
README.md
@ -1,6 +1,38 @@
|
|||||||
# Simple raytracer using zig
|
# Simple raytracer using zig
|
||||||
|
|
||||||
I did that to learn zig and ray tracing as it looked fun.
|
Project used to introduce me to Zig.
|
||||||
Greatly inspired by [Ray Tracing in a Weekend](https://raytracing.github.io/books/RayTracingInOneWeekend.html)
|
|
||||||
|
Greatly inspired by [Ray Tracing in a Weekend](https://raytracing.github.io/books/RayTracingInOneWeekend.html).
|
||||||
|
Added multi-thread and other stuffs.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
***Generated in 4200s on a Qualcomm X Elite 80.***
|
||||||
|
|
||||||
|
# Parameters
|
||||||
|
|
||||||
|
They are all in `camera.zig`.
|
||||||
|
|
||||||
|
```zig
|
||||||
|
// Resolution
|
||||||
|
const aspect_ratio: f64 = 16.0 / 9.0;
|
||||||
|
const image_width: usize = 2560; // Possible 128, 256, 512, 1024, 1280, 1920, 2560, 3840, 7680
|
||||||
|
const image_height: usize = image_width / aspect_ratio;
|
||||||
|
|
||||||
|
// Ray precision
|
||||||
|
const samples_per_pixel = 500;
|
||||||
|
const max_depth = 50;
|
||||||
|
|
||||||
|
// Camera lenses
|
||||||
|
const defocus_angle = 0.6;
|
||||||
|
const focus_dist = 10;
|
||||||
|
const vfov = 20;
|
||||||
|
|
||||||
|
// Camera position
|
||||||
|
const lookfrom = vec3{ 13, 2, 3 };
|
||||||
|
const lookat = vec3{ 0, 0, 0 };
|
||||||
|
const vup = vec3{ 0, 1, 0 };
|
||||||
|
|
||||||
|
// Number of thread to use
|
||||||
|
const n_threads_to_spawn = 100;
|
||||||
|
```
|
||||||
|
@ -32,20 +32,33 @@ const ThreadInfo = struct {
|
|||||||
semaphore_ptr: *Semaphore,
|
semaphore_ptr: *Semaphore,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Resolution parameters
|
// Resolution
|
||||||
const aspect_ratio: f64 = 16.0 / 9.0;
|
const aspect_ratio: f64 = 16.0 / 9.0;
|
||||||
const image_width: usize = 2560; // Possible 128, 256, 512, 1024, 1280, 1920, 2560, 3840, 7680
|
const image_width: usize = 2560; // Possible 128, 256, 512, 1024, 1280, 1920, 2560, 3840, 7680
|
||||||
const image_height: usize = image_width / aspect_ratio;
|
const image_height: usize = image_width / aspect_ratio;
|
||||||
|
|
||||||
|
// Ray precision
|
||||||
const samples_per_pixel = 500;
|
const samples_per_pixel = 500;
|
||||||
const max_depth = 50;
|
const max_depth = 50;
|
||||||
|
|
||||||
|
// Camera lenses
|
||||||
|
const defocus_angle = 0.6;
|
||||||
|
const focus_dist = 10;
|
||||||
|
const vfov = 20;
|
||||||
|
|
||||||
|
// Camera position
|
||||||
|
const lookfrom = vec3{ 13, 2, 3 };
|
||||||
|
const lookat = vec3{ 0, 0, 0 };
|
||||||
|
const vup = vec3{ 0, 1, 0 };
|
||||||
|
|
||||||
|
// Number of thread to use
|
||||||
const n_threads_to_spawn = 100;
|
const n_threads_to_spawn = 100;
|
||||||
|
|
||||||
|
// Global var for multi-thread
|
||||||
var completion_count: usize = 0;
|
var completion_count: usize = 0;
|
||||||
var next_entry_to_do: usize = 0;
|
var next_entry_to_do: usize = 0;
|
||||||
var entry_count: usize = 0;
|
var entry_count: usize = 0;
|
||||||
var entry_buffer: [image_width * image_height]Pixel = undefined;
|
var entry_buffer: [image_width * image_height]Pixel = undefined;
|
||||||
|
|
||||||
var _camera: *const Camera = undefined;
|
var _camera: *const Camera = undefined;
|
||||||
|
|
||||||
fn addWork(semaphore_ptr: *Semaphore) void {
|
fn addWork(semaphore_ptr: *Semaphore) void {
|
||||||
@ -166,14 +179,6 @@ pub const Camera = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(world: *const HittableList) Camera {
|
pub fn new(world: *const HittableList) Camera {
|
||||||
const vfov = 20;
|
|
||||||
const lookfrom = vec3{ 13, 2, 3 };
|
|
||||||
const lookat = vec3{ 0, 0, 0 };
|
|
||||||
const vup = vec3{ 0, 1, 0 };
|
|
||||||
|
|
||||||
const defocus_angle = 0.6;
|
|
||||||
const focus_dist = 10;
|
|
||||||
|
|
||||||
const camera_center = lookfrom;
|
const camera_center = lookfrom;
|
||||||
const pixel_samples_scale = 1.0 / @as(f64, @floatFromInt(samples_per_pixel));
|
const pixel_samples_scale = 1.0 / @as(f64, @floatFromInt(samples_per_pixel));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user