Public
Edited
Oct 31, 2023
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
specular = (x, V) => {
const L = (lightParameters.lightType=="point")? glMatrix.vec2.normalize([],glMatrix.vec2.sub([],lightPosition,[x,0])):lightVector;
const R = reflectAlongYAxis(L);
//const V = glMatrix.vec2.normalize([],glMatrix.vec2.sub([],eyePosition,[x,0]));
const N = [0, 1];
const H = glMatrix.vec2.normalize([],glMatrix.vec2.add([],L,V));
//return [L, R, V, N, H, dot(R,V), dot(N, H),specularParameters.exponent]
const factor = ((specularParameters.modelType == "Phong")? dot(R,V): dot(N, H))**specularParameters.exponent
return factor < 0 ? 0 : factor;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dot = (A,B) => A[0]*B[0] + A[1]*B[1]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more