As a lab exercise:
waterstarter project. Run it to find some very disappointing water. We’re going to do a couple of things to make it look better: 1) add environment mapping to make it reflect the skybox and 2) perturb its normals using a 3D noise texture.
fposition_world. Compute its value in the vertex shader.
uniformfor the camera’s world position. Upload it in
OnDraw. Compute the incident vector.
uniformfor the skybox texture in the fragment shader and in
OnDraw. A skybox texture has already been made; it’s called
textureCubefunction. Assign this color to the fragment. How do things look?
uniformfor the noise texture to the fragment shader and
OnDraw. A texture object has already been made; it’s called
varyingto get these values in the fragment shader. The third we can get from a clock reading. Add a
timeuniform in the fragment shader and in
here = lookup height at texture coordinates right = lookup height at here + nudge right above = lookup height at here + nudge up
tangentRight = [1, right - here, 0] tangentAbove = [0, above - here, 1]
vec3s. Compute their cross product to produce
normal_worldinstead of the fixed y-axis.