Muutke küpsiste eelistusi

Ray Tracer Challenge [Pehme köide]

  • Formaat: Paperback / softback, 292 pages, kõrgus x laius x paksus: 235x190x15 mm, Illustrations
  • Sari: Pragmatic Bookshelf
  • Ilmumisaeg: 16-May-2019
  • Kirjastus: The Pragmatic Programmers
  • ISBN-10: 1680502719
  • ISBN-13: 9781680502718
  • Formaat: Paperback / softback, 292 pages, kõrgus x laius x paksus: 235x190x15 mm, Illustrations
  • Sari: Pragmatic Bookshelf
  • Ilmumisaeg: 16-May-2019
  • Kirjastus: The Pragmatic Programmers
  • ISBN-10: 1680502719
  • ISBN-13: 9781680502718
Brace yourself for a fun challenge: build a photorealistic 3D renderer from scratch! It's easier than you think. In just a couple of weeks, build a ray-tracer that renders beautiful scenes with shadows, reflections, brilliant refraction effects, and subjects composed of various graphics primitives: spheres, cubes, cylinders, triangles, and more. With each chapter, implement another piece of the puzzle and move the renderer that much further forward. Do all of this in whichever language and environment you prefer, and do it entirely test-first, so you know it's correct. Recharge yourself with this project's immense potential for personal exploration, experimentation, and discovery.



The renderer is a ray tracer, which means it simulates the physics of light by tracing the path of light rays around your scene. Each exciting chapter presents a bite-sized piece of the puzzle, building on earlier chapters and setting the stage for later ones. Requirements are given in plain English, which you translate into tests and code. When the project is complete, look back and realize you've built an entire system test-first!



There's no research necessary -- all the necessary formulas and algorithms are presented and illustrated right here. Dive into intriguing topics from fundamental concepts such as vectors and matrices; to the algorithms that simulate the intersection of light rays with spheres, planes, cubes, cylinders, and triangles; to geometric patterns such as checkers and rings. Lighting and shading effects, such as shadows and reflections, make your scenes come to life, and constructive solid geometry (CSG) enables you to combine your graphics primitives in simple ways to produce complex shapes.



Play and experiment as you discover the fun of writing a ray tracer. Accept the challenge today!



What You Need:









Aside from a computer, operating system, and programming environment, you'll need a way to display PPM image files. On Windows, programs like Photoshop will work, or free programs like IrfanView. On Mac, no special software is needed, as Preview can open PPM files.
Acknowledgments ix
Foreword xi
Getting Started xiii
1 Tuples, Points, and Vectors
1(14)
Tuples
2(3)
Operations
5(7)
Putting It Together
12(3)
2 Drawing on a Canvas
15(10)
Representing Colors
15(1)
Implementing Color Operations
16(3)
Creating a Canvas
19(1)
Saving a Canvas
19(3)
Putting It Together
22(3)
3 Matrices
25(18)
Creating a Matrix
26(2)
Multiplying Matrices
28(3)
The Identity Matrix
31(1)
Transposing Matrices
32(1)
Inverting Matrices
33(9)
Putting It Together
42(1)
4 Matrix Transformations
43(14)
Translation
44(2)
Scaling
46(1)
Rotation
47(4)
Shearing
51(2)
Chaining Transformations
53(1)
Putting It Together
54(3)
5 Ray-Sphere Intersections
57(18)
Creating Rays
57(2)
Intersecting Rays with Spheres
59(4)
Tracking Intersections
63(1)
Identifying Hits
64(2)
Transforming Rays and Spheres
66(4)
Putting It Together
70(5)
6 Light and Shading
75(16)
Surface Normals
76(6)
Reflecting Vectors
82(1)
The Phong Reflection Model
83(6)
Putting It Together
89(2)
7 Making a Scene
91(18)
Building a World
92(5)
Defining a View Transformation
97(3)
Implementing a Camera
100(5)
Putting It Together
105(4)
8 Shadows
109(8)
Lighting in Shadows
110(1)
Testing for Shadows
111(2)
Rendering Shadows
113(3)
Putting It Together
116(1)
9 Planes
117(10)
Refactoring Shapes
117(5)
Implementing a Plane
122(2)
Putting It Together
124(3)
10 Patterns
127(14)
Making a Striped Pattern
128(2)
Transforming Patterns
130(2)
Generalizing Patterns
132(2)
Making a Gradient Pattern
134(1)
Making a Ring Pattern
135(1)
Making a 3D Checker Pattern
136(2)
Putting It Together
138(3)
11 Reflection and Refraction
141(26)
Reflection
142(7)
Transparency and Refraction
149(11)
Fresnel Effect
160(5)
Putting It Together
165(2)
12 Cubes
167(10)
Intersecting a Ray with a Cube
168(5)
Finding the Normal on a Cube
173(2)
Putting It Together
175(2)
13 Cylinders
177(16)
Intersecting a Ray with a Cylinder
178(2)
Finding the Normal on a Cylinder
180(1)
Truncating Cylinders
181(3)
Capped Cylinders
184(4)
Cones
188(3)
Putting It Together
191(2)
14 Groups
193(14)
Implementing Groups
194(3)
Finding the Normal on a Child Object
197(3)
Using Bounding Boxes to Optimize Large Scenes
200(3)
Putting It Together
203(4)
15 Triangles
207(20)
Triangles
208(4)
Wavefront OBJ Files
212(6)
Smooth Triangles
218(5)
Smooth Triangles in OBJ Files
223(2)
Putting It Together
225(2)
16 Constructive Solid Geometry (CSG)
227(12)
Implementing CSG
229(8)
Coloring CSG Shapes
237(1)
Putting It Together
237(2)
17 Next Steps
239(10)
Area Lights and Soft Shadows
239(1)
Spotlights
240(1)
Focal Blur
241(1)
Motion Blur
242(1)
Anti-aliasing
243(1)
Texture Maps
244(1)
Normal Perturbation
245(1)
Torus Primitive
246(1)
Wrapping It Up
247(2)
A1 Rendering the Cover Image 249(6)
Index 255
Jamis Buck has been active in open source for years, and has a deep passion for learning. He loves programming puzzles and trying new things, and especially enjoys finding ways to make programming fun again.