summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1
diff options
context:
space:
mode:
authorGeenz <geenz@geenzo.com>2013-04-18 23:11:38 -0400
committerGeenz <geenz@geenzo.com>2013-04-18 23:11:38 -0400
commit9e53724538d61e6e53f5bf56e01760d59b54f690 (patch)
treeac494bb773e15f5b59bb3a6fffac0a5f913ce40b /indra/newview/app_settings/shaders/class1
parentb6a6479c372e311b45e27eafd368e2045ca21790 (diff)
parent509c35d5bae7dbd938198c3e038011932693ff36 (diff)
Merged with latest viewer-development-materials.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl46
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl17
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl35
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/materialF.glsl15
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl15
5 files changed, 51 insertions, 77 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index aa0e73d058..97767964f0 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -39,10 +39,6 @@ out vec4 frag_color;
uniform sampler2D diffuseMap;
#endif
-#if INDEX_MODE == INDEXED
-vec4 diffuseLookup(vec2 texcoord);
-#endif
-
uniform vec2 screen_res;
vec3 atmosLighting(vec3 light);
@@ -54,34 +50,24 @@ 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;
#endif
-uniform mat4 inv_proj;
-
uniform vec4 light_position[8];
uniform vec3 light_direction[8];
uniform vec3 light_attenuation[8];
uniform vec3 light_diffuse[8];
-uniform vec4 specular_color;
-
-
-uniform float shadow_offset;
-
vec3 calcDirectionalLight(vec3 n, vec3 l)
{
- float a = pow(max(dot(n,l),0.0), 0.7);
+ float a = max(dot(n,l),0.0);
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;
@@ -105,10 +91,10 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
da *= spot*spot; // GL_SPOT_EXPONENT=2
//angular attenuation
- da *= max(pow(dot(n, lv), 0.7), 0.0);
+ da *= max(dot(n, lv), 0.0);
}
- return da;
+ return vec3(da,da,da);
}
void main()
@@ -123,18 +109,18 @@ void main()
#else
vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy);
#endif
- diff.rgb = pow(diff.rgb, vec3(2.2));
+
#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 normal = vary_norm;
vec3 l = light_position[0].xyz;
vec3 dlight = calcDirectionalLight(normal, l);
- dlight = dlight * vary_directional.rgb * vary_pointlight_col;
+ dlight = dlight * vary_directional.rgb * vary_pointlight_col;
vec4 col = vec4(vary_ambient + dlight, vertex_color_alpha);
vec4 color = diff * col;
@@ -142,12 +128,11 @@ void main()
color.rgb = atmosLighting(color.rgb);
color.rgb = scaleSoftClip(color.rgb);
- vec3 light_col = vec3(0,0,0);
+ col = vec4(0,0,0,0);
+
+ #define LIGHT_LOOP(i) \
+ col.rgb += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i].xyz, 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)
@@ -155,14 +140,9 @@ void main()
LIGHT_LOOP(5)
LIGHT_LOOP(6)
LIGHT_LOOP(7)
-#else
- for (int i = 2; i < 8; 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);
- }
-#endif
- color.rgb += diff.rgb * vary_pointlight_col * light_col;
+ color.rgb += diff.rgb * vary_pointlight_col * col.rgb;
+
frag_color = color;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
index e872dadcc1..cccc7275ab 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
@@ -56,13 +56,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 = pow(max(dot(n,l),0.0), 0.7);
- 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;
@@ -89,7 +89,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
da *= max(pow(dot(n, lv), 0.7), 0.0);
}
- return da;
+ return vec3(da,da,da);
}
vec4 getPosition(vec2 pos_screen)
@@ -126,7 +126,7 @@ 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);
@@ -137,12 +137,7 @@ void main()
LIGHT_LOOP(5)
LIGHT_LOOP(6)
LIGHT_LOOP(7)
-#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);
- }
-#endif
+
color.rgb += diff.rgb * vary_pointlight_col * light_col;
frag_color = color;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index 13676ceead..4c26621a88 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -38,11 +38,10 @@ ATTRIBUTE vec3 position;
void passTextureIndex();
#endif
ATTRIBUTE vec3 normal;
+#if INDEX_MODE != NON_INDEXED_NO_COLOR
ATTRIBUTE vec4 diffuse_color;
+#endif
ATTRIBUTE vec2 texcoord0;
-ATTRIBUTE vec3 binormal;
-ATTRIBUTE vec2 texcoord1;
-ATTRIBUTE vec2 texcoord2;
#if HAS_SKIN
mat4 getObjectSkinnedTransform();
@@ -71,15 +70,10 @@ VARYING vec4 vertex_color;
#endif
VARYING vec2 vary_texcoord0;
-VARYING vec2 vary_texcoord1;
-VARYING vec2 vary_texcoord2;
VARYING vec3 vary_norm;
-VARYING mat3 vary_rotation;
uniform float near_clip;
-uniform float shadow_offset;
-uniform float shadow_bias;
uniform vec4 light_position[8];
uniform vec3 light_direction[8];
@@ -159,8 +153,7 @@ void main()
pos = (modelview_matrix * vert);
gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
#endif
- vary_texcoord1 = (texture_matrix0 * vec4(texcoord1,0,1)).xy;
- vary_texcoord2 = (texture_matrix0 * vec4(texcoord2,0,1)).xy;
+
#if INDEX_MODE == INDEXED
passTextureIndex();
vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
@@ -169,33 +162,27 @@ void main()
#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;
-
- vec3 n = norm;
- vec3 b = normalize(normal_matrix * binormal);
- vec3 t = cross(b, n);
-
- vary_rotation[0] = vec3(t.x, b.x, n.x);
- vary_rotation[1] = vec3(t.y, b.y, n.y);
- vary_rotation[2] = vec3(t.z, b.z, n.z);
+ vary_position = pos.xyz;
calcAtmospherics(pos.xyz);
- vec3 dff = pow(diffuse_color.rgb, vec3(2.2));
+
+#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.));
vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a);
- vary_pointlight_col = dff;
+ vary_pointlight_col = diffuse_color.rgb;
col.rgb = vec3(0,0,0);
// Add windlight lights
col.rgb = atmosAmbient(vec3(0.));
+ vary_ambient = col.rgb*diffuse_color.rgb;
vary_directional.rgb = atmosAffectDirectionalLight(1);
- vary_ambient = col.rgb*dff;
- col.rgb = col.rgb*dff;
+ col.rgb = col.rgb*diffuse_color.rgb;
#if INDEX_MODE != NON_INDEXED_NO_COLOR
vertex_color = col;
#endif
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index 79a06bed2c..5e75cc3ce6 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -115,7 +115,7 @@ uniform vec3 light_diffuse[8];
vec3 calcDirectionalLight(vec3 n, vec3 l)
{
- float a = pow(max(dot(n,l),0.0), 0.7);
+ float a = max(dot(n,l),0.0);
return vec3(a,a,a);
}
@@ -149,8 +149,6 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe
da *= max(dot(n, lv), 0.0);
float lit = max(da * dist_atten, 0.0);
-
- lit = pow(lit, 0.7);
col = light_col*lit*diffuse;
@@ -435,6 +433,10 @@ void main()
}
#endif
+#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND
+ diffcol.rgb = pow(diffcol.rgb, vec3(2.2));
+#endif
+
#if HAS_SPECULAR_MAP
vec4 spec = texture2D(specularMap, vary_texcoord2.xy);
#else
@@ -566,11 +568,13 @@ void main()
col *= diffuse.rgb;
+ vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
+
if (spec.a > 0.0) // specular reflection
{
// the old infinite-sky shiny reflection
//
- vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
+
float sa = dot(refnormpersp, sun_dir.xyz);
vec3 dumbshiny = vary_SunlitColor*shadow*(texture2D(lightFunc, vec2(sa, spec.a)).r);
@@ -578,7 +582,10 @@ void main()
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,
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 026039a0e7..aafa932b8f 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -306,11 +306,13 @@ void main()
col *= diffuse.rgb;
+ vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
+
if (spec.a > 0.0) // specular reflection
{
// the old infinite-sky shiny reflection
//
- vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
+
float sa = dot(refnormpersp, sun_dir.xyz);
vec3 dumbshiny = vary_SunlitColor*(texture2D(lightFunc, vec2(sa, spec.a)).r);
@@ -318,13 +320,15 @@ void main()
vec3 spec_contrib = dumbshiny * spec.rgb;
bloom = dot(spec_contrib, spec_contrib) / 6;
col += spec_contrib;
-
- //add environmentmap
+ }
+
+ if (envIntensity > 0.0)
+ { //add environmentmap
vec3 env_vec = env_mat * refnormpersp;
col = mix(col.rgb, pow(textureCube(environmentMap, env_vec).rgb, vec3(2.2)) * 2.2,
max(envIntensity-diffuse.a*2.0, 0.0));
}
-
+
col = atmosLighting(col);
col = scaleSoftClip(col);
@@ -337,5 +341,6 @@ void main()
frag_color.rgb = col;
- frag_color.a = bloom;
+ //frag_color.a = bloom;
+ frag_color.a = 0.0;
}