|
2 | 2 | #include <algorithm> |
3 | 3 | #include <chrono> |
4 | 4 | #include <cstdint> |
| 5 | +#include <ctime> |
5 | 6 | #include <iostream> |
6 | 7 | #include <iterator> |
7 | 8 | #include <math.h> |
@@ -79,17 +80,29 @@ int main(int argc, char* argv[]) { |
79 | 80 | hittables.emplace_back(sphere(point { 0, -1000, 0 }, 1000, m)); |
80 | 81 | t = checker_texture(color { 0.9f, 0.9f, 0.9f }, color { 0.4f, 0.2f, 0.1f }); |
81 | 82 |
|
82 | | - LocalPseudoRNG rng; |
| 83 | + LocalPseudoRNG rng{static_cast<uint32_t>(std::time(nullptr))}; |
83 | 84 |
|
84 | | - for (int a = -11; a < 11; a += 3) { |
85 | | - for (int b = -11; b < 11; b += 3) { |
| 85 | + for (int a = -11; a < 11; a++) { |
| 86 | + for (int b = -11; b < 11; b++) { |
| 87 | + auto choose_mat = rng.real(); |
86 | 88 | // Spheres are placed at a point randomly displaced from a,b |
87 | 89 | point center(a + 0.9f * rng.real(), 0.2f, b + 0.9f * rng.real()); |
88 | | - if (sycl::length((center - point(4, 0.2f, 0))) > 0.9f) { |
| 90 | + if (choose_mat < 0.70f) { |
89 | 91 | // Lambertian |
90 | 92 | auto albedo = rng.vec_t() * rng.vec_t(); |
91 | 93 | hittables.emplace_back( |
92 | 94 | sphere(center, 0.2f, lambertian_material(albedo))); |
| 95 | + } else if (choose_mat < 0.95f) { |
| 96 | + // metal |
| 97 | + auto albedo = rng.vec_t(0.5f, 1); |
| 98 | + auto fuzz = rng.real(0, 0.5f); |
| 99 | + hittables.emplace_back( |
| 100 | + sphere(center, 0.2f, metal_material(albedo, fuzz))); |
| 101 | + } else { |
| 102 | + // glass |
| 103 | + hittables.emplace_back( |
| 104 | + sphere(center, 0.2f, |
| 105 | + dielectric_material(1.5f, color { 1.0f, 1.0f, 1.0f }))); |
93 | 106 | } |
94 | 107 | } |
95 | 108 | } |
@@ -127,23 +140,20 @@ int main(int argc, char* argv[]) { |
127 | 140 | hittables.emplace_back(sphere(point { 0, 1, -2.25f }, 1, |
128 | 141 | metal_material(color(0.7f, 0.6f, 0.5f), 0.0f))); |
129 | 142 |
|
130 | | - // t = image_texture::image_texture_factory("../images/SYCL.png", 5); |
131 | | - |
132 | | - // // Add a sphere with a SYCL logo in the background |
133 | 143 | hittables.emplace_back( |
134 | 144 | sphere { point { -60, 3, 5 }, 4, lambertian_material { t } }); |
135 | 145 |
|
136 | 146 | // Add a metallic monolith |
137 | 147 | hittables.emplace_back( |
138 | 148 | box { point { 6.5f, 0, -1.5f }, point { 7.0f, 3.0f, -1.0f }, |
139 | | - metal_material { color { 0.7f, 0.6f, 0.5f }, 0.25f } });/**/ |
| 149 | + metal_material { color { 0.7f, 0.6f, 0.5f }, 0.25f } }); |
140 | 150 |
|
141 | 151 | // Add a smoke ball |
142 | 152 | sphere smoke_sphere = |
143 | 153 | sphere { point { 5, 1, 3.5f }, 1, |
144 | 154 | lambertian_material { color { 0.75f, 0.75f, 0.75f } } }; |
145 | | - /*hittables.emplace_back( |
146 | | - constant_medium { smoke_sphere, 1, color { 1, 1, 1 } });*/ |
| 155 | + hittables.emplace_back( |
| 156 | + constant_medium { smoke_sphere, 1, color { 1, 1, 1 } }); |
147 | 157 |
|
148 | 158 | // SYCL queue |
149 | 159 | sycl::queue myQueue; |
|
0 commit comments