Skip to Content
Real-Time 3D Graphics with WebGL 2 - Second Edition
book

Real-Time 3D Graphics with WebGL 2 - Second Edition

by Farhad Ghayour, Diego Cantor
October 2018
Intermediate to advanced
500 pages
12h 40m
English
Packt Publishing
Content preview from Real-Time 3D Graphics with WebGL 2 - Second Edition

Mapping JavaScript Matrices to ESSL Uniforms

Since the Model-View and Perspective matrices do not change during a single rendering step, they are passed as uniforms to the shaders. For example, if we were applying a translation to an object in our scene, we would have to paint the whole object in the new coordinates given by the translation. Painting the whole object in the new position is achieved in exactly one rendering step.

However, before the rendering step is invoked (by calling drawArrays or drawElements), we need to make sure that the shaders have an updated version of our matrices. We already know how to do that for other uniforms, such as light and color properties. The method to map JavaScript matrices to uniforms is similar to ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

WebGL Programming Guide: Interactive 3D Graphics Programming with WebGL

WebGL Programming Guide: Interactive 3D Graphics Programming with WebGL

Kouichi Matsuda, Rodger Lea
3D Graphics Rendering Cookbook

3D Graphics Rendering Cookbook

Sergey Kosarevsky, Viktor Latypov

Publisher Resources

ISBN: 9781788629690Supplemental Content