diff options
author | Eric Guzman | 2012-02-13 10:29:49 -0800 |
---|---|---|
committer | Eric Guzman | 2012-02-13 10:29:49 -0800 |
commit | e4893f7d3c3b9bd7967973197c3ffb5d3a075c91 (patch) | |
tree | f3d4fd9d96ba0dcf846fbf66153fb443bd60f767 /assets/shaders | |
parent | ef032412216d437ce1c7dfc9050ab41adf0594c0 (diff) | |
parent | e142611e22718b1f1d1696902ad9161ec5f33f98 (diff) | |
download | ninja-e4893f7d3c3b9bd7967973197c3ffb5d3a075c91.tar.gz |
Merge branch 'refs/heads/master' into TreeComponents
Diffstat (limited to 'assets/shaders')
-rw-r--r-- | assets/shaders/Basic.frag.glsl | 17 | ||||
-rw-r--r-- | assets/shaders/Basic.vert.glsl | 2 | ||||
-rw-r--r-- | assets/shaders/radialGradient.frag.glsl | 51 | ||||
-rw-r--r-- | assets/shaders/radialGradient.vert.glsl | 28 | ||||
-rw-r--r-- | assets/shaders/test_fshader.glsl | 25 |
5 files changed, 109 insertions, 14 deletions
diff --git a/assets/shaders/Basic.frag.glsl b/assets/shaders/Basic.frag.glsl new file mode 100644 index 00000000..a2c21afa --- /dev/null +++ b/assets/shaders/Basic.frag.glsl | |||
@@ -0,0 +1,17 @@ | |||
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 | uniform vec4 color; | ||
14 | |||
15 | void main() { | ||
16 | gl_FragColor = color; | ||
17 | } | ||
diff --git a/assets/shaders/Basic.vert.glsl b/assets/shaders/Basic.vert.glsl index 028786d1..0d5b8d63 100644 --- a/assets/shaders/Basic.vert.glsl +++ b/assets/shaders/Basic.vert.glsl | |||
@@ -12,7 +12,7 @@ precision highp float; | |||
12 | 12 | ||
13 | // attributes | 13 | // attributes |
14 | attribute vec3 a_pos; | 14 | attribute vec3 a_pos; |
15 | 15 | attribute vec2 texcoord; | |
16 | 16 | ||
17 | 17 | ||
18 | // matrix uniforms | 18 | // matrix uniforms |
diff --git a/assets/shaders/radialGradient.frag.glsl b/assets/shaders/radialGradient.frag.glsl new file mode 100644 index 00000000..cd751750 --- /dev/null +++ b/assets/shaders/radialGradient.frag.glsl | |||
@@ -0,0 +1,51 @@ | |||
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 | #ifdef GL_ES | ||
8 | precision highp float; | ||
9 | #endif | ||
10 | |||
11 | uniform vec4 u_color1; | ||
12 | uniform vec4 u_color2; | ||
13 | uniform vec4 u_color3; | ||
14 | uniform vec4 u_color4; | ||
15 | uniform float u_colorStop1; | ||
16 | uniform float u_colorStop2; | ||
17 | uniform float u_colorStop3; | ||
18 | uniform float u_colorStop4; | ||
19 | uniform vec2 u_cos_sin_angle; | ||
20 | //uniform int u_colorCount; // currently using all 4 | ||
21 | |||
22 | varying vec2 v_uv; | ||
23 | |||
24 | void main(void) | ||
25 | { | ||
26 | vec2 pt = vec2( v_uv.x - 0.5, v_uv.y - 0.5); | ||
27 | float t = sqrt( dot(pt, pt) ); | ||
28 | |||
29 | vec4 color; | ||
30 | if (t < u_colorStop1) | ||
31 | color = u_color1; | ||
32 | else if (t < u_colorStop2) | ||
33 | { | ||
34 | float tLocal = (t - u_colorStop1)/(u_colorStop2 - u_colorStop1); | ||
35 | color = mix(u_color1,u_color2,tLocal); | ||
36 | } | ||
37 | else if (t < u_colorStop3) | ||
38 | { | ||
39 | float tLocal = (t - u_colorStop2)/(u_colorStop3 - u_colorStop2); | ||
40 | color = mix(u_color2,u_color3,tLocal); | ||
41 | } | ||
42 | else if (t < u_colorStop4) | ||
43 | { | ||
44 | float tLocal = (t - u_colorStop3)/(u_colorStop4 - u_colorStop3); | ||
45 | color = mix(u_color3,u_color4,tLocal); | ||
46 | } | ||
47 | else | ||
48 | color = u_color4; | ||
49 | |||
50 | gl_FragColor = color; | ||
51 | } | ||
diff --git a/assets/shaders/radialGradient.vert.glsl b/assets/shaders/radialGradient.vert.glsl new file mode 100644 index 00000000..c3e1b50a --- /dev/null +++ b/assets/shaders/radialGradient.vert.glsl | |||
@@ -0,0 +1,28 @@ | |||
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 | // matrix uniforms | ||
19 | uniform mat4 u_mvMatrix; | ||
20 | uniform mat4 u_projMatrix; | ||
21 | |||
22 | varying vec2 v_uv; | ||
23 | |||
24 | void main(void) | ||
25 | { | ||
26 | gl_Position = u_projMatrix * u_mvMatrix * vec4(vert,1.0) ; | ||
27 | v_uv = texcoord; | ||
28 | } \ No newline at end of file | ||
diff --git a/assets/shaders/test_fshader.glsl b/assets/shaders/test_fshader.glsl index 3a0af39f..629d1878 100644 --- a/assets/shaders/test_fshader.glsl +++ b/assets/shaders/test_fshader.glsl | |||
@@ -4,7 +4,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | |||
8 | #ifdef GL_ES | 7 | #ifdef GL_ES |
9 | precision highp float; | 8 | precision highp float; |
10 | #endif | 9 | #endif |
@@ -15,18 +14,18 @@ uniform vec4 u_light0Diff; | |||
15 | uniform vec4 u_light0Amb; | 14 | uniform vec4 u_light0Amb; |
16 | 15 | ||
17 | // diffuse map | 16 | // diffuse map |
18 | uniform sampler2D colMap; | 17 | uniform sampler2D u_colMap; |
19 | 18 | ||
20 | // environment map | 19 | // environment map |
21 | uniform sampler2D envMap; | 20 | uniform sampler2D envMap; |
22 | 21 | ||
23 | // normal map | 22 | // normal map |
24 | uniform sampler2D normalMap; | 23 | uniform sampler2D u_normalMap; |
25 | 24 | ||
26 | // glow map | 25 | // specular map |
27 | uniform sampler2D glowMap; | 26 | uniform sampler2D u_glowMap; |
28 | 27 | ||
29 | // glow map | 28 | // depth map |
30 | uniform sampler2D depthMap; | 29 | uniform sampler2D depthMap; |
31 | 30 | ||
32 | //material uniforms | 31 | //material uniforms |
@@ -45,7 +44,7 @@ varying vec4 vShadowCoord; | |||
45 | varying vec2 vEnvTexCoord; | 44 | varying vec2 vEnvTexCoord; |
46 | varying float vDiffuseIntensity; | 45 | varying float vDiffuseIntensity; |
47 | 46 | ||
48 | #ifdef PC | 47 | #if defined( PC ) |
49 | 48 | ||
50 | void main() | 49 | void main() |
51 | { | 50 | { |
@@ -57,14 +56,14 @@ void main() | |||
57 | 56 | ||
58 | vec4 colMapTexel = vec4(0); | 57 | vec4 colMapTexel = vec4(0); |
59 | if (u_renderGlow <= 0.5) { | 58 | if (u_renderGlow <= 0.5) { |
60 | colMapTexel = vec4(texture2D(colMap, vec2(vNormal.w, vECPos.w)).rgb, 1.0); | 59 | colMapTexel = vec4(texture2D(u_colMap, vec2(vNormal.w, vECPos.w)).rgb, 1.0); |
61 | } else { | 60 | } else { |
62 | colMapTexel = vec4(texture2D(glowMap, vec2(vNormal.w, vECPos.w)).rgb, 1.0); | 61 | colMapTexel = vec4(texture2D(u_glowMap, vec2(vNormal.w, vECPos.w)).rgb, 1.0); |
63 | } | 62 | } |
64 | 63 | ||
65 | // normal mapping | 64 | // normal mapping |
66 | vec3 normal = normalize(vNormal.xyz); | 65 | vec3 normal = normalize(vNormal.xyz); |
67 | vec3 mapNormal = texture2D(normalMap, vec2(vNormal.w, vECPos.w)).xyz * 2.0 - 1.0; | 66 | vec3 mapNormal = texture2D(u_normalMap, vec2(vNormal.w, vECPos.w)).xyz * 2.0 - 1.0; |
68 | mapNormal = normalize(mapNormal.x*vec3(normal.z, 0.0, -normal.x) + vec3(0.0, mapNormal.y, 0.0) + mapNormal.z*normal); | 67 | mapNormal = normalize(mapNormal.x*vec3(normal.z, 0.0, -normal.x) + vec3(0.0, mapNormal.y, 0.0) + mapNormal.z*normal); |
69 | 68 | ||
70 | // create envmap coordinates | 69 | // create envmap coordinates |
@@ -108,15 +107,15 @@ void main() | |||
108 | 107 | ||
109 | #endif | 108 | #endif |
110 | 109 | ||
111 | #ifdef DEVICE | 110 | #if defined( DEVICE ) |
112 | 111 | ||
113 | void main() | 112 | void main() |
114 | { | 113 | { |
115 | vec4 colMapTexel = vec4(texture2D(colMap, vec2(vNormal.w, vECPos.w)).rgb, 1.0); | 114 | vec4 colMapTexel = vec4(texture2D(u_colMap, vec2(vNormal.w, vECPos.w)).rgb, 1.0); |
116 | 115 | ||
117 | // // normal mapping | 116 | // // normal mapping |
118 | vec3 normal = normalize(vNormal.xyz); | 117 | vec3 normal = normalize(vNormal.xyz); |
119 | // vec3 mapNormal = texture2D(normalMap, vec2(vNormal.w, vECPos.w)).xyz * 2.0 - 1.0; | 118 | // vec3 mapNormal = texture2D(u_normalMap, vec2(vNormal.w, vECPos.w)).xyz * 2.0 - 1.0; |
120 | // mapNormal = normalize(mapNormal.x*vec3(normal.z, 0.0, -normal.x) + vec3(0.0, mapNormal.y, 0.0) + mapNormal.z*normal); | 119 | // mapNormal = normalize(mapNormal.x*vec3(normal.z, 0.0, -normal.x) + vec3(0.0, mapNormal.y, 0.0) + mapNormal.z*normal); |
121 | // | 120 | // |
122 | // // create envmap coordinates | 121 | // // create envmap coordinates |