Computer Graphics from Scratch demystifies the algorithms used in modern graphics software and guides beginners through building photorealistic 3D renders.
Computer graphics are at work everywhere today, adding eye-popping details to video games, hyper-realistic CGI to major blockbusters, and life-like imagery to computer-animated films. This beginners book will introduce you to a core slice of this ever-expanding field, 3D rendering, with a focus on two popular algorithmic methods: raytracing and rasterization.
Written to be easily understood by high-school students but rigorous enough for professional engineers, you’ll build each of these surprisingly simple algorithms into complete, fully functional renderers as you build your knowledge base. The first half covers raytracing, which simulates rays of light as they bounce off of objects in a scene; the second half breaks down rasterization, the real-time process for converting 3D graphics into a screen-compatible array of 2D pixels. Every chapter gives you something visually new and exciting to add to your works-in-progress, from creating reflections and shadows that make objects look more realistic, to rendering a scene from any directional point of view.
You’ll learn how to:
• Represent objects in a scene, and use perspective projection to draw them in
• Compute the illumination for light sources (point, directional, and ambient)
• Render mirror-like reflections on surfaces, and cast shadows for depth
• Use clipping algorithms to render a scene from any camera position
• Implement flat shading, Gouraud shading, and Phong shading algorithms
• "Paint” textures that fake surface details and turn shapes into everyday objects
The book uses informal pseudocode throughout the text, so you can write your renderers in any language. In addition, the author provides links to live working versions of his algorithms.
Author(s): Gabriel Gambetta
Edition: 1
Publisher: No Starch Press
Year: 2021
Language: English
Commentary: Vector PDF
Pages: 248
City: San Francisco, CA
Tags: Rendering; Graphics; Texturing; Linear Algebra; Color; Elementary; Raytracing; Shading
Brief Contents
Contents in Detail
Acknowledgments
Introduction
Who This Book Is For
What This Book Covers
Why Read This Book?
About This Book
About the Author
Chapter 1: Introductory Concepts
The Canvas
Coordinate Systems
Color Models
Subtractive Color Model
Additive Color Model
Forget the Details
Color Depth and Representation
Color Manipulation
The Scene
Summary
Part 1: Raytracing
Chapter 2: Basic Raytracing
Rendering a Swiss Landscape
Basic Assumptions
Canvas to Viewport
Tracing Rays
The Ray Equation
The Sphere Equation
Ray Meets Sphere
Rendering our First Spheres
Summary
Chapter 3: Light
Simplifying Assumptions
Light Sources
Point Lights
Directional Lights
Ambient Light
Illumination of a Single Point
Diffuse Reflection
Modeling Diffuse Reflection
The Diffuse Reflection Equation
Sphere Normals
Rendering with Diffuse Reflection
Specular Reflection
Modeling Specular Reflection
The Specular Reflection Term
The Full Illumination Equation
Rendering with Specular Reflections
Summary
Chapter 4: Shadows and Reflections
Shadows
Understanding Shadows
Rendering with Shadows
Reflections
Mirrors and Reflection
Rendering with Reflections
Summary
Chapter 5: Extending the Raytracer
Arbitrary Camera Positioning
Performance Optimizations
Parallelization
Caching Immutable Values
Shadow Optimizations
Spatial Structures
Subsampling
Supporting Other Primitives
Constructive Solid Geometry
Transparency
Refraction
Supersampling
Summary
Part 2: Rasterization
Chapter 6: Lines
Describing Lines
Drawing Lines
Drawing Lines with Any Slope
The Linear Interpolation Function
Summary
Chapter 7: Filled Triangles
Drawing Wireframe Triangles
Drawing Filled Triangles
Summary
Chapter 8: Shaded Triangles
Defining Our Problem
Computing Edge Shading
Computing Interior Shading
Summary
Chapter 9: Perspective Projection
Basic Assumptions
Finding P’
The Projection Equation
Properties of the Projection Equation
Projecting Our First 3D Object
Summary
Chapter 10: Describing and Rendering a Scene
Representing a Cube
Models and Instances
Model Transform
Camera Transform
The Transform Matrix
Homogeneous Coordinates
Homogeneous Rotation Matrix
Homogeneous Scale Matrix
Homogeneous Translation Matrix
Homogeneous Projection Matrix
Homogeneous Viewport-to-Canvas Matrix
The Transform Matrix Revisited
Summary
Chapter 11: Clipping
An Overview of the Clipping Process
The Clipping Volume
Clipping the Scene Against a Plane
Defining the Clipping Planes
Clipping Whole Objects
Clipping Triangles
Segment-Plane Intersection
Clipping Pseudocode
Clipping in the Rendering Pipeline
Summary
Chapter 12: Hidden Surface Removal
Rendering Solid Objects
Painter’s Algorithm
Depth Buffering
Using 1/Z instead of Z
Back Face Culling
Classifying Triangles
Summary
Chapter 13: Shading
Shading vs. Illumination
Flat Shading
Gouraud Shading
Phong Shading
Summary
Chapter 14: Textures
Painting a Crate
Bilinear Filtering
Mipmapping
Trilinear Filtering
Summary
Chapter 15: Extending the Rasterizer
Normal Mapping
Environment Mapping
Shadows
Stencil Shadows
Shadow Mapping
Summary
Afterword
Appendix: Linear Algebra
Points
Vectors
Representing Vectors
Vector Magnitude
Point and Vector Operations
Subtracting Points
Adding a Point and a Vector
Adding Vectors
Multiplying a Vector by a Number
Multiplying Vectors
Matrices
Matrix Operations
Adding Matrices
Multiplying a Matrix by a Number
Multiplying Matrices
Multiplying a Matrix and a Vector
Index