OLD | NEW |
| (Empty) |
1 // shared vertex shader should succeed. | |
2 uniform mat4 viewProjection; | |
3 uniform vec3 worldPosition; | |
4 uniform vec3 nextPosition; | |
5 uniform float fishLength; | |
6 uniform float fishWaveLength; | |
7 uniform float fishBendAmount; | |
8 attribute vec4 position; | |
9 attribute vec2 texCoord; | |
10 varying vec4 v_position; | |
11 varying vec2 v_texCoord; | |
12 varying vec3 v_surfaceToLight; | |
13 void main() { | |
14 vec3 vz = normalize(worldPosition - nextPosition); | |
15 vec3 vx = normalize(cross(vec3(0,1,0), vz)); | |
16 vec3 vy = cross(vz, vx); | |
17 mat4 orientMat = mat4( | |
18 vec4(vx, 0), | |
19 vec4(vy, 0), | |
20 vec4(vz, 0), | |
21 vec4(worldPosition, 1)); | |
22 mat4 world = orientMat; | |
23 mat4 worldViewProjection = viewProjection * world; | |
24 mat4 worldInverseTranspose = world; | |
25 | |
26 v_texCoord = texCoord; | |
27 // NOTE:If you change this you need to change the laser code to match! | |
28 float mult = position.z > 0.0 ? | |
29 (position.z / fishLength) : | |
30 (-position.z / fishLength * 2.0); | |
31 float s = sin(mult * fishWaveLength); | |
32 float a = sign(s); | |
33 float offset = pow(mult, 2.0) * s * fishBendAmount; | |
34 v_position = ( | |
35 worldViewProjection * | |
36 (position + | |
37 vec4(offset, 0, 0, 0))); | |
38 v_surfaceToLight = (world * position).xyz; | |
39 gl_Position = v_position; | |
40 } | |
41 | |
OLD | NEW |