summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl12
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl24
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/materialF.glsl172
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/materialV.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl8
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl33
6 files changed, 121 insertions, 135 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 17ac5a276d..ac8393edf8 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -35,7 +35,7 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-#if INDEX_MODE != INDEXED
+#if (INDEX_MODE != INDEXED)
uniform sampler2D diffuseMap;
#endif
@@ -52,7 +52,7 @@ VARYING vec3 vary_pointlight_col;
VARYING vec2 vary_texcoord0;
VARYING vec3 vary_norm;
-#if INDEX_MODE != NON_INDEXED_NO_COLOR
+#if (INDEX_MODE != NON_INDEXED_NO_COLOR)
VARYING vec4 vertex_color;
#endif
@@ -104,20 +104,20 @@ void main()
vec4 pos = vec4(vary_position, 1.0);
-#if INDEX_MODE == INDEXED
- 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
diff.rgb = pow(diff.rgb, vec3(2.2));
-#if INDEX_MODE == NON_INDEXED_NO_COLOR
+#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;
-
+
vec3 l = light_position[0].xyz;
vec3 dlight = calcDirectionalLight(normal, l);
dlight = dlight * vary_directional.rgb * vary_pointlight_col;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index a4b4cd51e3..141a817991 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -34,11 +34,11 @@ uniform mat4 modelview_matrix;
uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
-#if INDEX_MODE == INDEXED
+#if (INDEX_MODE == INDEXED)
void passTextureIndex();
#endif
ATTRIBUTE vec3 normal;
-#if INDEX_MODE != NON_INDEXED_NO_COLOR
+#if (INDEX_MODE != NON_INDEXED_NO_COLOR)
ATTRIBUTE vec4 diffuse_color;
#endif
ATTRIBUTE vec2 texcoord0;
@@ -132,7 +132,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
+
+#if IS_AVATAR_SKIN
mat4 trans = getSkinnedTransform();
vec4 pos_in = vec4(position.xyz, 1.0);
pos.x = dot(trans[0], pos_in);
@@ -153,8 +155,10 @@ void main()
pos = (modelview_matrix * vert);
gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
#endif
-
-#if INDEX_MODE == INDEXED
+
+#endif
+
+#if (INDEX_MODE == INDEXED)
passTextureIndex();
vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
#else
@@ -166,7 +170,7 @@ void main()
calcAtmospherics(pos.xyz);
-#if INDEX_MODE == NON_INDEXED_NO_COLOR
+#if (INDEX_MODE == NON_INDEXED_NO_COLOR)
vec4 diffuse_color = vec4(1,1,1,1);
#endif
//vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.));
@@ -184,17 +188,21 @@ void main()
vary_directional.rgb = atmosAffectDirectionalLight(1.0f);
col.rgb = col.rgb*diffuse_color.rgb;
-#if INDEX_MODE != NON_INDEXED_NO_COLOR
+#if (INDEX_MODE != NON_INDEXED_NO_COLOR)
vertex_color = col;
#endif
#if HAS_SKIN
vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip);
-#elif IS_AVATAR_SKIN
+#else
+
+#if 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
+
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index 5e75cc3ce6..43848761b3 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -29,7 +29,8 @@
#define DIFFUSE_ALPHA_MODE_EMISSIVE 3
-#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND
+#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)
+
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
@@ -349,39 +350,44 @@ vec3 atmosGetDiffuseSunlightColor()
vec3 scaleDownLight(vec3 light)
{
- return (light / scene_light_strength );
+ return (light / vec3(scene_light_strength, scene_light_strength, scene_light_strength));
}
vec3 scaleUpLight(vec3 light)
{
- return (light * scene_light_strength);
+ return (light * vec3(scene_light_strength, scene_light_strength, scene_light_strength));
}
vec3 atmosAmbient(vec3 light)
{
- return getAmblitColor() + light / 2.0;
+ return getAmblitColor() + (light * vec3(0.5f, 0.5f, 0.5f));
}
vec3 atmosAffectDirectionalLight(float lightIntensity)
{
- return getSunlitColor() * lightIntensity;
+ return getSunlitColor() * vec3(lightIntensity, lightIntensity, lightIntensity);
}
vec3 scaleSoftClip(vec3 light)
{
//soft clip effect:
- light = 1. - clamp(light, vec3(0.), vec3(1.));
- light = 1. - pow(light, gamma.xxx);
+ vec3 zeroes = vec3(0.0f, 0.0f, 0.0f);
+ vec3 ones = vec3(1.0f, 1.0f, 1.0f);
+
+ light = ones - clamp(light, zeroes, ones);
+ light = ones - pow(light, gamma.xxx);
return light;
}
#else
+
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_data[3];
#else
#define frag_data gl_FragData
#endif
+
#endif
uniform sampler2D diffuseMap;
@@ -399,7 +405,7 @@ VARYING vec2 vary_texcoord2;
uniform float env_intensity;
uniform vec4 specular_color;
-#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK
+#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK)
uniform float minimum_alpha;
#endif
@@ -426,14 +432,14 @@ void main()
vec4 diffcol = texture2D(diffuseMap, vary_texcoord0.xy);
diffcol.rgb *= vertex_color.rgb;
-#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK
+#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK)
if (diffcol.a < minimum_alpha)
{
discard;
}
#endif
-#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND
+#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)
diffcol.rgb = pow(diffcol.rgb, vec3(2.2));
#endif
@@ -456,9 +462,12 @@ void main()
vec3 tnorm = vary_normal;
#endif
+ norm.xyz = tnorm;
+ norm.xyz = normalize(norm.xyz);
+
vec4 final_color = diffcol;
-#if DIFFUSE_ALPHA_MODE != DIFFUSE_ALPHA_MODE_EMISSIVE
+#if (DIFFUSE_ALPHA_MODE != DIFFUSE_ALPHA_MODE_EMISSIVE)
final_color.a = 0;
#endif
@@ -475,9 +484,8 @@ void main()
#endif
-#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND
- {
- //forward rendering, output just lit RGBA
+#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)
+ //forward rendering, output just lit RGBA
vec3 pos = vary_position;
#if HAS_SUN_SHADOW
@@ -549,110 +557,65 @@ void main()
float shadow = 1.0;
#endif
- vec4 diffuse = final_color;
- vec3 norm = normalize(tnorm);
- vec4 spec = final_specular;
- float envIntensity = final_normal.z;
+ spec = final_specular;
+ vec4 diffuse = final_color;
+ float envIntensity = final_normal.z;
- vec3 col;
- float bloom = 0.0;
- {
- calcAtmospherics(pos.xyz, 1.0);
+ vec3 col = vec3(0.0f,0.0f,0.0f);
+
+ float bloom = 0.0;
+ calcAtmospherics(pos.xyz, 1.0);
- float da = max(dot(norm.xyz, sun_dir.xyz), 0.0);
+ vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
- da = pow(da, 0.7);
+ float da =dot(norm.xyz, sun_dir.xyz);
+ float final_da = pow(da, 0.7f);
+ final_da = min(final_da, shadow);
+ final_da = max(final_da, diffuse.a);
+ final_da = max(final_da, 0.0f);
- col = atmosAmbient(vec3(0));
- col += atmosAffectDirectionalLight(max(min(da, shadow), diffuse.a));
-
- col *= diffuse.rgb;
+ col.rgb = atmosAmbient(col);
+ col.rgb = col.rgb + atmosAffectDirectionalLight(final_da);
+ col.rgb *= diffuse.rgb;
- vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
- if (spec.a > 0.0) // specular reflection
- {
- // the old infinite-sky shiny reflection
- //
+ if (spec.a > 0.0) // specular reflection
+ {
+ // the old infinite-sky shiny reflection
+ //
- float sa = dot(refnormpersp, sun_dir.xyz);
- vec3 dumbshiny = vary_SunlitColor*shadow*(texture2D(lightFunc, vec2(sa, spec.a)).r);
+ float sa = dot(refnormpersp, sun_dir.xyz);
+ vec3 dumbshiny = vary_SunlitColor*shadow*(texture2D(lightFunc, vec2(sa, spec.a)).r);
- // add the two types of shiny together
- vec3 spec_contrib = dumbshiny * spec.rgb;
- bloom = dot(spec_contrib, spec_contrib) / 6;
- col += spec_contrib;
- }
-
- if (envIntensity > 0.0)
- {
- //add environmentmap
- vec3 env_vec = env_mat * refnormpersp;
- col = mix(col.rgb, textureCube(environmentMap, env_vec).rgb,
- max(envIntensity-diffuse.a*2.0, 0.0));
- }
-
- col = atmosLighting(col);
- col = scaleSoftClip(col);
-
- //col = mix(col.rgb, diffuse.rgb, diffuse.a);
- }
-
- vec3 light_col = vec3(0,0,0);
-
- vec3 npos = normalize(-pos.xyz);
+ // add the two types of shiny together
+ vec3 spec_contrib = dumbshiny * spec.rgb;
+ bloom = dot(spec_contrib, spec_contrib) / 6;
+ col += spec_contrib;
+ }
-
- /*vec3 calcPointLightOrSpotLight(
- vec3 light_col,
- vec3 npos,
- vec3 diffuse,
- vec4 spec,
- vec3 v,
- vec3 n,
- vec4 lp,
- vec3 ln,
- float la,
- float fa,
- float is_pointlight)
-
- */
-
- /*
-#ifdef MAC_GEFORCE_HACK
- #define LIGHT_LOOP(i) \
- light_col += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm, 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)
- LIGHT_LOOP(4)
- LIGHT_LOOP(5)
- LIGHT_LOOP(6)
- LIGHT_LOOP(7)
-#else*/
- for (int i = 2; i < 8; i++)
+ if (envIntensity > 0.0)
{
- light_col += calcPointLightOrSpotLight(
- light_diffuse[i].rgb,
- npos,
- diffuse.rgb,
- final_specular,
- pos.xyz,
- norm,
- light_position[i],
- light_direction[i],
- light_attenuation[i].x,
- light_attenuation[i].y,
- light_attenuation[i].z);
+ //add environmentmap
+ vec3 env_vec = env_mat * refnormpersp;
+ col = mix(col.rgb, textureCube(environmentMap, env_vec).rgb,
+ max(envIntensity-diffuse.a*2.0, 0.0));
}
-//#endif
+
+ col = atmosLighting(col);
+ col = scaleSoftClip(col);
- col += light_col;
- frag_color.rgb = col;
+ vec3 npos = normalize(-pos.xyz);
- }
+ #define LIGHT_LOOP(i) \
+ frag_color.rgb = frag_color.rgb + calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z);
+ LIGHT_LOOP(1)
+ LIGHT_LOOP(2)
+ LIGHT_LOOP(3)
+ LIGHT_LOOP(4)
+ LIGHT_LOOP(5)
+ LIGHT_LOOP(6)
+ LIGHT_LOOP(7)
frag_color.a = diffcol.a*vertex_color.a;
@@ -661,4 +624,5 @@ void main()
frag_data[1] = final_specular; // XYZ = Specular color. W = Specular exponent.
frag_data[2] = final_normal; // XY = Normal. Z = Env. intensity.
#endif
+
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl
index f578795abe..0638dcfa55 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl
@@ -37,7 +37,8 @@ uniform mat3 normal_matrix;
uniform mat4 modelview_projection_matrix;
#endif
-#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND
+#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)
+
#if !HAS_SKIN
uniform mat4 modelview_matrix;
#endif
@@ -84,7 +85,7 @@ void main()
vec3 pos = (mat*vec4(position.xyz,1.0)).xyz;
-#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND
+#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)
vary_position = pos;
#endif
@@ -134,7 +135,7 @@ vary_normal = n;
vertex_color = diffuse_color;
-#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND
+#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)
#if !HAS_SKIN
vary_position = (modelview_matrix*vec4(position.xyz, 1.0)).xyz;
#endif
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
index 59950a88ef..e72f9449f1 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
@@ -40,7 +40,7 @@ uniform sampler2DShadow shadowMap1;
uniform sampler2DShadow shadowMap2;
uniform sampler2DShadow shadowMap3;
-#if INDEX_MODE != INDEXED
+#if (INDEX_MODE != INDEXED)
uniform sampler2D diffuseMap;
#endif
@@ -58,7 +58,7 @@ VARYING vec3 vary_pointlight_col;
VARYING vec2 vary_texcoord0;
VARYING vec3 vary_norm;
-#if INDEX_MODE != NON_INDEXED_NO_COLOR
+#if (INDEX_MODE != NON_INDEXED_NO_COLOR)
VARYING vec4 vertex_color;
#endif
@@ -198,13 +198,13 @@ void main()
}
vec4 diff;
-#if INDEX_MODE == INDEXED
+#if (INDEX_MODE == INDEXED)
diff = diffuseLookup(vary_texcoord0.xy);
#else
diff = texture2D(diffuseMap,vary_texcoord0.xy);
#endif
diff.rgb = pow(diff.rgb, vec3(2.2));
-#if INDEX_MODE == NON_INDEXED_NO_COLOR
+#if (INDEX_MODE == NON_INDEXED_NO_COLOR)
float vertex_color_alpha = 1.0;
#else
float vertex_color_alpha = vertex_color.a;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
index dc4dd5d5e9..95fd634c12 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
@@ -34,21 +34,25 @@ uniform mat4 modelview_matrix;
uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
-#if INDEX_MODE == INDEXED
+#if (INDEX_MODE == INDEXED)
void passTextureIndex();
#endif
ATTRIBUTE vec3 normal;
-#if INDEX_MODE != NON_INDEXED_NO_COLOR
+#if (INDEX_MODE != NON_INDEXED_NO_COLOR)
ATTRIBUTE vec4 diffuse_color;
#endif
ATTRIBUTE vec2 texcoord0;
#if HAS_SKIN
mat4 getObjectSkinnedTransform();
-#elif IS_AVATAR_SKIN
+#else
+
+#if IS_AVATAR_SKIN
mat4 getSkinnedTransform();
#endif
+#endif
+
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
void calcAtmospherics(vec3 inPositionEye);
@@ -65,7 +69,7 @@ VARYING vec3 vary_fragcoord;
VARYING vec3 vary_position;
VARYING vec3 vary_pointlight_col;
-#if INDEX_MODE != NON_INDEXED_NO_COLOR
+#if (INDEX_MODE != NON_INDEXED_NO_COLOR)
VARYING vec4 vertex_color;
#endif
@@ -134,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
+
+#if IS_AVATAR_SKIN
mat4 trans = getSkinnedTransform();
vec4 pos_in = vec4(position.xyz, 1.0);
pos.x = dot(trans[0], pos_in);
@@ -155,8 +161,10 @@ void main()
pos = (modelview_matrix * vert);
gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
#endif
-
-#if INDEX_MODE == INDEXED
+
+#endif
+
+#if (INDEX_MODE == INDEXED)
passTextureIndex();
vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
#else
@@ -169,7 +177,7 @@ void main()
calcAtmospherics(pos.xyz);
-#if INDEX_MODE == NON_INDEXED_NO_COLOR
+#if (INDEX_MODE == NON_INDEXED_NO_COLOR)
vec4 diffuse_color = vec4(1,1,1,1);
#endif
@@ -190,16 +198,21 @@ void main()
col.rgb = col.rgb*dff;
-#if INDEX_MODE != NON_INDEXED_NO_COLOR
+#if (INDEX_MODE != NON_INDEXED_NO_COLOR)
vertex_color = col;
#endif
#if HAS_SKIN
vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip);
-#elif IS_AVATAR_SKIN
+#else
+
+#if 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
+
}