Skip to Main Content
WebGL Insights
book

WebGL Insights

by Patrick Cozzi
August 2015
Intermediate to advanced content levelIntermediate to advanced
416 pages
16h 58m
English
A K Peters/CRC Press
Content preview from WebGL Insights
214 13. glslify
vec3 color;
float kAmbient, kDiffuse, kSpecular;
float phongExponent;
};
#pragma glslify: export(Material)
Next, we will create a subroutine that takes these two data types as well as some infor-
mation about the surface/viewing geometry as input and computes the intensity of the
light in each channel:
#pragma glslify: Material = require(./material.glsl)
#pragma glslify: PointLight = require(./light.glsl)
vec3 blinnPhong(
Material material,
PointLight light,
vec3 surfaceNormal,
vec3 surfacePosition,
vec3 viewDirection) {
vec3 L = normalize(light.position - surfacePosition);
vec3 H = normalize(viewDirection + surfaceNormal);
vec3
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

Learning HTML5 Game Programming: Build Online Games with Canvas, SVG, and WebGL

Learning HTML5 Game Programming: Build Online Games with Canvas, SVG, and WebGL

James L. Williams

Publisher Resources

ISBN: 9781498716079