summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
diff options
context:
space:
mode:
authorAura Linden <aura@lindenlab.com>2013-07-11 17:49:13 -0700
committerAura Linden <aura@lindenlab.com>2013-07-11 17:49:13 -0700
commitce9962b33872db65b70c9b10901ec9062cb59169 (patch)
tree94be5367128e241ef1c6f802e8551a9b4ed786ff /indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
parent8642f57dd95864ec6b002f6519701f30866c6502 (diff)
parent6060e5e46acbeb20a301070a0fd0efea029d33d0 (diff)
Merged in viewer-release
Diffstat (limited to 'indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl')
-rwxr-xr-x[-rw-r--r--]indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl128
1 files changed, 101 insertions, 27 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
index 1586aab0f2..13c6ffc607 100644..100755
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
@@ -25,19 +25,36 @@
uniform mat3 normal_matrix;
uniform mat4 texture_matrix0;
+uniform mat4 projection_matrix;
uniform mat4 modelview_matrix;
uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
+
+#ifdef USE_INDEXED_TEX
void passTextureIndex();
+#endif
+
ATTRIBUTE vec3 normal;
+
+#ifdef USE_VERTEX_COLOR
ATTRIBUTE vec4 diffuse_color;
+#endif
+
ATTRIBUTE vec2 texcoord0;
+#ifdef HAS_SKIN
+mat4 getObjectSkinnedTransform();
+#else
+#ifdef IS_AVATAR_SKIN
+mat4 getSkinnedTransform();
+#endif
+#endif
+
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
void calcAtmospherics(vec3 inPositionEye);
-float calcDirectionalLight(vec3 n, vec3 l);
+vec3 calcDirectionalLight(vec3 n, vec3 l);
vec3 atmosAmbient(vec3 light);
vec3 atmosAffectDirectionalLight(float lightIntensity);
@@ -50,9 +67,12 @@ VARYING vec3 vary_fragcoord;
VARYING vec3 vary_position;
VARYING vec3 vary_pointlight_col;
+#ifdef USE_VERTEX_COLOR
VARYING vec4 vertex_color;
-VARYING vec2 vary_texcoord0;
+#endif
+VARYING vec2 vary_texcoord0;
+VARYING vec3 vary_norm;
uniform float near_clip;
uniform float shadow_offset;
@@ -63,13 +83,15 @@ uniform vec3 light_direction[8];
uniform vec3 light_attenuation[8];
uniform vec3 light_diffuse[8];
-float calcDirectionalLight(vec3 n, vec3 l)
+uniform vec3 sun_dir;
+
+vec3 calcDirectionalLight(vec3 n, vec3 l)
{
float a = max(dot(n,l),0.0);
- return a;
+ return vec3(a,a,a);
}
-float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
+vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
{
//get light vector
vec3 lv = lp.xyz-v;
@@ -96,55 +118,107 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
da *= max(dot(n, lv), 0.0);
}
- return da;
+ return vec3(da,da,da);
}
void main()
{
+ vec4 pos;
+ vec3 norm;
+
//transform vertex
+#ifdef HAS_SKIN
+ mat4 trans = getObjectSkinnedTransform();
+ trans = modelview_matrix * trans;
+
+ pos = trans * vec4(position.xyz, 1.0);
+
+ norm = position.xyz + normal.xyz;
+ norm = normalize((trans * vec4(norm, 1.0)).xyz - pos.xyz);
+ vec4 frag_pos = projection_matrix * pos;
+ gl_Position = frag_pos;
+#else
+
+#ifdef IS_AVATAR_SKIN
+ mat4 trans = getSkinnedTransform();
+ vec4 pos_in = vec4(position.xyz, 1.0);
+ pos.x = dot(trans[0], pos_in);
+ pos.y = dot(trans[1], pos_in);
+ pos.z = dot(trans[2], pos_in);
+ pos.w = 1.0;
+
+ norm.x = dot(trans[0].xyz, normal);
+ norm.y = dot(trans[1].xyz, normal);
+ norm.z = dot(trans[2].xyz, normal);
+ norm = normalize(norm);
+
+ vec4 frag_pos = projection_matrix * pos;
+ gl_Position = frag_pos;
+#else
+ norm = normalize(normal_matrix * normal);
vec4 vert = vec4(position.xyz, 1.0);
- passTextureIndex();
- vec4 pos = (modelview_matrix * vert);
+ pos = (modelview_matrix * vert);
gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
+#endif
+#endif
+
+#ifdef USE_INDEXED_TEX
+ passTextureIndex();
vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
-
- vec3 norm = normalize(normal_matrix * normal);
+#else
+ vary_texcoord0 = texcoord0;
+#endif
+ vary_norm = norm;
float dp_directional_light = max(0.0, dot(norm, light_position[0].xyz));
vary_position = pos.xyz + light_position[0].xyz * (1.0-dp_directional_light)*shadow_offset;
-
+
calcAtmospherics(pos.xyz);
+#ifndef USE_VERTEX_COLOR
+ vec4 diffuse_color = vec4(1,1,1,1);
+#endif
+
//vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.));
vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a);
-
- // Collect normal lights
- col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z);
- col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z);
- col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z);
- col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z);
- col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z);
- col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z);
+ vec3 dff = pow(diffuse_color.rgb, vec3(2.2f,2.2f,2.2f));
- vary_pointlight_col = col.rgb*diffuse_color.rgb;
+ vary_pointlight_col = dff;
col.rgb = vec3(0,0,0);
// Add windlight lights
- col.rgb = atmosAmbient(vec3(0.));
+ col.rgb = atmosAmbient(col.rgb);
- vary_ambient = col.rgb*diffuse_color.rgb;
- vary_directional.rgb = diffuse_color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), (1.0-diffuse_color.a)*(1.0-diffuse_color.a)));
+ float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0);
+ ambient *= 0.5;
+ ambient *= ambient;
+ ambient = (1.0-ambient);
+
+ col.rgb *= ambient;
+
+ vary_directional.rgb = atmosAffectDirectionalLight(1.0f);
+ vary_ambient = col.rgb*dff;
- col.rgb = col.rgb*diffuse_color.rgb;
+ col.rgb = col.rgb*dff;
+#ifdef USE_VERTEX_COLOR
vertex_color = col;
-
-
+#endif
+#ifdef HAS_SKIN
+ vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip);
+#else
+
+#ifdef IS_AVATAR_SKIN
+ vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
+#else
pos = modelview_projection_matrix * vert;
vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
-
+#endif
+
+#endif
+
}