Real-Time 3D Graphics with WebGL 2 [2 ed.]
1788629698, 9781788629690, 1788837878, 9781788837873
As highly interactive applications have become an increasingly important part of the user experience, WebGL is a unique
1,612
113
88MB
English
Pages 500
Year 2018
Report DMCA / Copyright
DOWNLOAD EPUB FILE
Table of contents :
1: Getting Started
System Requirements
WebGL Rendering
Elements in a WebGL Application
Time for Action: Creating an HTML5 Canvas Element
Time for Action: Accessing the WebGL Context
State Machine
Time for Action: Setting up WebGL Context Attributes
Loading a 3D Scene
Time for Action: Visualizing a 3D Showroom
Architecture Updates
Summary
2: Rendering
WebGL Rendering Pipeline
Rendering in WebGL
Time for Action: Rendering a Square
Vertex Array Objects
Time for Action: Rendering a Square Using a VAO
Time for Action: Rendering Modes
WebGL as a State Machine: Buffer Manipulation
Time for Action: Querying the State of Buffers
Advanced Geometry-Loading Techniques
Time for Action: Encoding and Decoding JSON
Time for Action: Loading a Cone with AJAX
Architecture Updates
Summary
3: Lights
Lights, Normals, and Materials
Using Lights, Normals, and Materials in the Pipeline
Shading Methods and Light-Reflection Models
OpenGL ES Shading Language (ESSL)
Writing ESSL Programs
Time for Action: Updating Uniforms in Real Time
Time for Action: Goraud Shading
Time for Action: Phong Shading with Phong Lighting
Back to WebGL
Bridging the Gap Between WebGL and ESSL
Time for Action: Working on the Wall
More on Lights: Positional Lights
Time for Action: Positional Lights in Action
Architecture Updates
Summary
4: Cameras
WebGL Does Not Have Cameras
Vertex Transformations
Normal Transformations
WebGL Implementation
The Model-View Matrix
The Camera Matrix
Time for Action: Translations in World Space vs Camera Space
Time for Action: Rotations in World Space vs Camera Space
Basic Camera Types
Time for Action: Exploring the Showroom
The Projection matrix
Time for Action: Orthographic and Perspective Projections
Structure of the WebGL Examples
Summary
5: Animations
WebGL Matrix Naming Conventions
Matrix Stacks
Animating a 3D scene
Timing Strategies
Architectural Updates
Connecting Matrix Stacks and JavaScript Timers
Time for Action: Simple Animation
Parametric Curves
Time for Action: Bouncing Ball
Optimization Strategies
Interpolation
Time for Action: Interpolation
Summary
6: Colors, Depth Testing, and Alpha Blending
Using Colors in WebGL
Use of Color in Objects
Time for Action: Coloring the Cube
Use of Color in Lights
Architectural Updates
Time for Action: Adding a Blue Light to a Scene
Time for Action: Adding a White Light to a Scene
Time for Action: Directional Point Lights
Use of Color in the Scene
Depth Testing
Alpha Blending
Time for Action: Blending Workbench
Creating Transparent Objects
Time for Action: Culling
Time for Action: Creating a Transparent Wall
Summary
7: Textures
What Is Texture Mapping?
Using Texture Coordinates
Using Textures in a Shader
Time for Action: Texturing the Cube
Time for Action: Trying Different Filter Modes
Texture Wrapping
Time for Action: Trying Different Wrap Modes
Using Multiple Textures
Time for Action: Using Multi-Texturing
Cube Maps
Time for Action: Trying out Cube Maps
Summary
8: Picking
Picking
Setting up an Offscreen Framebuffer
Assigning One Color per Object in the Scene
Rendering to an Offscreen Framebuffer
Clicking on the Canvas
Reading Pixels from the Offscreen Framebuffer
Looking for Hits
Processing Hits
Architectural Updates
Time for Action: Picking
Implementing Unique Object Labels
Time for Action: Unique Object Labels
Summary
9: Putting It All Together
Creating a WebGL Application
Architectural Review
Time for Action: 3D Virtual Car Showroom
Designing Our GUI
Implementing the Shaders
Setting up the Scene
Loading the Cars
Bonus
Summary
10: Advanced Techniques
Post-Processing
Architectural Updates
Time for Action: Post-Process Effects
Point Sprites
Time for Action: Fountain of Sparks
Normal Mapping
Time for Action: Normal Mapping in Action
Ray Tracing in Fragment Shaders
Time for Action: Examining the Ray Traced Scene
Summary
11: WebGL 2 Highlights
What's New in WebGL 2?
Migrating to WebGL 2
Summary
12: Journey Ahead
WebGL Libraries
Testing WebGL 2 Applications
3D Reconstruction
Physically-Based Rendering
Communities
Summary