aboutsummaryrefslogtreecommitdiff
path: root/assets/shaders/test_vshader.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'assets/shaders/test_vshader.glsl')
-rwxr-xr-xassets/shaders/test_vshader.glsl60
1 files changed, 30 insertions, 30 deletions
diff --git a/assets/shaders/test_vshader.glsl b/assets/shaders/test_vshader.glsl
index 8bf9ee74..69015b78 100755
--- a/assets/shaders/test_vshader.glsl
+++ b/assets/shaders/test_vshader.glsl
@@ -46,8 +46,8 @@ uniform mat4 u_vShadowLight;
46uniform vec3 u_lightPos; 46uniform vec3 u_lightPos;
47 47
48// varyings 48// varyings
49varying vec4 vNormal; // w = texcoord.x 49varying vec4 vNormal; // w = texcoord.x
50varying vec4 vECPos; // w = texcoord.y 50varying vec4 vECPos; // w = texcoord.y
51varying vec3 vEyePos; 51varying vec3 vEyePos;
52varying vec4 vShadowCoord; 52varying vec4 vShadowCoord;
53varying vec2 vEnvTexCoord; 53varying vec2 vEnvTexCoord;
@@ -56,18 +56,18 @@ varying float vDiffuseIntensity;
56#ifdef PC 56#ifdef PC
57void main() 57void main()
58{ 58{
59 vNormal.w = texcoord.x; 59 vNormal.w = texcoord.x;
60 vECPos.w = texcoord.y; 60 vECPos.w = texcoord.y;
61 vEyePos = u_eye; 61 vEyePos = u_eye;
62 62
63// position normals and vert 63// position normals and vert
64 vECPos.xyz = (u_mvMatrix*vec4(vert, 1.0)).xyz; 64 vECPos.xyz = (u_mvMatrix*vec4(vert, 1.0)).xyz;
65 vNormal.xyz = (u_normalMatrix*vec4(normal, 0.0)).xyz; 65 vNormal.xyz = (u_normalMatrix*vec4(normal, 0.0)).xyz;
66 66
67// pass along the geo 67// pass along the geo
68 gl_Position = u_projMatrix * vec4(vECPos.xyz, 1.0); 68 gl_Position = u_projMatrix * vec4(vECPos.xyz, 1.0);
69 69
70 mat4 shadowMat = u_shadowBiasMatrix*u_projMatrix*u_vShadowLight*u_worldMatrix; 70 mat4 shadowMat = u_shadowBiasMatrix*u_projMatrix*u_vShadowLight*u_worldMatrix;
71 vShadowCoord = shadowMat * vec4(vert, 1.0); 71 vShadowCoord = shadowMat * vec4(vert, 1.0);
72} 72}
73#endif 73#endif
@@ -76,31 +76,31 @@ void main()
76 76
77void main() 77void main()
78{ 78{
79 vNormal.w = texcoord.x; 79 vNormal.w = texcoord.x;
80 vECPos.w = texcoord.y; 80 vECPos.w = texcoord.y;
81 vEyePos = u_eye; 81 vEyePos = u_eye;
82 82
83// position normals and vert 83// position normals and vert
84 vECPos.xyz = (u_mvMatrix*vec4(vert, 1.0)).xyz; 84 vECPos.xyz = (u_mvMatrix*vec4(vert, 1.0)).xyz;
85 vNormal.xyz = (u_normalMatrix*vec4(normal, 0.0)).xyz; 85 vNormal.xyz = (u_normalMatrix*vec4(normal, 0.0)).xyz;
86 86
87// pass along the geo 87// pass along the geo
88 gl_Position = u_projMatrix * vec4(vECPos.xyz, 1.0); 88 gl_Position = u_projMatrix * vec4(vECPos.xyz, 1.0);
89 89
90 //mat4 shadowMat = u_shadowBiasMatrix*u_projMatrix*u_vShadowLight*u_worldMatrix; 90 //mat4 shadowMat = u_shadowBiasMatrix*u_projMatrix*u_vShadowLight*u_worldMatrix;
91 //vShadowCoord = shadowMat * vec4(vert, 1.0); 91 //vShadowCoord = shadowMat * vec4(vert, 1.0);
92 92
93 // normal mapping 93 // normal mapping
94 vec3 normal = normalize(vNormal.xyz); 94 vec3 normal = normalize(vNormal.xyz);
95 95
96 // create envmap coordinates 96 // create envmap coordinates
97 vec3 r = reflect( vec3(vECPos.xyz - u_eye.xyz), normal); 97 vec3 r = reflect( vec3(vECPos.xyz - u_eye.xyz), normal);
98 float m = 2.0 * length(r); 98 float m = 2.0 * length(r);
99 vEnvTexCoord = vec2(r.x/m + 0.5, r.y/m + 0.5); 99 vEnvTexCoord = vec2(r.x/m + 0.5, r.y/m + 0.5);
100 100
101 vec3 lightDirection = normalize(u_lightPos - vECPos.xyz); 101 vec3 lightDirection = normalize(u_lightPos - vECPos.xyz);
102 vDiffuseIntensity = max(0.0, dot(normal, lightDirection)); 102 vDiffuseIntensity = max(0.0, dot(normal, lightDirection));
103 103
104} 104}
105 105
106#endif 106#endif