Skip to content

Commit 3228df0

Browse files
authored
Merge pull request #454 from RayTracing/fix-441
Introduce u,v coords to hit_record
2 parents 71fa88e + a77e0c2 commit 3228df0

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Change Log -- Ray Tracing in One Weekend
1313
### _The Next Week_
1414
- Fix: `shared_ptr` dereference and simplify code in `hittable_list::bounding_box()` (#435)
1515
- Fix: Erroneous en-dash in code block. Replace `–>` with `->` (#439)
16+
- Fix: Introduce `u`,`v` surface coordinates to `hit_record` (#441)
1617
- Fix: Add highlight to new `hittable::bounding_box()` method (#442)
1718

1819

books/RayTracingTheNextWeek.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,24 @@
898898
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
899899
[Listing [texture]: <kbd>[texture.h]</kbd> A texture class]
900900

901+
We'll need to update the `hit_record` structure to store the U,V surface coordinates of the
902+
ray-object hit point.
903+
904+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
905+
struct hit_record {
906+
vec3 p;
907+
vec3 normal;
908+
shared_ptr<material> mat_ptr;
909+
double t;
910+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
911+
double u;
912+
double v;
913+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
914+
bool front_face;
915+
...
916+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
917+
[Listing [hit-record-uv]: <kbd>[hittable.h]</kbd> Adding U,V coordinates to the `hit_record`]
918+
901919
<div class='together'>
902920
Now we can make textured materials by replacing the vec3 color with a texture pointer:
903921

0 commit comments

Comments
 (0)