Skip to content

Instantly share code, notes, and snippets.

@mattdesl
Created July 5, 2021 17:48
Show Gist options
  • 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