Skip to content

Commit 7d585b2

Browse files
authored
Merge pull request #897 from mu-lambda/dev-major
Fix scaling in the final Perlin noise texture.
2 parents 38084db + 02a19b5 commit 7d585b2

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Change Log -- Ray Tracing in One Weekend
3434
- Change: Broad rewrite of time management for moving objects, primarily `camera` and
3535
`moving_sphere`, but also impacting the API for `hittable::bounding_box()` (#799)
3636
- Fix: Fixed `bvh_node` constructor definition signature (#872)
37+
- Fix: Fixed scaling for final Perlin noise texture (#896).
3738

3839
### The Rest of Your Life
3940
- Fix: Added missing functionality for `isotropic` (#664)

books/RayTracingTheNextWeek.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,7 +2195,8 @@
21952195

21962196
color value(double u, double v, const point3& p) const override {
21972197
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
2198-
return color(1,1,1) * noise.turb(scale * p);
2198+
auto s = scale * p;
2199+
return color(1,1,1) * noise.turb(s);
21992200
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
22002201
}
22012202

@@ -2232,7 +2233,8 @@
22322233

22332234
color value(double u, double v, const point3& p) const override {
22342235
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
2235-
return color(1,1,1) * 0.5 * (1 + sin(scale*p.z() + 10*noise.turb(p)));
2236+
auto s = scale * p;
2237+
return color(1,1,1) * 0.5 * (1 + sin(s.z() + 10*noise.turb(s)));
22362238
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
22372239
}
22382240

books/acknowledgments.md.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
- Dan Drummond
3333
- [David Chambers](https://github.com/dafhi)
3434
- David Hart
35+
- [Dmitry Lomov](https://github.com/mu-lambda)
3536
- [Eric Haines](https://github.com/erich666)
3637
- Fabio Sancinetti
3738
- Filipe Scur

src/common/texture.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ class noise_texture : public texture {
7878
noise_texture(double sc) : scale(sc) {}
7979

8080
color value(double u, double v, const point3& p) const override {
81-
return color(1,1,1)*0.5*(1 + sin(scale*p.z() + 10*noise.turb(p)));
81+
auto s = scale * p;
82+
return color(1,1,1)*0.5*(1 + sin(s.z() + 10*noise.turb(s)));
8283
}
8384

8485
public:

0 commit comments

Comments
 (0)