Skip to content

Instantly share code, notes, and snippets.

@mattdesl
Created July 5, 2021 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattdesl/119ef6c1849aa5461685da66258ad727 to your computer and use it in GitHub Desktop.
Save mattdesl/119ef6c1849aa5461685da66258ad727 to your computer and use it in GitHub Desktop.
const light = /* a unit normal for light direction */;
// Determine the 3D position and normal from surface point
const [ u, v ] = penStart;
const [ position, normal ] = geometricNormal(parametricTerrain, u, v);
// Get lambertian diffuse
const diffuse = Math.max(0, vec3.dot(normal, light));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment