Main Web Site (Online Books)
This alpha wraps up most of the major changes we expect to make to book 2 for the impending v4.0.0 release, along with a bunch of updates to the other two books. Since the alpha.1 release last August, we've been lucky to have onboarded two new contributors: Arman Uguray and Nate Rupsis. They've been helping out a ton with this release, and Arman is also developing his GPU Ray Tracing book at the same time!
This release is a bit faster, thanks to some new BVH optimizations. We've eliminated the negative radius sphere hack to model hollow spheres, instead accomplishing this with refraction indices. This eliminates a bunch of places in the code where we had to accomodate this, and probably a bunch of bugs we still haven't found. We now load texture images in linear color space, fixing a long-running bug where we were gamma-correcting our textures twice -- you'll notice object texture maps look a bit darker and less washed out. Refraction text has gotten a bit of an overhaul, and a better example of total internal reflection. Of course, this also includes a load of small fixes, tweaks, and improvements.
Our current plan is to get the final v4.0.0 release out the door by SIGGRAPH 2024, targeting July 28. With that, here are the latest changes since our alpha.1 release:
rtw_stb_image.h
header from book 1 source, as it's unused there.double(x)
instead of static_cast<double>(x)
, and similarly for other types, for
easier readability for non-C++ programmers.ray
class constructors no longer use C++ default parameter valueswrite_color()
. This simplifies write_color()
to take only the desired output color, and made each phase in color computation easier
to understand.ray::origin()
and ray::direction()
getters now return const references, avoiding
unnecessary copies.hit_record
class in material.h
vec3
, point3
, ray
, and color
parameters by const reference where
possible (#1250)material::scatter()
gets a trivial default implementation (#1455)random_in_hemisphere()
to random_on_hemisphere()
(#1198)linear_to_gamma()
function has been hardened against negative inputs (#1202)quad
bounding box now considers all four vertices instead of erroneously only
using two (#1402)lambertian
texture support (#1258)perlin::turb()
no longer defaults the value for the depth parameter.aabb::axis()
to aabb::axis_interval()
. Minor
refactoring of aabb::hit()
function. (#927, #1270)turb()
functions with scaled points (these should
be unscaled). (#1286)operatorname
(#1311)It's been quite a while since our last release of v3.2.3 at the end of 2020. For this cycle, we've tackled a load of significant backlog items, including rewrites of much of our underlying code. As always, the primary idea isn't to provide the best or most optimal implemntation, but instead to put out simple, sometimes crude first approximations of the main components of writing a ray tracer.
Highlights include large rewrites and expansions of the book text, a large refactoring of our camera class, folding moving_sphere
functionality into sphere
, adding a new interval
class for use in multiple contexts, creating a new general quad
primitive to replace the old *_rect
primitives, and the addressing of hundreds of issues and requested features. The line-item changes below should give you an idea of v4 includes.
In order to drive this release to resolution, we're releasing our alpha.1 version to coincide with the start of SIGGRAPH 2023. We've pretty much finished with book one, though there's a fair amount left for books two and three. Our plan is to keep crunching for a final v4.0.0 release by the end of 2023.
Since this is an alpha, we would greatly appreciate any feedback you might have. Let us know by creating issues up on the GitHub project.
virtual
keyword for methods with override
(#805)rect
hit returning NaNs and infinities (#681)\mathit
to italic math variables to fix slight kerning issues in equations (#839)class
instead of struct
throughout for simpler C++ (#781)inline
clean. We now use inline
in all header function definitions to
guard against copies in multiple C++ translation units (#803)src/common/
directory. Each book now has complete source in one directorycamera
classaabb
class constructor treats two params as extreme points in any orientation (#733)hittable:hit()
methods use new interval class for ray-t parameterinterval::clamp()
replaces standalone clamp
utility functionaabb
class uses intervals for each axis (#796)hittable
member variable ptr
renamed to object
mat_ptr
to mat
(material)hittable::bounding_box()
signature has changed to always return a value (#859)isotropic
with random_unit_vector
camera
class now handles images with width or height of one (#682, #1040)interval
class used throughout codebase (#777)rtw_image
class for easier image data loading, better texture file search (#807)quad
primitive of arbitrary orientation (#756)box()
utility function returns hittable_list
of new quad
primitives (#780)box
, xy_rect
, yz_rect
, xz_rect
classes. These are replaced with new quad
primitive (#292, #780, #681)double
and float
(#752)bvh_node
constructor definition signature (#872)camera
and
sphere
, but also impacting the API for hittable::bounding_box()
(#799)sphere
class now includes animation capability originally in moving_sphere
(#1125)bvh_node
class in the random_spheres
scene (#715).moving_sphere
class is deprecated, and functionality moved to sphere
(#1125)isotropic
(#664)direction
was used without being defined in listing 11 (#831)fmin
to book text for cos_theta
of refract
(#732)random_unit_vector()
was incorrect (#697)hittable.h
hittable_list.h
, material.h
, sphere.h
sphere::hit()
method to reuse common blocks of code.lambertian::scatter()
yields degenerate scatter rays (#619)lambertian::scatter()
yields degenerate scatter rays (#619)override
keyword for xz_rect::pdf_value()
and xz_rect::random()
methods
(#748)cornell_box()
function.ray_color()
was creating a new light for every ray bounce (#759)STBI_FREE
instead of delete (#734)cstdlib
include; not needed until we use rand()
(#687)rtweekend.h
include (#691)vup
variable in camera definition (#686)hittable.h
, rtweekend.h
includes (#693)trilinear_interp
(#722)bvh_node
no longer reorders the source vector of scene objects; uses local copy
instead (#701)perlin::noise()
function (#684)bvh.h
, add missing hittable_list.h
include (#690)perlin.h
in the caption to texture.h
(#698)bvh.h
(#694)main.cc
: Change a fuzz value of a metal sphere to 1.0 which is the maximum
value (#694)We're still chasing that elusive stable project state where we're mostly done with large changes, yet we keep finding more and more to tweak and improve. Besides the usual batch of corrections and small improvements, for this change we plodded through the complete code progression for both books one and two (In One Weekend and The Next Week). This caught a lot of issues (to our dismay), and allowed us to generate a complete set of new render images for both books, to catch up with all of the changes we've been making. The end result is that readers should find a significantly better agreement between the book and their code as they progress, and their renders should also generally match.
Besides the new rendered images, we also much improved the image parameters, which were frequently missing from the previous version, leaving readers to guess at their values, or go to the code to try to figure out how we created some of the images. In general, our working renders are now 400 pixels wide, usually 16:9 aspect ratio. We now use an explicit aspect ratio and deduce the image height and other camera values, so you can tweak your render size just by changing the image width (instead of updating a bunch of dependent parameters).
One interesting late change we made was adding explicit C++ override
labels to subclass methods.
We did this mostly to aid code readers, but were surprised to find that it actually caught a pretty
significant bug hiding in our code (see entry in common changes below).
You'll also see a new citation section at the end of the books, to encourage uniform citations out in the world, making it easier for people to refer to and track these books.
As is typical, though we roughly follow semantic versioning, we're considering this release a minor change instead of a major one. It's a common reflex, because people generally have a (misguided) aversion to bumping the major version a lot. We consider it minor because most of the changes are quite local, some classes get new constructors and any variances should be quite simple and easy to fix up. Still, one might consider this more properly a major version bump.
For our next larger-than-patch release, we're beginning a large revisit of book 3, Ray Tracing: The Rest of Your Life. There's a lot of work to do, and this will likely be a significant change and improvement. We're hoping that changes to books one and two will be small, but that's never worked out for us before. Ah, dreams.
isotropic::scatter()
method. Commented out, using default
(as it was previously). (#669)vec3::write_color()
method (now in color.h){fig,img}-<book>.<sequence>-<title>.<filetype>
(#495)main()
function gets organized into image, world, camera, and render chunkscolor
arguments in addition to the constructors
taking shared_ptr<texture>
arguments, simplifying calling code. Applies to checker_texture
,
constant_medium
, diffuse_light
, lambertian
, and isotropic
(#516, #644)override
keywords throughout. This keyword marks a subclass method as one that
is intended to override a superclass method. It makes the code a bit easier to understand, and
ensures that your function is actually overriding the method you think it is. Which is good,
because it already caught an existing bug in The Rest of Your Life source. This change
includes commenting out the book 3 isotropic::scatter()
method, which was accidentally ignored
anyway. (#639, #669)etai_over_etat
color.h
, vec3.h
includesdouble t
member of struct hit_record
(#428)color.h
includecamera.h
includeray.h
when using rtweekend.h
material.h
includerefract()
function was missing fabs()
on sqrt()
argument (#559)cam
declaration, show context w/highlightingcamera::get_ray()
parameters to s, t (#616)flip_face
class, renumbered images as this
eliminated the rendering with missing Cornell box faces (#270, #482, #661)cornell_balls
and cornell_final
), as these were not
covered in the book. Made the source and book consistent with each other. There are now a total
of eight scenes for the second book (#653, #620)dielectric::scatter()
functionmoving-sphere.h
vup
for camera, as in other two booksmain()
, and include full body in book listing (#646)flip_face
moved to book 3, where it's needed for the light source (#661)ray_color()
, listing 20 (#606)random_double()
switched distribution
, generator
(#621)light_shape
should have default material, not 0
(#607)mixture_pdf
needs shared_ptr
arguments (#608)shared_ptr
dereference and simplify code in hittable_list::bounding_box()
(#435)–>
with ->
(#439)u
,v
surface coordinates to hit_record
(#441)hittable::bounding_box()
method (#442)integrate_x_sq.cc
<random>
version of random_double()
no longer depends on <functional>
header.random_scene()
. More named intermediate values, sync'ed with source.
(#489)color
to solid_color
.random_scene()
.hit_record
(#496)std::sort
instead of qsort
(#490)random_scene()
. More named intermediate values, sync'ed with version in
In One Weekend and with source. Added highlight for update from last version in book 1. (#489)<random>
version of random_double()
no longer depends on <functional>
header