Skip to content

Instantly share code, notes, and snippets.

@yorung
Created October 9, 2017 09:39
Show Gist options
  • Save yorung/ea0a57b4bd2bdcf6ab73706c0bce499b to your computer and use it in GitHub Desktop.
Save yorung/ea0a57b4bd2bdcf6ab73706c0bce499b to your computer and use it in GitHub Desktop.
Calculate gerstner wave normals
float3 ofsByGerstnerWave = CalcGerstnerWaveOffset(vertexPosition);
float3 dx = float3(0.01, 0, 0) + CalcGerstnerWaveOffset(vertexPosition + float3(0.01, 0, 0));
float3 dz = float3(0, 0, 0.01) + CalcGerstnerWaveOffset(vertexPosition + float3(0, 0, 0.01));
float3 N = normalize(cross(dz - ofsByGerstnerWave, dx - ofsByGerstnerWave));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment