diff options
author | Pushkar Joshi | 2012-02-24 12:08:49 -0800 |
---|---|---|
committer | Pushkar Joshi | 2012-02-24 12:08:49 -0800 |
commit | 03ca7a5ed13c25faaa9100bb666e062fd15335e6 (patch) | |
tree | c51112223ceb9121cd595a60335eb2795215590f /assets/shaders/TwistVert.vert.glsl | |
parent | fcb12cc09eb3cd3b42bd215877ba18f449275b75 (diff) | |
parent | 053fc63a2950c7a5ee4ebf98033b64d474a3c46e (diff) | |
download | ninja-03ca7a5ed13c25faaa9100bb666e062fd15335e6.tar.gz |
Merge branch 'pentool' into brushtool
Conflicts:
imports/codemirror/mode/scheme/scheme.js
js/tools/BrushTool.js
Diffstat (limited to 'assets/shaders/TwistVert.vert.glsl')
-rw-r--r-- | assets/shaders/TwistVert.vert.glsl | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/assets/shaders/TwistVert.vert.glsl b/assets/shaders/TwistVert.vert.glsl new file mode 100644 index 00000000..29cb30ea --- /dev/null +++ b/assets/shaders/TwistVert.vert.glsl | |||
@@ -0,0 +1,97 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | |||
8 | #ifdef GL_ES | ||
9 | precision highp float; | ||
10 | #endif | ||
11 | |||
12 | |||
13 | // attributes | ||
14 | attribute vec3 vert; | ||
15 | attribute vec3 normal; | ||
16 | attribute vec2 texcoord; | ||
17 | |||
18 | // scalar uniforms | ||
19 | uniform float u_limit1; | ||
20 | uniform float u_limit2; | ||
21 | uniform float u_twistAmount; | ||
22 | uniform float u_center; | ||
23 | |||
24 | // texture sampler uniforms | ||
25 | uniform sampler2D u_tex0; | ||
26 | uniform sampler2D u_tex1; | ||
27 | |||
28 | uniform vec4 color; | ||
29 | |||
30 | |||
31 | // matrix uniforms | ||
32 | uniform mat4 u_mvMatrix; | ||
33 | uniform mat4 u_projMatrix; | ||
34 | uniform mat4 u_worldMatrix; | ||
35 | |||
36 | //varying vec4 v_color; | ||
37 | varying float v_zNormal; | ||
38 | varying vec2 v_texcoord; | ||
39 | |||
40 | |||
41 | float GetAngle( float t ) | ||
42 | { | ||
43 | float angle= 0.0; | ||
44 | if (t < u_limit2) | ||
45 | { | ||
46 | if (t < u_limit1) | ||
47 | { | ||
48 | angle = u_twistAmount; | ||
49 | } | ||
50 | else | ||
51 | { | ||
52 | angle = (t - u_limit2)/(u_limit1 - u_limit2)*u_twistAmount; | ||
53 | } | ||
54 | } | ||
55 | |||
56 | return angle; | ||
57 | } | ||
58 | |||
59 | |||
60 | void main(void) | ||
61 | { | ||
62 | vec3 pos = vert; | ||
63 | vec2 uv = texcoord; | ||
64 | v_texcoord = texcoord; | ||
65 | |||
66 | //v_color = vec4(texcoord.x, texcoord.y, 0, 1); | ||
67 | |||
68 | v_zNormal = 1.0; | ||
69 | if (uv.x < u_limit2) | ||
70 | { | ||
71 | float angle = GetAngle( uv.x ); | ||
72 | float cs = cos(angle), sn = sin(angle); | ||
73 | |||
74 | pos.y -= u_center; | ||
75 | vec3 ctrPt = pos; | ||
76 | float y = pos.y*cs - pos.z*sn + u_center; | ||
77 | pos.z = pos.y*sn + pos.z*cs; | ||
78 | pos.y = y; | ||
79 | |||
80 | // rotate the normal | ||
81 | mat3 rotMat = mat3( vec3( 1.0, 0.0, 0.0 ), vec3( 0.0, cs, sn ), vec3( 0.0, -sn, cs ) ); | ||
82 | vec3 pt0 = ctrPt, pt1 = vec3(ctrPt.x, ctrPt.y+1.0, ctrPt.z), pt2 = vec3( ctrPt.x+1.0, ctrPt.y, ctrPt.z); | ||
83 | pt0 = rotMat * pt0; pt1 = rotMat * pt1; | ||
84 | angle = GetAngle(1.0); | ||
85 | cs = cos(angle); sn = sin(angle); | ||
86 | rotMat = mat3( vec3( 1.0, 0.0, 0.0 ), vec3( 0.0, cs, sn ), vec3( 0.0, -sn, cs ) ); | ||
87 | pt2 = rotMat * pt2; | ||
88 | pt0.y += u_center; pt1.y += u_center; pt2.y += u_center; | ||
89 | //vec4 nrm = u_projMatrix * u_mvMatrix * vec4( cross(pt1-pt0, pt2-pt0), 1.0 ); | ||
90 | vec4 nrm = vec4( cross(pt1-pt0, pt2-pt0), 1.0 ); | ||
91 | |||
92 | //v_zNormal = normal.y*sn + normal.z*cs; | ||
93 | v_zNormal = -nrm.z; | ||
94 | } | ||
95 | |||
96 | gl_Position = u_projMatrix * u_mvMatrix * vec4(pos,1.0) ; | ||
97 | } \ No newline at end of file | ||