Skip to content

Instantly share code, notes, and snippets.

@yorung
Created October 9, 2017 10:28
Show Gist options
  • Save yorung/64d8161e6999126f6ac3a15dce90fab4 to your computer and use it in GitHub Desktop.
Save yorung/64d8161e6999126f6ac3a15dce90fab4 to your computer and use it in GitHub Desktop.
Convert tangent space normal to world space normal
float3 gerstnerWaveN = CalcGerstnerWaveNormal(vertexPosition + ofsByGerstnerWave);
float3 gerstnerWaveB = CalcGerstnerWaveBinormal(vertexPosition + ofsByGerstnerWave);
float3 gerstnerWaveT = CalcGerstnerWaveTangent(vertexPosition + ofsByGerstnerWave);
float3x3 rotator;
rotator[0] = gerstnerWaveB;
rotator[1] = gerstnerWaveN;
rotator[2] = gerstnerWaveT;
output.normal = mul(water_normal.xyz, rotator);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment