aboutsummaryrefslogtreecommitdiff
path: root/assets/shaders
diff options
context:
space:
mode:
authorPierre Frisch2011-12-22 07:25:50 -0800
committerValerio Virgillito2012-01-27 11:18:17 -0800
commitb89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch)
tree0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /assets/shaders
parent2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff)
downloadninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'assets/shaders')
-rw-r--r--assets/shaders/Basic.vert.glsl26
-rw-r--r--assets/shaders/linearGradient.frag.glsl52
-rw-r--r--assets/shaders/linearGradient.vert.glsl48
-rw-r--r--assets/shaders/test_fshader.glsl159
-rw-r--r--assets/shaders/test_fshader_full.glsl82
-rw-r--r--assets/shaders/test_vshader.glsl82
-rw-r--r--assets/shaders/ub_fshader.glsl263
-rw-r--r--assets/shaders/ub_vshader.glsl162
8 files changed, 874 insertions, 0 deletions
diff --git a/assets/shaders/Basic.vert.glsl b/assets/shaders/Basic.vert.glsl
new file mode 100644
index 00000000..028786d1
--- /dev/null
+++ b/assets/shaders/Basic.vert.glsl
@@ -0,0 +1,26 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No 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
9precision highp float;
10#endif
11
12
13// attributes
14attribute vec3 a_pos;
15
16
17
18// matrix uniforms
19uniform mat4 u_mvMatrix;
20uniform mat4 u_projMatrix;
21uniform mat4 u_worldMatrix;
22
23void main(void)
24{
25 gl_Position = u_projMatrix * u_mvMatrix * vec4(a_pos,1.0) ;
26} \ No newline at end of file
diff --git a/assets/shaders/linearGradient.frag.glsl b/assets/shaders/linearGradient.frag.glsl
new file mode 100644
index 00000000..64cf56ff
--- /dev/null
+++ b/assets/shaders/linearGradient.frag.glsl
@@ -0,0 +1,52 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No 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
8precision highp float;
9#endif
10
11
12uniform vec4 u_color1;
13uniform vec4 u_color2;
14uniform vec4 u_color3;
15uniform vec4 u_color4;
16uniform float u_colorStop1;
17uniform float u_colorStop2;
18uniform float u_colorStop3;
19uniform float u_colorStop4;
20uniform vec2 u_cos_sin_angle;
21//uniform int u_colorCount; // currently using 4
22
23varying vec2 v_uv;
24
25
26void main(void)
27{
28 float t = dot(v_uv, u_cos_sin_angle);
29
30 vec4 color;
31 if (t < u_colorStop1)
32 color = u_color1;
33 else if (t < u_colorStop2)
34 {
35 float tLocal = (t - u_colorStop1)/(u_colorStop2 - u_colorStop1);
36 color = mix(u_color1,u_color2,tLocal);
37 }
38 else if (t < u_colorStop3)
39 {
40 float tLocal = (t - u_colorStop2)/(u_colorStop3 - u_colorStop2);
41 color = mix(u_color2,u_color3,tLocal);
42 }
43 else if (t < u_colorStop4)
44 {
45 float tLocal = (t - u_colorStop3)/(u_colorStop4 - u_colorStop3);
46 color = mix(u_color3,u_color4,tLocal);
47 }
48 else
49 color = u_color4;
50
51 gl_FragColor =color;
52} \ No newline at end of file
diff --git a/assets/shaders/linearGradient.vert.glsl b/assets/shaders/linearGradient.vert.glsl
new file mode 100644
index 00000000..aac9cbee
--- /dev/null
+++ b/assets/shaders/linearGradient.vert.glsl
@@ -0,0 +1,48 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No 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
9precision highp float;
10#endif
11
12
13// attributes
14attribute vec3 vert;
15attribute vec3 normal;
16attribute vec2 texcoord;
17
18//uniform mat4 u_shadowLightWorld;
19//uniform mat4 u_shadowBiasMatrix;
20//uniform mat4 u_vShadowLight;
21//uniform vec3 u_lightPos;
22
23// matrix uniforms
24uniform mat4 u_mvMatrix;
25uniform vec3 u_eye;
26uniform mat4 u_normalMatrix;
27uniform mat4 u_projMatrix;
28uniform mat4 u_worldMatrix;
29
30uniform vec4 u_color1;
31uniform vec4 u_color2;
32uniform vec4 u_color3;
33uniform vec4 u_color4;
34uniform float u_colorStop1;
35uniform float u_colorStop2;
36uniform float u_colorStop3;
37uniform float u_colorStop4;
38uniform vec2 u_cos_sin_angle;
39//uniform int u_colorCount; // currently using 4
40
41varying vec2 v_uv;
42
43
44void main(void)
45{
46 gl_Position = u_projMatrix * u_mvMatrix * vec4(vert,1.0) ;
47 v_uv = texcoord;
48}
diff --git a/assets/shaders/test_fshader.glsl b/assets/shaders/test_fshader.glsl
new file mode 100644
index 00000000..3a0af39f
--- /dev/null
+++ b/assets/shaders/test_fshader.glsl
@@ -0,0 +1,159 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No 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
9precision highp float;
10#endif
11
12// lighting uniforms
13uniform vec3 u_light0Pos;
14uniform vec4 u_light0Diff;
15uniform vec4 u_light0Amb;
16
17// diffuse map
18uniform sampler2D colMap;
19
20// environment map
21uniform sampler2D envMap;
22
23// normal map
24uniform sampler2D normalMap;
25
26// glow map
27uniform sampler2D glowMap;
28
29// glow map
30uniform sampler2D depthMap;
31
32//material uniforms
33uniform vec4 u_matAmbient;
34uniform vec4 u_matDiffuse;
35uniform vec4 u_matSpecular;
36uniform float u_matShininess;
37uniform vec4 u_matEmission;
38uniform float u_renderGlow;
39
40// varyings
41varying vec4 vNormal; // w = texcoord.x
42varying vec4 vECPos; // w = texcoord.y
43varying vec3 vEyePos;
44varying vec4 vShadowCoord;
45varying vec2 vEnvTexCoord;
46varying float vDiffuseIntensity;
47
48#ifdef PC
49
50void main()
51{
52 vec4 rgba_depth = texture2D(depthMap, vShadowCoord.xy/vShadowCoord.w, -32.0);
53 const vec4 bit_shift = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);
54 float dist = vShadowCoord.w/200.0;
55 float d = dot(rgba_depth, bit_shift);
56 float shadowCoef = (dist > d + 0.00779) ? (0.6) : (1.0);
57
58 vec4 colMapTexel = vec4(0);
59 if (u_renderGlow <= 0.5) {
60 colMapTexel = vec4(texture2D(colMap, vec2(vNormal.w, vECPos.w)).rgb, 1.0);
61 } else {
62 colMapTexel = vec4(texture2D(glowMap, vec2(vNormal.w, vECPos.w)).rgb, 1.0);
63 }
64
65 // normal mapping
66 vec3 normal = normalize(vNormal.xyz);
67 vec3 mapNormal = texture2D(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);
69
70 // create envmap coordinates
71 vec3 r = reflect( normalize(vec3(vECPos.xyz - vEyePos.xyz)), mapNormal);
72 float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + r.z*r.z );
73
74 // calculate environment map texel
75 vec4 envMapTexel = vec4(texture2D(envMap, vec2(r.x/m + 0.5, r.y/m + 0.5)).rgb, 0.0);
76
77 // lighting
78 vec3 lightDirection = u_light0Pos - vECPos.xyz;
79 float lightDist = length(lightDirection);
80 lightDirection /= lightDist;
81
82 float attenuation = clamp(1.0 - lightDist * 0.01, 0.0, 1.0);
83
84 vec3 halfVec = normalize(lightDirection + vEyePos);
85
86 float diffuseIntensity = max(0.0, dot(mapNormal, lightDirection));
87 float specularModifier = max(0.0, dot(mapNormal, halfVec));
88
89 float pf;
90 if(diffuseIntensity == 0.0)