-
Notifications
You must be signed in to change notification settings - Fork 899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
now nonskippdf materials can be added to lights hittable list #1674
base: dev-patch
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
|
||
build/ | ||
/*.ppm | ||
|
||
.vscode/ | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,9 +59,14 @@ class hittable_list : public hittable { | |
return sum; | ||
} | ||
|
||
vec3 random(const point3& origin) const override { | ||
auto int_size = int(objects.size()); | ||
return objects[random_int(0, int_size-1)]->random(origin); | ||
vec3 random(const point3& origin) const override { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation error. |
||
int int_size = int(objects.size()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the change to make this a double declaration? |
||
auto vec = objects[random_int(0, int_size-1)]->random(origin); | ||
while (vec.is_nan()) { | ||
vec = objects[random_int(0, int_size-1)]->random(origin); | ||
} | ||
Comment on lines
+64
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This pattern calls for a do-while loop to eliminate the code duplication. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More generally, a vector that contains a NaN value has issues before this code executes, so we still need to find the root cause for why this happens and fix it at the source. Addressing it here is too late. |
||
|
||
return vec; | ||
} | ||
|
||
private: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,8 @@ int main() { | |
|
||
// Glass Sphere | ||
auto glass = make_shared<dielectric>(1.5); | ||
world.add(make_shared<sphere>(point3(190,90,190), 90, glass)); | ||
auto nonglass = make_shared<lambertian>(color(0.8, 0.2, 0.4)); | ||
world.add(make_shared<sphere>(point3(190,90,190), 90, nonglass)); | ||
Comment on lines
+47
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be a testing artifact that made it into your PR. |
||
|
||
// Light Sources | ||
auto empty_material = shared_ptr<material>(); | ||
|
@@ -56,9 +57,9 @@ int main() { | |
camera cam; | ||
|
||
cam.aspect_ratio = 1.0; | ||
cam.image_width = 600; | ||
cam.samples_per_pixel = 100; | ||
cam.max_depth = 50; | ||
cam.image_width = 400; | ||
cam.samples_per_pixel = 1000; | ||
cam.max_depth = 10; | ||
Comment on lines
+60
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More testing artifacts. |
||
cam.background = color(0,0,0); | ||
|
||
cam.vfov = 40; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,11 +76,14 @@ class sphere : public hittable { | |
if (!this->hit(ray(origin, direction), interval(0.001, infinity), rec)) | ||
return 0; | ||
|
||
auto dist_squared = (center.at(0) - origin).length_squared(); | ||
auto cos_theta_max = std::sqrt(1 - radius*radius/dist_squared); | ||
auto cos_theta_max = sqrt(1 - radius*radius/(center.at(0) - origin).length_squared()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand the motivation for this change. It doesn't seem related to the PR purpose. |
||
auto solid_angle = 2*pi*(1-cos_theta_max); | ||
|
||
return 1 / solid_angle; | ||
if (std::isnan(solid_angle) || std::fabs(solid_angle) < 1e-3) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the reasoning for such a large minimum value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why would → Seems like this needs further digging to figure out why this is an issue. |
||
return 0; | ||
} else { | ||
return 1 / solid_angle; | ||
} | ||
} | ||
|
||
vec3 random(const point3& origin) const override { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an artifact of your own personal environment, so it belongs in your personal global .gitconfig file (along with other things like editor, tool, tagging, OS and other artifacts that come from your general environment and toolsets).