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

Phong Shading

Unlike the Goraud interpolation, where we calculated the final color for each vertex, the Phong interpolation calculates the final color for every fragment. This means that the calculation of the ambient, diffuse, and specular terms in the Phong model are performed in the fragment shader instead of the vertex shader. As you can imagine, this is computationally more intensive than performing a simple interpolation like in the two previous scenarios where we were using Goraud interpolation. However, we obtain a scene that seems more realistic.

After this translation, you may be wondering what is left for the vertex shader to do. Well, in this case, we will create varyings that will allow us to do all of the calculations in the ...

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