summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2019-05-22 11:00:30 -0700
committerGraham Linden <graham@lindenlab.com>2019-05-22 11:00:30 -0700
commitdb091d23db70952b4ad8b610ef02942a8f13f223 (patch)
tree8e7a4013eb2927692b735b479de417e501d673e6 /indra/newview/app_settings/shaders/class1
parente9dbee00262a437e4b3f971b37ea636e92032133 (diff)
SL-10969
Fix linear attenuation on forward projector lighting. Revert setup of falloff to prev code. Revert deferred water spec and tweak refl/refr blend.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl18
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/materialF.glsl23
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/waterF.glsl52
7 files changed, 67 insertions, 42 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index e0bf58a5c2..1c826790fb 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -107,7 +107,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec
return col;
}
- if (d > 0.0)
+ if (d > 0.0 && la > 0.0 && fa > 0.0)
{
//normalize light vector
lv = normalize(lv);
@@ -115,13 +115,19 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec
da = dot(norm, lv);
da = clamp(da, 0.0, 1.0);
+
+la /= 20.0f;
//distance attenuation
- float dist = (la > 0) ? d/la : 1.0f;
- fa += 1.0f;
- float dist_atten = (fa > 0) ? clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0) : 0.0f;
+ float dist = d/la;
+
+ float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
dist_atten *= dist_atten;
- dist_atten *= 2.2f;
+
+ if (dist_atten < 0.0)
+ {
+ return col;
+ }
// spotlight coefficient.
float spot = max(dot(-ln, lv), is_pointlight);
@@ -224,7 +230,7 @@ void main()
ambient *= 0.5;
ambient *= ambient;
- float ambient_clamp = getAmbientClamp() + 0.2;
+ float ambient_clamp = getAmbientClamp() + 0.1;
ambient = (1.0 - ambient) * ambient_clamp;
vec3 sun_contrib = min(final_da, shadow) * sunlit;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index b9c16bfa11..373727f572 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -110,17 +110,18 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe
return col;
}
- if (d > 0.0)
- {
+ if (d > 0.0 && la > 0.0 && fa > 0.0)
+ {
//normalize light vector
lv = normalize(lv);
-
+
+la /= 20.0f;
+
//distance attenuation
- float dist = (la > 0) ? d/la : 1.0f;
- fa += 1.0f;
- float dist_atten = ( fa > 0) ? clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0) : 1.0f;
+ float dist = d/la;
+
+ float dist_atten = (fa > 0) ? clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0) : 1.0f;
dist_atten *= dist_atten;
- dist_atten *= 2.2f;
if (dist_atten <= 0)
{
@@ -139,15 +140,15 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe
float lit = max(da * dist_atten, 0.0);
float amb_da = ambiance;
- if (da > 0)
- {
+ if (lit > 0)
+ {
col = light_col*lit*diffuse;
amb_da += (da*0.5 + 0.5) * ambiance;
amb_da += (da*da*0.5+0.5) * ambiance;
}
amb_da *= dist_atten;
amb_da = min(amb_da, 1.0f - lit);
- col.rgb += amb_da * 0.25 * light_col * diffuse;
+ col.rgb += amb_da * 0.5 * light_col * diffuse;
if (spec.a > 0.0)
{
@@ -321,7 +322,7 @@ void main()
ambient *= 0.5;
ambient *= ambient;
- float ambient_clamp = getAmbientClamp() + 0.2;
+ float ambient_clamp = getAmbientClamp() + 0.1;
ambient = (1.0 - ambient) * ambient_clamp;
vec3 sun_contrib = min(final_da, shadow) * sunlit;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
index 2569e49743..2dd9c1f057 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
@@ -72,10 +72,12 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
vec3 getNorm(vec2 pos_screen);
+vec3 srgb_to_linear(vec3 c);
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
+ ret.rgb = srgb_to_linear(ret.rgb);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
@@ -95,6 +97,7 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
+ ret.rgb = srgb_to_linear(ret.rgb);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
@@ -112,6 +115,7 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
+ ret.rgb = srgb_to_linear(ret.rgb);
vec2 dist = tc-vec2(0.5);
@@ -263,7 +267,7 @@ void main()
}
}
}
-
+//col.rgb = vec3(0);
frag_color.rgb = col;
frag_color.a = 0.0;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
index f8264d971c..73bc1141b0 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
@@ -124,7 +124,7 @@ void main()
{
discard;
}
-
+//col.rgb = vec3(0);
frag_color.rgb = col;
frag_color.a = 0.0;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 40bb705326..4ab68eaf3b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -156,7 +156,7 @@ vec3 post_diffuse = color.rgb;
vec3 post_spec = color.rgb;
#ifndef WATER_FOG
- color.rgb = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a);
+ color.rgb += diffuse_srgb.rgb * diffuse_srgb.a;
#endif
if (envIntensity > 0.0)
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index d09bc25334..c6417fa532 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -71,10 +71,12 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
vec3 getNorm(vec2 pos_screen);
+vec3 srgb_to_linear(vec3 c);
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
+ ret.rgb = srgb_to_linear(ret.rgb);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
@@ -94,6 +96,7 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
+ ret.rgb = srgb_to_linear(ret.rgb);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
@@ -111,6 +114,7 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
+ ret.rgb = srgb_to_linear(ret.rgb);
vec2 dist = tc-vec2(0.5);
@@ -268,7 +272,7 @@ void main()
}
}
}
-
+//col.rgb = vec3(0);
frag_color.rgb = col;
frag_color.a = 0.0;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index 914e17beed..0459b39bd9 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -129,8 +129,7 @@ void main()
vec4 refcol = refcol1 + refcol2 + refcol3;
float df1 = df.x + df.y + df.z;
- df1 *= 0.333;
- refcol *= df1;
+ refcol *= df1 * 0.333;
vec3 wavef = (wave1 + wave2 * 0.4 + wave3 * 0.6) * 0.5;
wavef.z *= max(-viewVec.z, 0.1);
@@ -145,23 +144,34 @@ void main()
vec4 baseCol = texture2D(refTex, refvec4);
refcol = mix(baseCol*df2, refcol, dweight);
-
- //figure out distortion vector (ripply)
- vec2 distort2 = distort+wavef.xy*(refScale * 0.01)/max(dmod*df1, 1.0);
-
- vec4 fb = texture2D(screenTex, distort2);
-
- //mix with reflection
- // Note we actually want to use just df1, but multiplying by 0.999999 gets around an nvidia compiler bug
- color.rgb = mix(fb.rgb, refcol.rgb, df1 + 0.6);
- color.rgb *= 2.0f;
- color.rgb = scaleSoftClip(color.rgb);
-
- vec4 pos = vary_position;
-
- vec3 screenspacewavef = normalize((norm_mat*vec4(wavef, 1.0)).xyz);
-
- frag_data[0] = vec4(color.rgb, 0); // diffuse
- frag_data[1] = vec4(specular * 0.5, 0.5); // speccolor, spec
- frag_data[2] = vec4(encode_normal(screenspacewavef.xyz), 0.05, 0);// normalxy, 0, 0
+ refcol.rgb = srgb_to_linear(refcol.rgb);
+
+ //get specular component
+ float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0);
+
+ //harden specular
+ spec = pow(spec, 128.0);
+
+ //figure out distortion vector (ripply)
+ vec2 distort2 = distort+wavef.xy*(refScale*0.01)/max(dmod*df1, 1.0);
+
+ vec4 fb = texture2D(screenTex, distort2);
+
+ //mix with reflection
+ // Note we actually want to use just df1, but multiplying by 0.999999 gets around an nvidia compiler bug
+ color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.3 + 0.7);
+
+ vec4 pos = vary_position;
+
+ color.rgb += spec * specular;
+
+ color.rgb = atmosTransport(color.rgb);
+ color.rgb = scaleSoftClip(color.rgb);
+ color.a = spec * sunAngle2 * 0.88;
+
+ vec3 screenspacewavef = normalize((norm_mat*vec4(wavef, 1.0)).xyz);
+
+ frag_data[0] = vec4(color.rgb, color); // diffuse
+ frag_data[1] = vec4(0); // speccolor, spec
+ frag_data[2] = vec4(encode_normal(screenspacewavef.xyz*0.5+0.5), 0.05, 0);// normalxy, 0, 0
}