diff options
author | Graham Madarasz <graham@lindenlab.com> | 2013-04-24 06:24:21 -0700 |
---|---|---|
committer | Graham Madarasz <graham@lindenlab.com> | 2013-04-24 06:24:21 -0700 |
commit | 79318043218a9ec6cb6e52eca936487177554903 (patch) | |
tree | 218b1f39303fa11aaaa6e39701e7335dc3680015 /indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl | |
parent | fbbbb80752e91deff0bbaf5893210fddff53eb13 (diff) |
NORSPEC-59 NORSPEC-125 make materials and alpha shaders work on Mac laptops with nV mobile graphics cards
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl | 63 |
1 files changed, 39 insertions, 24 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl index 6a1bfd5bef..a8efd3e95b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl @@ -34,25 +34,31 @@ uniform mat4 modelview_matrix; uniform mat4 modelview_projection_matrix; ATTRIBUTE vec3 position; -#if INDEX_MODE == INDEXED + +#ifdef USE_INDEXED_TEX void passTextureIndex(); #endif + ATTRIBUTE vec3 normal; -#if INDEX_MODE != NON_INDEXED_NO_COLOR + +#ifdef USE_VERTEX_COLOR ATTRIBUTE vec4 diffuse_color; #endif + ATTRIBUTE vec2 texcoord0; -#if HAS_SKIN +#ifdef HAS_SKIN mat4 getObjectSkinnedTransform(); -#elif IS_AVATAR_SKIN +#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); @@ -65,7 +71,7 @@ VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; -#if INDEX_MODE != NON_INDEXED_NO_COLOR +#ifdef USE_VERTEX_COLOR VARYING vec4 vertex_color; #endif @@ -80,13 +86,13 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; -float calcDirectionalLight(vec3 n, vec3 l) +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; @@ -113,7 +119,7 @@ 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() @@ -122,7 +128,7 @@ void main() vec3 norm; //transform vertex -#if HAS_SKIN +#ifdef HAS_SKIN mat4 trans = getObjectSkinnedTransform(); trans = modelview_matrix * trans; @@ -132,7 +138,9 @@ void main() norm = normalize((trans * vec4(norm, 1.0)).xyz - pos.xyz); vec4 frag_pos = projection_matrix * pos; gl_Position = frag_pos; -#elif IS_AVATAR_SKIN +#else + +#ifdef IS_AVATAR_SKIN mat4 trans = getSkinnedTransform(); vec4 pos_in = vec4(position.xyz, 1.0); pos.x = dot(trans[0], pos_in); @@ -154,7 +162,9 @@ void main() gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0); #endif -#if INDEX_MODE == INDEXED +#endif + +#ifdef USE_INDEXED_TEX passTextureIndex(); vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; #else @@ -166,36 +176,41 @@ void main() calcAtmospherics(pos.xyz); -#if INDEX_MODE == NON_INDEXED_NO_COLOR +#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); - vec3 diff = pow(diffuse_color.rgb, vec3(2.2)); - - vary_pointlight_col = diff; + vary_pointlight_col = diffuse_color.rgb; col.rgb = vec3(0,0,0); // Add windlight lights - col.rgb = atmosAmbient(vec3(0.)); + col.rgb = atmosAmbient(col.rgb); - vary_ambient = col.rgb*diff; - vary_directional.rgb = atmosAffectDirectionalLight(1); + vary_ambient = col.rgb*diffuse_color.rgb; + + vary_directional.rgb = atmosAffectDirectionalLight(1.0f); - col.rgb = col.rgb*diff; -#if INDEX_MODE != NON_INDEXED_NO_COLOR + col.rgb = col.rgb*diffuse_color.rgb; + +#ifdef USE_VERTEX_COLOR vertex_color = col; #endif -#if HAS_SKIN +#ifdef HAS_SKIN vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip); -#elif IS_AVATAR_SKIN +#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 + } + |