diff options
author | Oz Linden <oz@lindenlab.com> | 2013-04-16 09:00:39 -0400 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2013-04-16 09:00:39 -0400 |
commit | b7d4ba1f086e8a318e389add7c17dcb803689a7d (patch) | |
tree | abd44fe38364125ba5de0ebe260701a1d25c0645 /indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | |
parent | d1f713f30bd4d42fe4696e25c01ab4532ef3b69b (diff) | |
parent | c72c3691ecf83875d4ee3e0784b3e76cb4b4633a (diff) |
merge changes for alpha fixes from geenz
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 67 |
1 files changed, 52 insertions, 15 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index eff94b143a..00717cd6a9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -25,6 +25,10 @@ #extension GL_ARB_texture_rectangle : enable +#define INDEXED 1 +#define NON_INDEXED 2 +#define NON_INDEXED_NO_COLOR 3 + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; #else @@ -33,7 +37,13 @@ out vec4 frag_color; uniform sampler2DRect depthMap; +#if INDEX_MODE != INDEXED +uniform sampler2D diffuseMap; +#endif + +#if INDEX_MODE == INDEXED vec4 diffuseLookup(vec2 texcoord); +#endif uniform vec2 screen_res; @@ -45,11 +55,16 @@ VARYING vec3 vary_directional; VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; +VARYING vec2 vary_texcoord0; +VARYING vec2 vary_texcoord1; +VARYING vec2 vary_texcoord2; +VARYING vec3 vary_norm; +VARYING mat3 vary_rotation; +#if INDEX_MODE != NON_INDEXED_NO_COLOR VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; +#endif -VARYING vec3 vary_norm; uniform mat4 inv_proj; uniform vec4 light_position[8]; @@ -57,13 +72,19 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; +uniform sampler2D bumpMap; +uniform samplerCube environmentMap; +uniform mat3 env_mat; + +uniform vec4 specular_color; + uniform float shadow_offset; -float calcDirectionalLight(vec3 n, vec3 l) +vec3 calcDirectionalLight(vec3 n, vec3 l) { - float a = pow(max(dot(n,l),0.0), 0.7); - return a; + float a = pow(max(dot(n,l),0.0), 0.7); + return vec3(a,a,a); } float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) @@ -103,14 +124,29 @@ void main() vec4 pos = vec4(vary_position, 1.0); - vec4 diff= diffuseLookup(vary_texcoord0.xy); +#if INDEX_MODE == INDEXED + vec4 diff = diffuseLookup(vary_texcoord0.xy); +#else + vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); +#endif - vec3 n = vary_norm; +#if INDEX_MODE == NON_INDEXED_NO_COLOR + float vertex_color_alpha = 1.0; +#else + float vertex_color_alpha = vertex_color.a; +#endif + + vec3 normal = vary_norm; + normal = texture2D(bumpMap, vary_texcoord1.xy).xyz * 2 - 1; + normal = vec3(dot(normal.xyz, vary_rotation[0]), + dot(normal.xyz, vary_rotation[1]), + dot(normal.xyz, vary_rotation[2])); + vec3 l = light_position[0].xyz; - vec3 dlight = calcDirectionalLight(n, l); - dlight = dlight * vary_directional.rgb * vary_pointlight_col; + vec3 dlight = calcDirectionalLight(normal, l); + dlight = dlight * vary_directional.rgb * vary_pointlight_col; - vec4 col = vec4(vary_ambient + dlight, vertex_color.a); + vec4 col = vec4(vary_ambient + dlight, vertex_color_alpha); vec4 color = diff * col; color.rgb = atmosLighting(color.rgb); @@ -118,10 +154,10 @@ void main() color.rgb = scaleSoftClip(color.rgb); vec3 light_col = vec3(0,0,0); -#if MAC_GEFORCE_HACK - #define LIGHT_LOOP(i) \ - light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); - +#ifdef MAC_GEFORCE_HACK + #define LIGHT_LOOP(i) \ + light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + LIGHT_LOOP(1) LIGHT_LOOP(2) LIGHT_LOOP(3) @@ -132,9 +168,10 @@ void main() #else for (int i = 2; i < 8; i++) { - light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); } #endif + color.rgb += diff.rgb * vary_pointlight_col * light_col; frag_color = color; |