Skip to content

Instantly share code, notes, and snippets.

@mattdesl
Last active July 5, 2021 17:09
Show Gist options
  • Save mattdesl/afaf417ebc6f36d2e12161ca3f1c4449 to your computer and use it in GitHub Desktop.
Save mattdesl/afaf417ebc6f36d2e12161ca3f1c4449 to your computer and use it in GitHub Desktop.
function parametricTerrain ([ u, v ]) {
// Turn 0..1 to -1..1
const x = u * 2 - 1;
const z = v * 2 - 1;
// Find height at this 2D coordinate
const y = calculateTerrainHeight(x, z);
// Return the 3D surface point
return [ x, y, z ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment