Real-Time 3D Graphics with WebGL 2
eBook - ePub

Real-Time 3D Graphics with WebGL 2

Build interactive 3D applications with JavaScript and WebGL 2 (OpenGL ES 3.0), 2nd Edition

Farhad Ghayour, Diego Cantor

Partager le livre
  1. 500 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Real-Time 3D Graphics with WebGL 2

Build interactive 3D applications with JavaScript and WebGL 2 (OpenGL ES 3.0), 2nd Edition

Farhad Ghayour, Diego Cantor

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

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.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Real-Time 3D Graphics with WebGL 2 est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Real-Time 3D Graphics with WebGL 2 par Farhad Ghayour, Diego Cantor en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Computer Science et Programming in JavaScript. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2018
ISBN
9781788837873

Rendering

In the previous chapter, we covered the history of WebGL, along with its evolution. We discussed the fundamental elements in a 3D application and how to set up a WebGL context. In this chapter, we will investigate how geometric entities are defined in WebGL.
WebGL renders objects following a "divide and conquer" approach. Complex polygons are decomposed into triangles, lines, and point primitives. Then, each geometric primitive is processed in parallel by the GPU in order to create the final scene.
In this chapter, you will:
  • Understand how WebGL defines and processes geometric information
  • Discuss the relevant API methods that relate to geometry manipulation
  • Examine why and how to use JavaScript Object Notation (JSON) to define, store, and load complex geometries
  • Continue our analysis of WebGL as a state machine to describe the attributes that are relevant to geometry manipulation that can be set and retrieved
  • Experiment with creating and loading different geometry models

WebGL Rendering Pipeline

Although WebGL is often thought of as a comprehensive 3D API, it is, in reality, just a rasterization engine. It draws points, lines, and triangles based on the code you supply. Getting WebGL to do anything else requires you to provide code to use points, lines, and triangles to accomplish your task.
WebGL runs on the GPU on your computer. As such, you need to provide code that runs on that GPU. The code should be provided in the form of pairs of functions. Those two functions are known as the vertex shader and fragment shader, and they are each written in a very strictly-typed C/C++-like language called GLSL (GL Shader Language). Together, they are called a program.
GLSL

GLSL is an acronym for the official OpenGL Shading Language. GLSL is a C/C++-like, high-level programming language for several parts of the graphic card. With GLSL, you can code short programs, called shaders, which are executed on the GPU. For more information, please check out https://en.wikipedia.org/wiki/OpenGL_Shading_Language.
A vertex shader's job is to compute vertex attributes. Based on various positions, the function outputs values that can be used to rasterize various kinds of primitives, including points, lines, and triangles. When rasterizing these primitives, it calls a second user-supplied function known as a fragment shader. A fragment shader's job is to compute a color for each pixel of the primitive currently being drawn.
Nearly all of the WebGL API is about setting up state for these pairs of functions to execute. For each thing you want to draw, you need to set up state to run these functions by invoking gl.drawArrays or gl.drawElements, which executes your shaders on the GPU.
Before going any further, let's examine what WebGL's rendering pipeline looks like. In subsequent chapters, we will discuss the pipeline in more detail. The following is a diagram of a simplified version of WebGL's rendering pipeline:
Let's take a moment to describe each element.

Vertex Buffer Objects (VBOs)

VBOs contain the data that is used to describe the geometry to be rendered. Vertex coordinates, which are points that define the vertices of 3D objects, are usually stored and processed in WebGL as VBOs. Additionally, there are several data elements, such as vertex normals, colors, and texture coordinates, that can be modeled as ...

Table des matiĂšres