Book description
A comprehensive guide with 80+ examples on 3D programming in WebGL 2, covering computer graphics topics such as rendering, 3D math, camera, and more
Key Features
- Create visually stunning, high-performance 3D applications for the web with WebGL 2
- A complete course on 3D computer graphics: rendering, 3D math, lighting, cameras, and more
- Unlock a variety of new and advanced features offered in WebGL 2
Book Description
As highly interactive applications have become an increasingly important part of the user experience, WebGL is a unique and cutting-edge technology that brings hardware-accelerated 3D graphics to the web.
Packed with 80+ examples, this book guides readers through the landscape of real-time computer graphics using WebGL 2. Each chapter covers foundational concepts in 3D graphics programming with various implementations. Topics are always associated with exercises for a hands-on approach to learning.
This book presents a clear roadmap to learning real-time 3D computer graphics with WebGL 2. Each chapter starts with a summary of the learning goals for the chapter, followed by a detailed description of each topic. The book offers example-rich, up-to-date introductions to a wide range of essential 3D computer graphics topics, including rendering, colors, textures, transformations, framebuffers, lights, surfaces, blending, geometry construction, advanced techniques, and more. With each chapter, you will "level up" your 3D graphics programming skills. This book will become your trustworthy companion in developing highly interactive 3D web applications with WebGL and JavaScript.
What you will learn
- Understand the rendering pipeline provided in WebGL
- Build and render 3D objects with WebGL
- Develop lights using shaders, 3D math, and the physics of light reflection
- Create a camera and use it to navigate a 3D scene
- Use texturing, lighting, and shading techniques to render realistic 3D scenes
- Implement object selection and interaction in a 3D scene
- Cover advanced techniques for creating immersive and compelling scenes
- Learn new and advanced features offered in WebGL 2
Who this book is for
This book is intended for developers who are interested in building highly interactive 3D applications for the web. A basic understanding of JavaScript is necessary; no prior computer graphics or WebGL knowledge is required.
Table of contents
- Title Page
- Copyright and Credits
- Dedication
- Packt Upsell
- Foreword
- Contributors
- Preface
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
- Putting It All Together
- Advanced Techniques
-
WebGL 2 Highlights
-
What's New in WebGL 2?
- Vertex Array Objects
- Wider Range of Texture Formats
- 3D Textures
- Texture Arrays
- Instanced Rendering
- Non-Power of 2 Texture Support
- Fragment Depth
- Texture Size in Shaders
- Sync Objects
- Direct Texel Lookup
- Flexible Shader Loops
- Shader Matrix Functions
- Common Compressed Textures
- Uniform Buffer Objects
- Integer Textures and Attributes
- Transform Feedback
- Sampler Objects
- Depth Textures
- Standard Derivatives
- UNSIGNED_INT Indices
- Blend Equation MIN / MAX
- Multiple Render Targets (MRT)
- Texture Access in Vertex Shaders
- Multi-Sampled Renderbuffers
- Query Objects
- Texture LOD
- Shader Texture LOD
- Floating Point Textures Always Available
- Migrating to WebGL 2
- Summary
-
What's New in WebGL 2?
- Journey Ahead
- Other Books You May Enjoy
Product information
- Title: Real-Time 3D Graphics with WebGL 2 - Second Edition
- Author(s):
- Release date: October 2018
- Publisher(s): Packt Publishing
- ISBN: 9781788629690
You might also like
book
Game Programming in C++: Creating 3D Games, First Edition
You can program games in many languages, but C++ remains the key language used by many …
book
3D Graphics Rendering Cookbook
Build a 3D rendering engine from scratch while solving problems in a step-by-step way with the …
book
Learn Three.js - Third Edition
Create and animate stunning 3D browser based graphics with Three.js JavaScript library Key Features Enhance your …
book
Learn Three.js - Fourth Edition
Become a creative JavaScript professional by creating and animating stunning 3D, browser-based graphics with Three.js from …