diff options
Diffstat (limited to 'assets/shaders/TwistVert.vert.glsl')
-rw-r--r-- | assets/shaders/TwistVert.vert.glsl | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/assets/shaders/TwistVert.vert.glsl b/assets/shaders/TwistVert.vert.glsl index 94d22020..6db4210f 100644 --- a/assets/shaders/TwistVert.vert.glsl +++ b/assets/shaders/TwistVert.vert.glsl | |||
@@ -64,51 +64,51 @@ varying vec2 v_texcoord; | |||
64 | 64 | ||
65 | float GetAngle( float t ) | 65 | float GetAngle( float t ) |
66 | { | 66 | { |
67 | float angle= 0.0; | 67 | float angle= 0.0; |
68 | if (t < u_limit2) | 68 | if (t < u_limit2) |
69 | { | 69 | { |
70 | if (t < u_limit1) | 70 | if (t < u_limit1) |
71 | { | 71 | { |
72 | angle = u_twistAmount; | 72 | angle = u_twistAmount; |
73 | } | 73 | } |
74 | else | 74 | else |
75 | { | 75 | { |
76 | angle = (t - u_limit2)/(u_limit1 - u_limit2)*u_twistAmount; | 76 | angle = (t - u_limit2)/(u_limit1 - u_limit2)*u_twistAmount; |
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | return angle; | 80 | return angle; |
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | void main(void) | 84 | void main(void) |
85 | { | 85 | { |
86 | vec3 pos = vert; | 86 | vec3 pos = vert; |
87 | vec2 uv = texcoord; | 87 | vec2 uv = texcoord; |
88 | v_texcoord = texcoord; | 88 | v_texcoord = texcoord; |
89 | 89 | ||
90 | v_zNormal = 1.0; | 90 | v_zNormal = 1.0; |
91 | if (uv.x < u_limit2) | 91 | if (uv.x < u_limit2) |
92 | { | 92 | { |
93 | float angle = GetAngle( uv.x ); | 93 | float angle = GetAngle( uv.x ); |
94 | float cs = cos(angle), sn = sin(angle); | 94 | float cs = cos(angle), sn = sin(angle); |
95 | 95 | ||
96 | vec3 ctrPt = pos; | 96 | vec3 ctrPt = pos; |
97 | float y = pos.y*cs - pos.z*sn; // + u_center; | 97 | float y = pos.y*cs - pos.z*sn; // + u_center; |
98 | pos.z = pos.y*sn + pos.z*cs; | 98 | pos.z = pos.y*sn + pos.z*cs; |
99 | pos.y = y; | 99 | pos.y = y; |
100 | 100 | ||
101 | // rotate the normal | 101 | // rotate the normal |
102 | mat3 rotMat = mat3( vec3( 1.0, 0.0, 0.0 ), vec3( 0.0, cs, sn ), vec3( 0.0, -sn, cs ) ); | 102 | mat3 rotMat = mat3( vec3( 1.0, 0.0, 0.0 ), vec3( 0.0, cs, sn ), vec3( 0.0, -sn, cs ) ); |
103 | vec3 pt0 = ctrPt, pt1 = vec3(ctrPt.x, ctrPt.y+1.0, ctrPt.z), pt2 = vec3( ctrPt.x+1.0, ctrPt.y, ctrPt.z); | 103 | vec3 pt0 = ctrPt, pt1 = vec3(ctrPt.x, ctrPt.y+1.0, ctrPt.z), pt2 = vec3( ctrPt.x+1.0, ctrPt.y, ctrPt.z); |
104 | pt0 = rotMat * pt0; pt1 = rotMat * pt1; | 104 | pt0 = rotMat * pt0; pt1 = rotMat * pt1; |
105 | angle = GetAngle(1.0); | 105 | angle = GetAngle(1.0); |
106 | cs = cos(angle); sn = sin(angle); | 106 | cs = cos(angle); sn = sin(angle); |
107 | rotMat = mat3( vec3( 1.0, 0.0, 0.0 ), vec3( 0.0, cs, sn ), vec3( 0.0, -sn, cs ) ); | 107 | rotMat = mat3( vec3( 1.0, 0.0, 0.0 ), vec3( 0.0, cs, sn ), vec3( 0.0, -sn, cs ) ); |
108 | pt2 = rotMat * pt2; | 108 | pt2 = rotMat * pt2; |
109 | vec4 nrm = vec4( cross(pt1-pt0, pt2-pt0), 1.0 ); | 109 | vec4 nrm = vec4( cross(pt1-pt0, pt2-pt0), 1.0 ); |
110 | v_zNormal = -nrm.z; | 110 | v_zNormal = -nrm.z; |
111 | } | 111 | } |
112 | 112 | ||
113 | gl_Position = u_projMatrix * u_mvMatrix * vec4(pos,1.0) ; | 113 | gl_Position = u_projMatrix * u_mvMatrix * vec4(pos,1.0) ; |
114 | } | 114 | } |