diff options
| -rw-r--r-- | include/vk-renderer.hpp | 4 | ||||
| -rw-r--r-- | shaders/compute.comp | 16 | ||||
| -rw-r--r-- | src/main.cpp | 10 |
3 files changed, 15 insertions, 15 deletions
diff --git a/include/vk-renderer.hpp b/include/vk-renderer.hpp index c1510c8..70fcc7e 100644 --- a/include/vk-renderer.hpp +++ b/include/vk-renderer.hpp @@ -42,8 +42,8 @@ struct input_data { float focus_distance; } cam; - float random_offset[200]; - float random_disk[200]; + float random_offset[2000]; + float random_disk[2000]; vec3 random_in_sphere[1000]; sphere spheres[512]; diff --git a/shaders/compute.comp b/shaders/compute.comp index c1c4163..6e6e8a1 100644 --- a/shaders/compute.comp +++ b/shaders/compute.comp @@ -5,9 +5,9 @@ struct ray { vec3 direction; }; -const uint LAMBERTIAN_MATERIAL = 0; -const uint METAL_MATERIAL = 1; -const uint DIELECTRIC_MATERIAL = 2; +const uint LAMBERTIAN_MATERIAL = 0; +const uint METAL_MATERIAL = 1; +const uint DIELECTRIC_MATERIAL = 2; struct material { vec4 albedo; @@ -48,8 +48,8 @@ layout(set = 0, binding = 0) buffer Inputs { vec4 ground_color; camera cam; - vec2[100] random_offset; - vec2[100] random_disk; + vec2[1000] random_offset; + vec2[1000] random_disk; vec4[1000] random_in_sphere; sphere[512] spheres; @@ -183,9 +183,9 @@ vec4 ray_color(ray r, uint sample_index) { vec2 seed = vec2(info.point.x * sample_index, info.point.y * bounces) * gl_GlobalInvocationID.xy; ray scattered; vec4 attenuation; - if (info.mat.type == LAMBERTIAN_MATERIAL && lambertian_scattering(info.mat, current_ray, seed, info, attenuation, scattered) || - info.mat.type == METAL_MATERIAL && metal_scattering(info.mat, current_ray, seed, info, attenuation, scattered) || - info.mat.type == DIELECTRIC_MATERIAL && dielectric_scattering(info.mat, current_ray, seed, info, attenuation, scattered)) { + if ((info.mat.type == LAMBERTIAN_MATERIAL && lambertian_scattering(info.mat, current_ray, seed, info, attenuation, scattered)) || + (info.mat.type == METAL_MATERIAL && metal_scattering(info.mat, current_ray, seed, info, attenuation, scattered)) || + (info.mat.type == DIELECTRIC_MATERIAL && dielectric_scattering(info.mat, current_ray, seed, info, attenuation, scattered))) { final_color *= attenuation; current_ray = scattered; } else { diff --git a/src/main.cpp b/src/main.cpp index f86529f..24fbf07 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -83,8 +83,8 @@ int main() { const float aspect_ratio = 16.0 / 9.0; const size_t width = 1920; const size_t height = width / aspect_ratio; - const uint32_t samples_per_pixel = 25; - const uint32_t max_depth = 50; + const uint32_t samples_per_pixel = 40; + const uint32_t max_depth = 20; const vec3 camera_position{ 13.0, 2.0, 3.0 }; const vec3 camera_target{ 0.0, 0.0, 0.0 }; @@ -106,18 +106,18 @@ int main() { }; // Random numbers pools - for (size_t rand_number_index = 0; rand_number_index < samples_per_pixel * 2; rand_number_index += 2) { + for (size_t rand_number_index = 0; rand_number_index < 1000; rand_number_index += 2) { inputs.random_offset[rand_number_index] = randd(); inputs.random_offset[rand_number_index + 1] = randd(); } - for (size_t rand_number_index = 0; rand_number_index < samples_per_pixel * 2; rand_number_index += 2) { + for (size_t rand_number_index = 0; rand_number_index < 1000; rand_number_index += 2) { vec3 random_unit_disk = random_in_unit_disk(); inputs.random_disk[rand_number_index] = random_unit_disk.x; inputs.random_disk[rand_number_index + 1] = random_unit_disk.y; } - for (size_t rand_number_index = 0; rand_number_index < max_depth * 10; rand_number_index++) { + for (size_t rand_number_index = 0; rand_number_index < 1000; rand_number_index++) { inputs.random_in_sphere[rand_number_index] = random_in_unit_sphere(); } |
