diff options
author | Kris Kowal | 2012-07-06 12:42:16 -0700 |
---|---|---|
committer | Kris Kowal | 2012-07-06 15:01:49 -0700 |
commit | 6803c0abd279fcb640c38b3881b751bab982cbe0 (patch) | |
tree | 876211d178954cbaa73e0fbb658fe0c6ffb7ac8d /assets/shaders/test_fshader.glsl | |
parent | 3644cb6def4f681c99959e5729e78ea353441fad (diff) | |
download | ninja-6803c0abd279fcb640c38b3881b751bab982cbe0.tar.gz |
Remove trailing spaces
Diffstat (limited to 'assets/shaders/test_fshader.glsl')
-rwxr-xr-x | assets/shaders/test_fshader.glsl | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/assets/shaders/test_fshader.glsl b/assets/shaders/test_fshader.glsl index 1fa78e44..de5da773 100755 --- a/assets/shaders/test_fshader.glsl +++ b/assets/shaders/test_fshader.glsl | |||
@@ -40,7 +40,7 @@ uniform vec4 u_light0Amb; | |||
40 | // diffuse map | 40 | // diffuse map |
41 | uniform sampler2D u_colMap; | 41 | uniform sampler2D u_colMap; |
42 | 42 | ||
43 | // environment map | 43 | // environment map |
44 | uniform sampler2D envMap; | 44 | uniform sampler2D envMap; |
45 | 45 | ||
46 | // normal map | 46 | // normal map |
@@ -77,7 +77,7 @@ void main() | |||
77 | float dist = vShadowCoord.w/200.0; | 77 | float dist = vShadowCoord.w/200.0; |
78 | float d = dot(rgba_depth, bit_shift); | 78 | float d = dot(rgba_depth, bit_shift); |
79 | float shadowCoef = (dist > d + 0.00779) ? (0.6) : (1.0); | 79 | float shadowCoef = (dist > d + 0.00779) ? (0.6) : (1.0); |
80 | 80 | ||
81 | vec4 colMapTexel = vec4(0); | 81 | vec4 colMapTexel = vec4(0); |
82 | if (u_renderGlow <= 0.5) { | 82 | if (u_renderGlow <= 0.5) { |
83 | colMapTexel = vec4(texture2D(u_colMap, vec2(vNormal.w, vECPos.w)).rgb, 1.0); | 83 | colMapTexel = vec4(texture2D(u_colMap, vec2(vNormal.w, vECPos.w)).rgb, 1.0); |
@@ -89,32 +89,32 @@ void main() | |||
89 | vec3 normal = normalize(vNormal.xyz); | 89 | vec3 normal = normalize(vNormal.xyz); |
90 | vec3 mapNormal = texture2D(u_normalMap, vec2(vNormal.w, vECPos.w)).xyz * 2.0 - 1.0; | 90 | vec3 mapNormal = texture2D(u_normalMap, vec2(vNormal.w, vECPos.w)).xyz * 2.0 - 1.0; |
91 | mapNormal = normalize(mapNormal.x*vec3(normal.z, 0.0, -normal.x) + vec3(0.0, mapNormal.y, 0.0) + mapNormal.z*normal); | 91 | mapNormal = normalize(mapNormal.x*vec3(normal.z, 0.0, -normal.x) + vec3(0.0, mapNormal.y, 0.0) + mapNormal.z*normal); |
92 | 92 | ||
93 | // create envmap coordinates | 93 | // create envmap coordinates |
94 | vec3 r = reflect( normalize(vec3(vECPos.xyz - vEyePos.xyz)), mapNormal); | 94 | vec3 r = reflect( normalize(vec3(vECPos.xyz - vEyePos.xyz)), mapNormal); |
95 | float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + r.z*r.z ); | 95 | float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + r.z*r.z ); |
96 | 96 | ||
97 | // calculate environment map texel | 97 | // calculate environment map texel |
98 | vec4 envMapTexel = vec4(texture2D(envMap, vec2(r.x/m + 0.5, r.y/m + 0.5)).rgb, 0.0); | 98 | vec4 envMapTexel = vec4(texture2D(envMap, vec2(r.x/m + 0.5, r.y/m + 0.5)).rgb, 0.0); |
99 | 99 | ||
100 | // lighting | 100 | // lighting |
101 | vec3 lightDirection = u_light0Pos - vECPos.xyz; | 101 | vec3 lightDirection = u_light0Pos - vECPos.xyz; |
102 | float lightDist = length(lightDirection); | 102 | float lightDist = length(lightDirection); |
103 | lightDirection /= lightDist; | 103 | lightDirection /= lightDist; |
104 | 104 | ||
105 | float attenuation = clamp(1.0 - lightDist * 0.01, 0.0, 1.0); | 105 | float attenuation = clamp(1.0 - lightDist * 0.01, 0.0, 1.0); |
106 | 106 | ||
107 | vec3 halfVec = normalize(lightDirection + vEyePos); | 107 | vec3 halfVec = normalize(lightDirection + vEyePos); |
108 | 108 | ||
109 | float diffuseIntensity = max(0.0, dot(mapNormal, lightDirection)); | 109 | float diffuseIntensity = max(0.0, dot(mapNormal, lightDirection)); |
110 | float specularModifier = max(0.0, dot(mapNormal, halfVec)); | 110 | float specularModifier = max(0.0, dot(mapNormal, halfVec)); |
111 | 111 | ||
112 | float pf; | 112 | float pf; |
113 | if(diffuseIntensity == 0.0) | 113 | if(diffuseIntensity == 0.0) |
114 | pf = 0.0; | 114 | pf = 0.0; |
115 | else | 115 | else |
116 | pf = pow(specularModifier, 76.0); | 116 | pf = pow(specularModifier, 76.0); |
117 | 117 | ||
118 | vec4 ambient = u_matAmbient * u_light0Amb; | 118 | vec4 ambient = u_matAmbient * u_light0Amb; |
119 | 119 | ||
120 | vec4 diffuse = u_matDiffuse * (colMapTexel + envMapTexel)*shadowCoef; | 120 | vec4 diffuse = u_matDiffuse * (colMapTexel + envMapTexel)*shadowCoef; |
@@ -122,9 +122,9 @@ void main() | |||
122 | if (u_renderGlow <= 0.5) { | 122 | if (u_renderGlow <= 0.5) { |
123 | diffuse *= u_light0Diff; | 123 | diffuse *= u_light0Diff; |
124 | } | 124 | } |
125 | 125 | ||
126 | vec4 specular = 2.0 * pf * envMapTexel; | 126 | vec4 specular = 2.0 * pf * envMapTexel; |
127 | 127 | ||
128 | //gl_FragColor = vec4(dist, dist, dist, 1.0); | 128 | //gl_FragColor = vec4(dist, dist, dist, 1.0); |
129 | gl_FragColor = ((colMapTexel*(ambient + diffuse)) + specular); | 129 | gl_FragColor = ((colMapTexel*(ambient + diffuse)) + specular); |
130 | } | 130 | } |
@@ -141,40 +141,40 @@ void main() | |||
141 | vec3 normal = normalize(vNormal.xyz); | 141 | vec3 normal = normalize(vNormal.xyz); |
142 | // vec3 mapNormal = texture2D(u_normalMap, vec2(vNormal.w, vECPos.w)).xyz * 2.0 - 1.0; | 142 | // vec3 mapNormal = texture2D(u_normalMap, vec2(vNormal.w, vECPos.w)).xyz * 2.0 - 1.0; |
143 | // mapNormal = normalize(mapNormal.x*vec3(normal.z, 0.0, -normal.x) + vec3(0.0, mapNormal.y, 0.0) + mapNormal.z*normal); | 143 | // mapNormal = normalize(mapNormal.x*vec3(normal.z, 0.0, -normal.x) + vec3(0.0, mapNormal.y, 0.0) + mapNormal.z*normal); |
144 | // | 144 | // |
145 | // // create envmap coordinates | 145 | // // create envmap coordinates |
146 | // vec3 r = reflect( (vec3(vECPos.xyz - vEyePos.xyz)), mapNormal); | 146 | // vec3 r = reflect( (vec3(vECPos.xyz - vEyePos.xyz)), mapNormal); |
147 | // float m = 2.0 * length(r); | 147 | // float m = 2.0 * length(r); |
148 | 148 | ||
149 | // calculate environment map texel | 149 | // calculate environment map texel |
150 | //vec4 envMapTexel = vec4(texture2D(envMap, vec2(r.x/m + 0.5, r.y/m + 0.5)).rgb, 0.0); | 150 | //vec4 envMapTexel = vec4(texture2D(envMap, vec2(r.x/m + 0.5, r.y/m + 0.5)).rgb, 0.0); |
151 | vec4 envMapTexel = vec4(texture2D(envMap, vEnvTexCoord).rgb, 0.0); | 151 | vec4 envMapTexel = vec4(texture2D(envMap, vEnvTexCoord).rgb, 0.0); |
152 | 152 | ||
153 | // lighting | 153 | // lighting |
154 | //vec3 lightDirection = normalize(u_light0Pos - vECPos.xyz); | 154 | //vec3 lightDirection = normalize(u_light0Pos - vECPos.xyz); |
155 | // float lightDist = length(lightDirection); | 155 | // float lightDist = length(lightDirection); |
156 | // lightDirection /= lightDist; | 156 | // lightDirection /= lightDist; |
157 | 157 | ||
158 | 158 | ||
159 | //vec3 halfVec = normalize(lightDirection + vEyePos); | 159 | //vec3 halfVec = normalize(lightDirection + vEyePos); |
160 | 160 | ||
161 | //float diffuseIntensity = max(0.0, dot(normal, lightDirection)); | 161 | //float diffuseIntensity = max(0.0, dot(normal, lightDirection)); |
162 | // float specularModifier = max(0.0, dot(mapNormal, halfVec)); | 162 | // float specularModifier = max(0.0, dot(mapNormal, halfVec)); |
163 | 163 | ||
164 | // float pf; | 164 | // float pf; |
165 | //if(diffuseIntensity == 0.0) | 165 | //if(diffuseIntensity == 0.0) |
166 | //pf = 0.0; | 166 | //pf = 0.0; |
167 | //else | 167 | //else |
168 | //pf = pow(specularModifier, 76.0); | 168 | //pf = pow(specularModifier, 76.0); |
169 | 169 | ||
170 | // vec4 ambient = u_matAmbient * u_light0Amb; | 170 | // vec4 ambient = u_matAmbient * u_light0Amb; |
171 | 171 | ||
172 | vec4 diffuse = u_matDiffuse*(colMapTexel + envMapTexel)*(vDiffuseIntensity + u_matAmbient); | 172 | vec4 diffuse = u_matDiffuse*(colMapTexel + envMapTexel)*(vDiffuseIntensity + u_matAmbient); |
173 | 173 | ||
174 | //diffuse *= u_light0Diff * diffuseIntensity; | 174 | //diffuse *= u_light0Diff * diffuseIntensity; |
175 | 175 | ||
176 | //vec4 specular = envMapTexel; | 176 | //vec4 specular = envMapTexel; |
177 | 177 | ||
178 | //gl_FragColor = vec4(dist, dist, dist, 1.0); | 178 | //gl_FragColor = vec4(dist, dist, dist, 1.0); |
179 | gl_FragColor = diffuse;//(colMapTexel*(ambient + diffuse)) + specular; | 179 | gl_FragColor = diffuse;//(colMapTexel*(ambient + diffuse)) + specular; |
180 | } | 180 | } |