Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Trouble with Gerstner Waves Normals

$
0
0
Hello all, I have been implementing Gerstner Waves in my engine and i have encountered a problem that as kept me from moving on. The positions are being computed correctly but the computed normals (using equation 12 in this paperhttps://developer.nvidia.com/gpugems/GPUGems/gpugems_ch01.html) do not seem to be correctly interpolating in the fragment shader. Here is the code in the vertex shader: // Normal for(int i = 0; i < nGerstnerWaves; i++) { float WA = waveFrequency[i] * waveAmplitude[i]; float waveNormal = waveFrequency[i] * dot(waveDirection[i], totalPosition.xz) + (wavePhaseConstant[i] * timeStep); totalNormal.x += waveDirection[i].x * WA * cos(waveNormal); totalNormal.y += waveCrest[i] * WA * sin(waveNormal); totalNormal.z += waveDirection[i].y * WA * cos(waveNormal); } totalNormal.x = -totalNormal.x; totalNormal.y = 1 - totalNormal.y; totalNormal.z = -totalNormal.z; totalNormal = normalize(totalNormal); And the Wave parameters are these (just one wave for now) "amplitude": 1.5, "direction": [1.0, 0.0], "steepness": 0.8, "speed": 0.9, "length": 10.0} In the fragment shader this normal is again normalized. And heres two quick videos of the issue: https://youtu.be/AuZryRo6jdo https://youtu.be/U03243xIgh4 Thank you in advance, and anything else you need just ask André

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>