From b6b23926340d8a2ac142b02923f04624b7c6b08e Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Fri, 9 Mar 2018 21:40:46 +0000 Subject: De-duplicate water fog code and modify programs to include the shared object as necessary. --- .../shaders/class1/deferred/alphaF.glsl | 53 ++-------------------- 1 file changed, 5 insertions(+), 48 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index b9c8f34cb0..b36016529c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -98,6 +98,10 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; +#ifdef WATER_FOG +vec4 applyWaterFogView(vec3 pos, vec4 color); +#endif + vec3 srgb_to_linear(vec3 cs) { vec3 low_range = cs / vec3(12.92); @@ -219,52 +223,6 @@ float pcfShadow(sampler2DShadow shadowMap, vec4 stc) } #endif -#ifdef WATER_FOG -uniform vec4 waterPlane; -uniform vec4 waterFogColor; -uniform float waterFogDensity; -uniform float waterFogKS; - -vec4 applyWaterFogDeferred(vec3 pos, vec4 color) -{ - //normalize view vector - vec3 view = normalize(pos); - float es = -(dot(view, waterPlane.xyz)); - - //find intersection point with water plane and eye vector - - //get eye depth - float e0 = max(-waterPlane.w, 0.0); - - vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); - - //get object depth - float depth = length(pos - int_v); - - //get "thickness" of water - float l = max(depth, 0.1); - - float kd = waterFogDensity; - float ks = waterFogKS; - vec4 kc = waterFogColor; - - float F = 0.98; - - float t1 = -kd * pow(F, ks * e0); - float t2 = kd + ks * es; - float t3 = pow(F, t2*l) - 1.0; - - float L = min(t1/t2*t3, 1.0); - - float D = pow(0.98, l*kd); - - color.rgb = color.rgb * D + kc.rgb * L; - color.a = kc.a + color.a; - - return color; -} -#endif - vec3 getSunlitColor() { return vary_SunlitColor; @@ -621,9 +579,8 @@ void main() color.rgb = linear_to_srgb(color.rgb); #ifdef WATER_FOG - color = applyWaterFogDeferred(pos.xyz, color); + color = applyWaterFogView(pos.xyz, color); #endif - #endif frag_color = color; -- cgit v1.2.3 From cf460b13bee894684d0ca1bcb5bbc9eb38df719c Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Mon, 12 Mar 2018 16:24:16 +0100 Subject: De-duplicate sRGB conversion funcs from many shaders and unify on using the version that works on OSX. Add more logging to shader loading about fallbacks and loading succcess. Add frag shaders for sharing sRGB and normal encode/decode via GL shader linkage. --- .../shaders/class1/deferred/alphaF.glsl | 40 ++-------------------- 1 file changed, 3 insertions(+), 37 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index b36016529c..090aa3d27f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -102,42 +102,8 @@ uniform vec3 light_diffuse[8]; vec4 applyWaterFogView(vec3 pos, vec4 color); #endif -vec3 srgb_to_linear(vec3 cs) -{ - vec3 low_range = cs / vec3(12.92); - vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); - bvec3 lte = lessThanEqual(cs,vec3(0.04045)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lte.r ? low_range.r : high_range.r; - result.g = lte.g ? low_range.g : high_range.g; - result.b = lte.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lte); -#endif - -} - -vec3 linear_to_srgb(vec3 cl) -{ - cl = clamp(cl, vec3(0), vec3(1)); - vec3 low_range = cl * 12.92; - vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; - bvec3 lt = lessThan(cl,vec3(0.0031308)); - -#ifdef OLD_SELECT - vec3 result; - result.r = lt.r ? low_range.r : high_range.r; - result.g = lt.g ? low_range.g : high_range.g; - result.b = lt.b ? low_range.b : high_range.b; - return result; -#else - return mix(high_range, low_range, lt); -#endif - -} +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); vec2 encode_normal(vec3 n) { @@ -527,7 +493,7 @@ void main() calcAtmospherics(pos.xyz, 1.0); vec2 abnormal = encode_normal(norm.xyz); - norm.xyz = decode_normal(abnormal.xy); + norm.xyz = decode_normal(abnormal.xy); float da = dot(norm.xyz, sun_dir.xyz); -- cgit v1.2.3 From 98b2fed85fd459012ed2b859ea40a3f56d27c0e8 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Mon, 12 Mar 2018 17:52:04 +0100 Subject: De-duplicate shader code for encoding and decoding normals to/from gbuffer format. --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 090aa3d27f..47dadb4ced 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -104,23 +104,8 @@ vec4 applyWaterFogView(vec3 pos, vec4 color); vec3 srgb_to_linear(vec3 cs); vec3 linear_to_srgb(vec3 cl); - -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} - -vec3 decode_normal (vec2 enc) -{ - vec2 fenc = enc*4-2; - float f = dot(fenc,fenc); - float g = sqrt(1-f/4); - vec3 n; - n.xy = fenc*g; - n.z = 1-f/2; - return n; -} +vec3 encode_normal (vec2 enc); +vec3 decode_normal (vec2 enc); vec3 calcDirectionalLight(vec3 n, vec3 l) { -- cgit v1.2.3 From d992cff950d69b6935171fae1c304d15ee06e95a Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Mon, 12 Mar 2018 18:11:39 +0100 Subject: Fix decl mismatch in alpha shader and mark deferred shaders needing new linkage so ALM works again. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 47dadb4ced..970f39ed02 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -104,7 +104,7 @@ vec4 applyWaterFogView(vec3 pos, vec4 color); vec3 srgb_to_linear(vec3 cs); vec3 linear_to_srgb(vec3 cl); -vec3 encode_normal (vec2 enc); +vec2 encode_normal (vec3 n); vec3 decode_normal (vec2 enc); vec3 calcDirectionalLight(vec3 n, vec3 l) -- cgit v1.2.3 From 4f6682ca29cefb83ac2307657d8605f96051da19 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Mon, 12 Mar 2018 22:26:22 +0100 Subject: De-duplicate deferred shader code for atmospherics and transport. --- .../shaders/class1/deferred/alphaF.glsl | 225 ++------------------- 1 file changed, 16 insertions(+), 209 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 970f39ed02..2234ceeb53 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -39,19 +39,6 @@ out vec4 frag_color; uniform float display_gamma; uniform vec4 gamma; -uniform vec4 lightnorm; -uniform vec4 sunlight_color; -uniform vec4 ambient; -uniform vec4 blue_horizon; -uniform vec4 blue_density; -uniform float haze_horizon; -uniform float haze_density; -uniform float cloud_shadow; -uniform float density_multiplier; -uniform float distance_multiplier; -uniform float max_y; -uniform vec4 glow; -uniform float scene_light_strength; uniform mat3 env_mat; uniform mat3 ssao_effect_mat; @@ -84,12 +71,6 @@ VARYING vec3 vary_norm; VARYING vec4 vertex_color; #endif -vec3 vary_PositionEye; -vec3 vary_SunlitColor; -vec3 vary_AmblitColor; -vec3 vary_AdditiveColor; -vec3 vary_AtmosAttenuation; - uniform mat4 inv_proj; uniform vec2 screen_res; @@ -107,6 +88,12 @@ vec3 linear_to_srgb(vec3 cl); vec2 encode_normal (vec3 n); vec3 decode_normal (vec2 enc); +vec3 scaleFragSoftClip(vec3 l); +vec3 atmosFragAmbient(vec3 light, vec3 sunlit); +vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); +vec3 atmosFragAffectDirectionalLight(float light, vec3 sunlit); +void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); + vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = max(dot(n,l),0.0); @@ -174,191 +161,6 @@ float pcfShadow(sampler2DShadow shadowMap, vec4 stc) } #endif -vec3 getSunlitColor() -{ - return vary_SunlitColor; -} -vec3 getAmblitColor() -{ - return vary_AmblitColor; -} -vec3 getAdditiveColor() -{ - return vary_AdditiveColor; -} -vec3 getAtmosAttenuation() -{ - return vary_AtmosAttenuation; -} - -void setPositionEye(vec3 v) -{ - vary_PositionEye = v; -} - -void setSunlitColor(vec3 v) -{ - vary_SunlitColor = v; -} - -void setAmblitColor(vec3 v) -{ - vary_AmblitColor = v; -} - -void setAdditiveColor(vec3 v) -{ - vary_AdditiveColor = v; -} - -void setAtmosAttenuation(vec3 v) -{ - vary_AtmosAttenuation = v; -} - -void calcAtmospherics(vec3 inPositionEye, float ambFactor) { - - vec3 P = inPositionEye; - setPositionEye(P); - - vec3 tmpLightnorm = lightnorm.xyz; - - vec3 Pn = normalize(P); - float Plen = length(P); - - vec4 temp1 = vec4(0); - vec3 temp2 = vec3(0); - vec4 blue_weight; - vec4 haze_weight; - vec4 sunlight = sunlight_color; - vec4 light_atten; - - //sunlight attenuation effect (hue and brightness) due to atmosphere - //this is used later for sunlight modulation at various altitudes - light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); - //I had thought blue_density and haze_density should have equal weighting, - //but attenuation due to haze_density tends to seem too strong - - temp1 = blue_density + vec4(haze_density); - blue_weight = blue_density / temp1; - haze_weight = vec4(haze_density) / temp1; - - //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) - temp2.y = max(0.0, tmpLightnorm.y); - temp2.y = 1. / temp2.y; - sunlight *= exp( - light_atten * temp2.y); - - // main atmospheric scattering line integral - temp2.z = Plen * density_multiplier; - - // Transparency (-> temp1) - // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati - // compiler gets confused. - temp1 = exp(-temp1 * temp2.z * distance_multiplier); - - //final atmosphere attenuation factor - setAtmosAttenuation(temp1.rgb); - - //compute haze glow - //(can use temp2.x as temp because we haven't used it yet) - temp2.x = dot(Pn, tmpLightnorm.xyz); - temp2.x = 1. - temp2.x; - //temp2.x is 0 at the sun and increases away from sun - temp2.x = max(temp2.x, .03); //was glow.y - //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) - temp2.x *= glow.x; - //higher glow.x gives dimmer glow (because next step is 1 / "angle") - temp2.x = pow(temp2.x, glow.z); - //glow.z should be negative, so we're doing a sort of (1 / "angle") function - - //add "minimum anti-solar illumination" - temp2.x += .25; - - //increase ambient when there are more clouds - vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5; - - /* decrease value and saturation (that in HSV, not HSL) for occluded areas - * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html - * // The following line of code performs the equivalent of: - * float ambAlpha = tmpAmbient.a; - * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis - * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue); - * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha); - */ - tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a); - - //haze color - setAdditiveColor( - vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient) - + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x - + tmpAmbient))); - - //brightness of surface both sunlight and ambient - setSunlitColor(vec3(sunlight * .5)); - setAmblitColor(vec3(tmpAmbient * .25)); - setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1)); -} - -vec3 atmosLighting(vec3 light) -{ - light *= getAtmosAttenuation().r; - light += getAdditiveColor(); - return (2.0 * light); -} - -vec3 atmosTransport(vec3 light) { - light *= getAtmosAttenuation().r; - light += getAdditiveColor() * 2.0; - return light; -} -vec3 atmosGetDiffuseSunlightColor() -{ - return getSunlitColor(); -} - -vec3 scaleDownLight(vec3 light) -{ - return (light / vec3(scene_light_strength, scene_light_strength, scene_light_strength)); -} - -vec3 scaleUpLight(vec3 light) -{ - return (light * vec3(scene_light_strength, scene_light_strength, scene_light_strength)); -} - -vec3 atmosAmbient(vec3 light) -{ - return getAmblitColor() + (light * vec3(0.5f, 0.5f, 0.5f)); -} - -vec3 atmosAffectDirectionalLight(float lightIntensity) -{ - return getSunlitColor() * vec3(lightIntensity, lightIntensity, lightIntensity); -} - -vec3 scaleSoftClip(vec3 light) -{ - //soft clip effect: - 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; -} - -vec3 fullbrightAtmosTransport(vec3 light) { - float brightness = dot(light.rgb, vec3(0.33333)); - - return mix(atmosTransport(light.rgb), light.rgb + getAdditiveColor().rgb, brightness * brightness); -} - -vec3 fullbrightScaleSoftClip(vec3 light) -{ - //soft clip effect: - return light; -} void main() { @@ -475,7 +277,12 @@ void main() vec3 norm = vary_norm; - calcAtmospherics(pos.xyz, 1.0); + vec3 sunlit; + vec3 amblit; + vec3 additive; + vec3 atten; + + calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); vec2 abnormal = encode_normal(norm.xyz); norm.xyz = decode_normal(abnormal.xy); @@ -490,7 +297,7 @@ void main() vec4 color = vec4(0,0,0,0); - color.rgb = atmosAmbient(color.rgb); + color.rgb = atmosFragAmbient(color.rgb, amblit); color.a = final_alpha; float ambient = abs(da); @@ -499,13 +306,13 @@ void main() ambient = (1.0-ambient); color.rgb *= ambient; - color.rgb += atmosAffectDirectionalLight(final_da); + color.rgb += atmosFragAffectDirectionalLight(final_da, sunlit); color.rgb *= gamma_diff.rgb; //color.rgb = mix(diff.rgb, color.rgb, final_alpha); - color.rgb = atmosLighting(color.rgb); - color.rgb = scaleSoftClip(color.rgb); + color.rgb = atmosFragLighting(color.rgb, additive, atten); + color.rgb = scaleFragSoftClip(color.rgb); vec4 light = vec4(0,0,0,0); -- cgit v1.2.3 From 67ab0084f87c40bf31d7fadded55cc9ea6299ca2 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 12 Jun 2018 18:42:07 +0100 Subject: Fix env panel forward action. Make env panel update environment when jumping frame to frame. Add separate funcs for sun/moon vectors in various coord systems. Make haze glow only pay attention to sun (i.e. fix sun glow when moon is near horizon in daytime). --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 2234ceeb53..8dda96984e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -43,6 +43,7 @@ uniform mat3 env_mat; uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; +uniform vec3 moon_dir; #if HAS_SHADOW uniform sampler2DShadow shadowMap0; @@ -287,7 +288,10 @@ void main() vec2 abnormal = encode_normal(norm.xyz); norm.xyz = decode_normal(abnormal.xy); - float da = dot(norm.xyz, sun_dir.xyz); + float da_sun = dot(norm.xyz, sun_dir.xyz); + float da_moon = dot(norm.xyz, moon_dir.xyz); + + float da = max(da_sun, da_moon); float final_da = da; final_da = min(final_da, shadow); -- cgit v1.2.3 From facc678391417c5fa8ca659adc1d449bba2fd349 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 9 Aug 2018 22:46:47 +0100 Subject: MAINT-8951 Remove moon_dir related shader code causing sunlight shadow artifacting. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 8dda96984e..7f2c5add16 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -43,7 +43,6 @@ uniform mat3 env_mat; uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; -uniform vec3 moon_dir; #if HAS_SHADOW uniform sampler2DShadow shadowMap0; @@ -286,12 +285,9 @@ void main() calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); vec2 abnormal = encode_normal(norm.xyz); - norm.xyz = decode_normal(abnormal.xy); + norm.xyz = decode_normal(abnormal.xy); - float da_sun = dot(norm.xyz, sun_dir.xyz); - float da_moon = dot(norm.xyz, moon_dir.xyz); - - float da = max(da_sun, da_moon); + float da = dot(norm.xyz, sun_dir.xyz); float final_da = da; final_da = min(final_da, shadow); -- cgit v1.2.3 From fb335cc243581925bb772a1f10112ec493db8552 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 1 Nov 2018 18:26:24 +0100 Subject: SL-10000 fix storing of ambient value when converting legacy settings --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 7f2c5add16..1cfc19267c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -88,7 +88,7 @@ vec3 linear_to_srgb(vec3 cl); vec2 encode_normal (vec3 n); vec3 decode_normal (vec2 enc); -vec3 scaleFragSoftClip(vec3 l); +vec3 scaleSoftClipFrag(vec3 l); vec3 atmosFragAmbient(vec3 light, vec3 sunlit); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); vec3 atmosFragAffectDirectionalLight(float light, vec3 sunlit); @@ -312,7 +312,7 @@ void main() //color.rgb = mix(diff.rgb, color.rgb, final_alpha); color.rgb = atmosFragLighting(color.rgb, additive, atten); - color.rgb = scaleFragSoftClip(color.rgb); + color.rgb = scaleSoftClipFrag(color.rgb); vec4 light = vec4(0,0,0,0); -- cgit v1.2.3 From a67cf385d763325119f4d2a37beb96c9c6a80282 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 1 Nov 2018 19:04:11 +0100 Subject: Back out unintended shader changes from SL-10000 fix. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 1cfc19267c..7f2c5add16 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -88,7 +88,7 @@ vec3 linear_to_srgb(vec3 cl); vec2 encode_normal (vec3 n); vec3 decode_normal (vec2 enc); -vec3 scaleSoftClipFrag(vec3 l); +vec3 scaleFragSoftClip(vec3 l); vec3 atmosFragAmbient(vec3 light, vec3 sunlit); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); vec3 atmosFragAffectDirectionalLight(float light, vec3 sunlit); @@ -312,7 +312,7 @@ void main() //color.rgb = mix(diff.rgb, color.rgb, final_alpha); color.rgb = atmosFragLighting(color.rgb, additive, atten); - color.rgb = scaleSoftClipFrag(color.rgb); + color.rgb = scaleFragSoftClip(color.rgb); vec4 light = vec4(0,0,0,0); -- cgit v1.2.3 From 4f267a5723e7da2de36b9f2295e4942a4c8bf6c5 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 1 Nov 2018 20:28:47 +0100 Subject: SL-9994 Make shaders use consistent naming and parameter order for transport and atmospheric helpers. Share transport and gamma correction code where possible. Add lots of asserts and other validation for when things don't go as planned. Engage dumpShaderSource to get more source output with shader compilation fail. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 7f2c5add16..1cfc19267c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -88,7 +88,7 @@ vec3 linear_to_srgb(vec3 cl); vec2 encode_normal (vec3 n); vec3 decode_normal (vec2 enc); -vec3 scaleFragSoftClip(vec3 l); +vec3 scaleSoftClipFrag(vec3 l); vec3 atmosFragAmbient(vec3 light, vec3 sunlit); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); vec3 atmosFragAffectDirectionalLight(float light, vec3 sunlit); @@ -312,7 +312,7 @@ void main() //color.rgb = mix(diff.rgb, color.rgb, final_alpha); color.rgb = atmosFragLighting(color.rgb, additive, atten); - color.rgb = scaleFragSoftClip(color.rgb); + color.rgb = scaleSoftClipFrag(color.rgb); vec4 light = vec4(0,0,0,0); -- cgit v1.2.3 From 8c1aefc17c710b55ed7a72bd9de14cbed58ccd31 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 6 Nov 2018 16:38:06 +0000 Subject: Remove scaleDownLight funcs and eliminate unused copy-pasted funcs in lighting shaders. Also fix terrain response to atmospherics shaders (was failing to apply ambient on low end even when atmospherics was on). --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 7 ------- 1 file changed, 7 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 1cfc19267c..3ec2ea12da 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -94,13 +94,6 @@ vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); vec3 atmosFragAffectDirectionalLight(float light, vec3 sunlit); void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); -vec3 calcDirectionalLight(vec3 n, vec3 l) -{ - float a = max(dot(n,l),0.0); - a = pow(a, 1.0/1.3); - return vec3(a,a,a); -} - vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) { //get light vector -- cgit v1.2.3 From 2929998982f37221a58b9fa8037748a2e905f4b1 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 6 Nov 2018 19:33:04 +0000 Subject: Move to using a shared deferredUtil object for getting pos/norm from gbuffer. Eliminate 20+ callsites with copy-paste of getPosition and/or getNorm code. Make pipeline use getShadowTarget/releaseShadowTarget consistently. --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 3ec2ea12da..a325faaad7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -89,9 +89,7 @@ vec2 encode_normal (vec3 n); vec3 decode_normal (vec2 enc); vec3 scaleSoftClipFrag(vec3 l); -vec3 atmosFragAmbient(vec3 light, vec3 sunlit); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); -vec3 atmosFragAffectDirectionalLight(float light, vec3 sunlit); void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) @@ -164,6 +162,8 @@ void main() float shadow = 1.0; + vec3 norm = vary_norm; + #if HAS_SHADOW vec4 spos = pos; @@ -268,13 +268,10 @@ void main() vec4 gamma_diff = diff; diff.rgb = srgb_to_linear(diff.rgb); - vec3 norm = vary_norm; - - vec3 sunlit; - vec3 amblit; - vec3 additive; - vec3 atten; - + vec3 sunlit; + vec3 amblit; + vec3 additive; + vec3 atten; calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); vec2 abnormal = encode_normal(norm.xyz); @@ -290,7 +287,7 @@ void main() vec4 color = vec4(0,0,0,0); - color.rgb = atmosFragAmbient(color.rgb, amblit); + color.rgb = (color.rgb * 0.5) + amblit; color.a = final_alpha; float ambient = abs(da); @@ -299,7 +296,7 @@ void main() ambient = (1.0-ambient); color.rgb *= ambient; - color.rgb += atmosFragAffectDirectionalLight(final_da, sunlit); + color.rgb += (final_da * sunlit); color.rgb *= gamma_diff.rgb; //color.rgb = mix(diff.rgb, color.rgb, final_alpha); -- cgit v1.2.3 From db270df7cc00c1e2519749831e7e98c2c10e3ee6 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 9 Nov 2018 18:31:29 +0000 Subject: Back out changes causing broken shadows and other render shenanigans. --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index a325faaad7..3ec2ea12da 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -89,7 +89,9 @@ vec2 encode_normal (vec3 n); vec3 decode_normal (vec2 enc); vec3 scaleSoftClipFrag(vec3 l); +vec3 atmosFragAmbient(vec3 light, vec3 sunlit); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); +vec3 atmosFragAffectDirectionalLight(float light, vec3 sunlit); void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) @@ -162,8 +164,6 @@ void main() float shadow = 1.0; - vec3 norm = vary_norm; - #if HAS_SHADOW vec4 spos = pos; @@ -268,10 +268,13 @@ void main() vec4 gamma_diff = diff; diff.rgb = srgb_to_linear(diff.rgb); - vec3 sunlit; - vec3 amblit; - vec3 additive; - vec3 atten; + vec3 norm = vary_norm; + + vec3 sunlit; + vec3 amblit; + vec3 additive; + vec3 atten; + calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); vec2 abnormal = encode_normal(norm.xyz); @@ -287,7 +290,7 @@ void main() vec4 color = vec4(0,0,0,0); - color.rgb = (color.rgb * 0.5) + amblit; + color.rgb = atmosFragAmbient(color.rgb, amblit); color.a = final_alpha; float ambient = abs(da); @@ -296,7 +299,7 @@ void main() ambient = (1.0-ambient); color.rgb *= ambient; - color.rgb += (final_da * sunlit); + color.rgb += atmosFragAffectDirectionalLight(final_da, sunlit); color.rgb *= gamma_diff.rgb; //color.rgb = mix(diff.rgb, color.rgb, final_alpha); -- cgit v1.2.3 From a49e2b604e6b505e083e24b10e39053196d917c1 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 12 Nov 2018 15:54:53 -0800 Subject: SL-10044 SL-10045 Fix class 1 and 2 transport/gamma funcs and made usage consistent across all shaders. Fix class1\environment\waterV reverting to old d1/d2 names for wave directions. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 3ec2ea12da..f79fc012d1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -88,7 +88,7 @@ vec3 linear_to_srgb(vec3 cl); vec2 encode_normal (vec3 n); vec3 decode_normal (vec2 enc); -vec3 scaleSoftClipFrag(vec3 l); +vec3 scaleSoftClip(vec3 l); vec3 atmosFragAmbient(vec3 light, vec3 sunlit); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); vec3 atmosFragAffectDirectionalLight(float light, vec3 sunlit); @@ -305,7 +305,7 @@ void main() //color.rgb = mix(diff.rgb, color.rgb, final_alpha); color.rgb = atmosFragLighting(color.rgb, additive, atten); - color.rgb = scaleSoftClipFrag(color.rgb); + color.rgb = scaleSoftClip(color.rgb); vec4 light = vec4(0,0,0,0); -- cgit v1.2.3 From b6fa72d3c4d02527f6d118eadc9ba1ac48a297f5 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 3 Dec 2018 15:33:15 -0800 Subject: SL-10055 Modify handling of directional light to prefer sun when it is up but use moon dir/color when it is alone in the sky. Modify handling of shader in shaders to get some shadowing of ambient and nighttime shadowing. --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index f79fc012d1..07b0f2a98a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -43,6 +43,7 @@ uniform mat3 env_mat; uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; +uniform vec3 moon_dir; #if HAS_SHADOW uniform sampler2DShadow shadowMap0; @@ -280,20 +281,20 @@ void main() vec2 abnormal = encode_normal(norm.xyz); norm.xyz = decode_normal(abnormal.xy); - float da = dot(norm.xyz, sun_dir.xyz); + float sun_da = dot(norm.xyz, sun_dir.xyz); + float moon_da = dot(norm.xyz, moon_dir.xyz); - float final_da = da; + float final_da = max(sun_da, moon_da); final_da = min(final_da, shadow); - final_da = max(final_da, 0.0f); - final_da = min(final_da, 1.0f); - final_da = pow(final_da, 1.0/1.3); + final_da = clamp(final_da, 0.0f, 1.0f); + final_da = pow(final_da, 1.0/1.3); vec4 color = vec4(0,0,0,0); color.rgb = atmosFragAmbient(color.rgb, amblit); color.a = final_alpha; - float ambient = abs(da); + float ambient = abs(final_da); ambient *= 0.5; ambient *= ambient; ambient = (1.0-ambient); -- cgit v1.2.3 From 26c1430a04de585c1823569b60dc99abc798231b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 5 Dec 2018 13:08:06 -0800 Subject: Shader cleanup and consolidation of use of sRGB conversion funcs. --- .../shaders/class1/deferred/alphaF.glsl | 33 ++++++---------------- 1 file changed, 9 insertions(+), 24 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 07b0f2a98a..5e3c767460 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -84,11 +84,8 @@ uniform vec3 light_diffuse[8]; vec4 applyWaterFogView(vec3 pos, vec4 color); #endif -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cl); vec2 encode_normal (vec3 n); vec3 decode_normal (vec2 enc); - vec3 scaleSoftClip(vec3 l); vec3 atmosFragAmbient(vec3 light, vec3 sunlit); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); @@ -162,7 +159,8 @@ void main() frag *= screen_res; vec4 pos = vec4(vary_position, 1.0); - + vec3 norm = vary_norm; + float shadow = 1.0; #if HAS_SHADOW @@ -265,17 +263,10 @@ void main() float final_alpha = diff.a; #endif - - vec4 gamma_diff = diff; - diff.rgb = srgb_to_linear(diff.rgb); - - vec3 norm = vary_norm; - - vec3 sunlit; - vec3 amblit; - vec3 additive; - vec3 atten; - + vec3 sunlit; + vec3 amblit; + vec3 additive; + vec3 atten; calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); vec2 abnormal = encode_normal(norm.xyz); @@ -287,7 +278,7 @@ void main() float final_da = max(sun_da, moon_da); final_da = min(final_da, shadow); final_da = clamp(final_da, 0.0f, 1.0f); - final_da = pow(final_da, 1.0/1.3); + final_da = pow(final_da, display_gamma); vec4 color = vec4(0,0,0,0); @@ -300,8 +291,8 @@ void main() ambient = (1.0-ambient); color.rgb *= ambient; - color.rgb += atmosFragAffectDirectionalLight(final_da, sunlit); - color.rgb *= gamma_diff.rgb; + color.rgb += (final_da * sunlit); + color.rgb *= diff.rgb; //color.rgb = mix(diff.rgb, color.rgb, final_alpha); @@ -310,8 +301,6 @@ void main() vec4 light = vec4(0,0,0,0); - color.rgb = srgb_to_linear(color.rgb); - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); LIGHT_LOOP(1) @@ -326,10 +315,6 @@ void main() // color.rgb += light.rgb; - // straight to display gamma, we're post-deferred - // - color.rgb = linear_to_srgb(color.rgb); - #ifdef WATER_FOG color = applyWaterFogView(pos.xyz, color); #endif -- cgit v1.2.3 From 7e9033821a96a9d6e80b58fafb4c7da63807b9d4 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 6 Dec 2018 10:59:11 -0800 Subject: De-duplicate deferred gbuffer access for getPosition/getNorm. De-duplicate ambient occlusion shader code and move to new aoUtil.glsl Split shared shadow tap funcs into shadowUtil.glsl --- .../shaders/class1/deferred/alphaF.glsl | 319 +++++++++++---------- 1 file changed, 160 insertions(+), 159 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 5e3c767460..33e61f2062 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -94,46 +94,46 @@ void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) { - //get light vector - vec3 lv = lp.xyz-v; - - //get distance - float d = length(lv); - - float da = 1.0; - - vec3 col = vec3(0); - - if (d > 0.0 && la > 0.0 && fa > 0.0) - { - //normalize light vector - lv = normalize(lv); - - //distance attenuation - 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.0; - - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 - - //angular attenuation - da *= max(dot(n, lv), 0.0); - - float lit = max(da * dist_atten,0.0); - - col = light_col * lit * diffuse; - - // no spec for alpha shader... - } - - return max(col, vec3(0.0,0.0,0.0)); + //get light vector + vec3 lv = lp.xyz-v; + + //get distance + float d = length(lv); + + float da = 1.0; + + vec3 col = vec3(0); + + if (d > 0.0 && la > 0.0 && fa > 0.0) + { + //normalize light vector + lv = normalize(lv); + + //distance attenuation + 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.0; + + // spotlight coefficient. + float spot = max(dot(-ln, lv), is_pointlight); + da *= spot*spot; // GL_SPOT_EXPONENT=2 + + //angular attenuation + da *= max(dot(n, lv), 0.0); + + float lit = max(da * dist_atten,0.0); + + col = light_col * lit * diffuse; + + // no spec for alpha shader... + } + + return max(col, vec3(0.0,0.0,0.0)); } #if HAS_SHADOW -float pcfShadow(sampler2DShadow shadowMap, vec4 stc) +float pcfShadowLegacy(sampler2DShadow shadowMap, vec4 stc) { stc.xyz /= stc.w; stc.z += shadow_bias; @@ -152,174 +152,175 @@ float pcfShadow(sampler2DShadow shadowMap, vec4 stc) } #endif +float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float bias_scale, vec2 pos_screen); void main() { - vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; - frag *= screen_res; - - vec4 pos = vec4(vary_position, 1.0); - vec3 norm = vary_norm; + vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; + frag *= screen_res; + + vec4 pos = vec4(vary_position, 1.0); + vec3 norm = vary_norm; - float shadow = 1.0; + float shadow = 1.0; #if HAS_SHADOW - vec4 spos = pos; - - if (spos.z > -shadow_clip.w) - { - shadow = 0.0; - - vec4 lpos; - - vec4 near_split = shadow_clip*-0.75; - vec4 far_split = shadow_clip*-1.25; - vec4 transition_domain = near_split-far_split; - float weight = 0.0; - - if (spos.z < near_split.z) - { - lpos = shadow_matrix[3]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap3, lpos)*w; - weight += w; - shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); - } - - if (spos.z < near_split.y && spos.z > far_split.z) - { - lpos = shadow_matrix[2]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.y, 0.0)/transition_domain.y; - w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; - shadow += pcfShadow(shadowMap2, lpos)*w; - weight += w; - } - - if (spos.z < near_split.x && spos.z > far_split.y) - { - lpos = shadow_matrix[1]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.x, 0.0)/transition_domain.x; - w -= max(near_split.y-spos.z, 0.0)/transition_domain.y; - shadow += pcfShadow(shadowMap1, lpos)*w; - weight += w; - } - - if (spos.z > far_split.x) - { - lpos = shadow_matrix[0]*spos; - - float w = 1.0; - w -= max(near_split.x-spos.z, 0.0)/transition_domain.x; - - shadow += pcfShadow(shadowMap0, lpos)*w; - weight += w; - } - - - shadow /= weight; - } - else - { - shadow = 1.0; - } + vec4 spos = pos; + + if (spos.z > -shadow_clip.w) + { + shadow = 0.0; + + vec4 lpos; + + vec4 near_split = shadow_clip*-0.75; + vec4 far_split = shadow_clip*-1.25; + vec4 transition_domain = near_split-far_split; + float weight = 0.0; + + if (spos.z < near_split.z) + { + lpos = shadow_matrix[3]*spos; + + float w = 1.0; + w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; + shadow += pcfShadowLegacy(shadowMap3, lpos)*w; + weight += w; + shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); + } + + if (spos.z < near_split.y && spos.z > far_split.z) + { + lpos = shadow_matrix[2]*spos; + + float w = 1.0; + w -= max(spos.z-far_split.y, 0.0)/transition_domain.y; + w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; + shadow += pcfShadowLegacy(shadowMap2, lpos)*w; + weight += w; + } + + if (spos.z < near_split.x && spos.z > far_split.y) + { + lpos = shadow_matrix[1]*spos; + + float w = 1.0; + w -= max(spos.z-far_split.x, 0.0)/transition_domain.x; + w -= max(near_split.y-spos.z, 0.0)/transition_domain.y; + shadow += pcfShadowLegacy(shadowMap1, lpos)*w; + weight += w; + } + + if (spos.z > far_split.x) + { + lpos = shadow_matrix[0]*spos; + + float w = 1.0; + w -= max(near_split.x-spos.z, 0.0)/transition_domain.x; + + shadow += pcfShadowLegacy(shadowMap0, lpos)*w; + weight += w; + } + + + shadow /= weight; + } + else + { + shadow = 1.0; + } #endif #ifdef USE_INDEXED_TEX - vec4 diff = diffuseLookup(vary_texcoord0.xy); + vec4 diff = diffuseLookup(vary_texcoord0.xy); #else - vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); + vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif #ifdef FOR_IMPOSTOR - vec4 color; - color.rgb = diff.rgb; - color.a = 1.0; + vec4 color; + color.rgb = diff.rgb; + color.a = 1.0; #ifdef USE_VERTEX_COLOR - float final_alpha = diff.a * vertex_color.a; - diff.rgb *= vertex_color.rgb; + float final_alpha = diff.a * vertex_color.a; + diff.rgb *= vertex_color.rgb; #else - float final_alpha = diff.a; + float final_alpha = diff.a; #endif - - // Insure we don't pollute depth with invis pixels in impostor rendering - // - if (final_alpha < 0.01) - { - discard; - } + + // Insure we don't pollute depth with invis pixels in impostor rendering + // + if (final_alpha < 0.01) + { + discard; + } #else - + #ifdef USE_VERTEX_COLOR - float final_alpha = diff.a * vertex_color.a; - diff.rgb *= vertex_color.rgb; + float final_alpha = diff.a * vertex_color.a; + diff.rgb *= vertex_color.rgb; #else - float final_alpha = diff.a; + float final_alpha = diff.a; #endif vec3 sunlit; vec3 amblit; vec3 additive; vec3 atten; - calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); + calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); - vec2 abnormal = encode_normal(norm.xyz); - norm.xyz = decode_normal(abnormal.xy); + vec2 abnormal = encode_normal(norm.xyz); + norm.xyz = decode_normal(abnormal.xy); - float sun_da = dot(norm.xyz, sun_dir.xyz); - float moon_da = dot(norm.xyz, moon_dir.xyz); + float sun_da = dot(norm.xyz, sun_dir.xyz); + float moon_da = dot(norm.xyz, moon_dir.xyz); float final_da = max(sun_da, moon_da); final_da = min(final_da, shadow); final_da = clamp(final_da, 0.0f, 1.0f); - final_da = pow(final_da, display_gamma); + final_da = pow(final_da, display_gamma); - vec4 color = vec4(0,0,0,0); + vec4 color = vec4(0,0,0,0); - color.rgb = atmosFragAmbient(color.rgb, amblit); - color.a = final_alpha; + color.rgb = atmosFragAmbient(color.rgb, amblit); + color.a = final_alpha; - float ambient = abs(final_da); - ambient *= 0.5; - ambient *= ambient; - ambient = (1.0-ambient); + float ambient = abs(final_da); + ambient *= 0.5; + ambient *= ambient; + ambient = (1.0-ambient); - color.rgb *= ambient; - color.rgb += (final_da * sunlit); - color.rgb *= diff.rgb; + color.rgb *= ambient; + color.rgb += (final_da * sunlit); + color.rgb *= diff.rgb; - //color.rgb = mix(diff.rgb, color.rgb, final_alpha); - - color.rgb = atmosFragLighting(color.rgb, additive, atten); - color.rgb = scaleSoftClip(color.rgb); + //color.rgb = mix(diff.rgb, color.rgb, final_alpha); + + color.rgb = atmosFragLighting(color.rgb, additive, atten); + color.rgb = scaleSoftClip(color.rgb); - vec4 light = vec4(0,0,0,0); + vec4 light = vec4(0,0,0,0); #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, 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) + LIGHT_LOOP(1) + LIGHT_LOOP(2) + LIGHT_LOOP(3) + LIGHT_LOOP(4) + LIGHT_LOOP(5) + LIGHT_LOOP(6) + LIGHT_LOOP(7) - // keep it linear - // - color.rgb += light.rgb; + // keep it linear + // + color.rgb += light.rgb; #ifdef WATER_FOG - color = applyWaterFogView(pos.xyz, color); + color = applyWaterFogView(pos.xyz, color); #endif #endif - frag_color = color; + frag_color = color; } -- cgit v1.2.3 From c007e1197c521a1b48736cbba29e7c7dadf39c20 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 4 Jan 2019 13:26:47 -0800 Subject: Convert to using shared shadow sampling function (reduce duplicated code blocks in several shaders). --- .../shaders/class1/deferred/alphaF.glsl | 93 +--------------------- 1 file changed, 3 insertions(+), 90 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 33e61f2062..9670b39fdb 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -92,6 +92,8 @@ vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); vec3 atmosFragAffectDirectionalLight(float light, vec3 sunlit); void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); +float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); + vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) { //get light vector @@ -132,28 +134,6 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec return max(col, vec3(0.0,0.0,0.0)); } -#if HAS_SHADOW -float pcfShadowLegacy(sampler2DShadow shadowMap, vec4 stc) -{ - stc.xyz /= stc.w; - stc.z += shadow_bias; - - stc.x = floor(stc.x*shadow_res.x + fract(stc.y*shadow_res.y*12345))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here - - float cs = shadow2D(shadowMap, stc.xyz).x; - float shadow = cs; - - shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; - shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - - return shadow*0.2; -} -#endif - -float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float bias_scale, vec2 pos_screen); - void main() { vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; @@ -162,74 +142,7 @@ void main() vec4 pos = vec4(vary_position, 1.0); vec3 norm = vary_norm; - float shadow = 1.0; - -#if HAS_SHADOW - vec4 spos = pos; - - if (spos.z > -shadow_clip.w) - { - shadow = 0.0; - - vec4 lpos; - - vec4 near_split = shadow_clip*-0.75; - vec4 far_split = shadow_clip*-1.25; - vec4 transition_domain = near_split-far_split; - float weight = 0.0; - - if (spos.z < near_split.z) - { - lpos = shadow_matrix[3]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; - shadow += pcfShadowLegacy(shadowMap3, lpos)*w; - weight += w; - shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); - } - - if (spos.z < near_split.y && spos.z > far_split.z) - { - lpos = shadow_matrix[2]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.y, 0.0)/transition_domain.y; - w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; - shadow += pcfShadowLegacy(shadowMap2, lpos)*w; - weight += w; - } - - if (spos.z < near_split.x && spos.z > far_split.y) - { - lpos = shadow_matrix[1]*spos; - - float w = 1.0; - w -= max(spos.z-far_split.x, 0.0)/transition_domain.x; - w -= max(near_split.y-spos.z, 0.0)/transition_domain.y; - shadow += pcfShadowLegacy(shadowMap1, lpos)*w; - weight += w; - } - - if (spos.z > far_split.x) - { - lpos = shadow_matrix[0]*spos; - - float w = 1.0; - w -= max(near_split.x-spos.z, 0.0)/transition_domain.x; - - shadow += pcfShadowLegacy(shadowMap0, lpos)*w; - weight += w; - } - - - shadow /= weight; - } - else - { - shadow = 1.0; - } -#endif + float shadow = sampleDirectionalShadow(pos.xyz, norm.xyz, frag); #ifdef USE_INDEXED_TEX vec4 diff = diffuseLookup(vary_texcoord0.xy); -- cgit v1.2.3 From b865fc88e575e39111418a329362eada368445cd Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 8 Jan 2019 17:20:56 -0800 Subject: Fix broken distortion map rendering (was culling everything). Clean up deferred\alpha shader to allow re-entrant graphics switching (link error on 2nd compile/link of deferred shaders). Clean up some uses of pragma(optimize,...). --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 9670b39fdb..132364882b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -45,20 +45,6 @@ uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; uniform vec3 moon_dir; -#if HAS_SHADOW -uniform sampler2DShadow shadowMap0; -uniform sampler2DShadow shadowMap1; -uniform sampler2DShadow shadowMap2; -uniform sampler2DShadow shadowMap3; - -uniform vec2 shadow_res; - -uniform mat4 shadow_matrix[6]; -uniform vec4 shadow_clip; -uniform float shadow_bias; - -#endif - #ifdef USE_DIFFUSE_TEX uniform sampler2D diffuseMap; #endif -- cgit v1.2.3 From acbc7f4cddd6ad999c2bc7690c10b85a414a8102 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 30 Jan 2019 08:37:07 -0800 Subject: SL-10415, SL-10434 Further tweaking of directional shadow sampling to balance between peter-panning and shadow acne. Move stars to just this side of the sky some to reduce parallax. Remove decodeNormF and uses of decode_normal in favor of unified use of getNorm (try to help the Intel HD x000 compiler learn to link correctly). --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 132364882b..f1b7a1312f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -71,7 +71,6 @@ vec4 applyWaterFogView(vec3 pos, vec4 color); #endif vec2 encode_normal (vec3 n); -vec3 decode_normal (vec2 enc); vec3 scaleSoftClip(vec3 l); vec3 atmosFragAmbient(vec3 light, vec3 sunlit); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); @@ -170,7 +169,6 @@ void main() calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); vec2 abnormal = encode_normal(norm.xyz); - norm.xyz = decode_normal(abnormal.xy); float sun_da = dot(norm.xyz, sun_dir.xyz); float moon_da = dot(norm.xyz, moon_dir.xyz); -- cgit v1.2.3 From 9a007cceeffb1b960ba495cd0e3d592698a52a99 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 4 Feb 2019 12:56:11 -0800 Subject: SL-10461 Pass projector ambiance as the .w element of the light_attenuation uniform so that alpha shader can emulate the behavior of proper spot projectors. --- .../shaders/class1/deferred/alphaF.glsl | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index f1b7a1312f..772859576f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -63,7 +63,7 @@ uniform vec2 screen_res; uniform vec4 light_position[8]; uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; +uniform vec4 light_attenuation[8]; uniform vec3 light_diffuse[8]; #ifdef WATER_FOG @@ -79,7 +79,7 @@ void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); -vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) +vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance) { //get light vector vec3 lv = lp.xyz-v; @@ -91,13 +91,16 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec vec3 col = vec3(0); - if (d > 0.0 && la > 0.0 && fa > 0.0) + if (d > 0.0 && fa > 0.0) { //normalize light vector lv = normalize(lv); - + vec3 norm = normalize(n); + + da = max(0.0, dot(norm, lv)); + //distance attenuation - float dist = d/la; + float dist = d; float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; @@ -106,17 +109,17 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec float spot = max(dot(-ln, lv), is_pointlight); da *= spot*spot; // GL_SPOT_EXPONENT=2 - //angular attenuation - da *= max(dot(n, lv), 0.0); - float lit = max(da * dist_atten,0.0); - col = light_col * lit * diffuse; + float 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 * light_col * diffuse; // no spec for alpha shader... } - - return max(col, vec3(0.0,0.0,0.0)); + col = max(col, vec3(0)); + return col; } void main() @@ -199,7 +202,7 @@ void main() vec4 light = vec4(0,0,0,0); - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w); LIGHT_LOOP(1) LIGHT_LOOP(2) -- cgit v1.2.3 From f8171a909cb2a18fcca47f6a0317919ece802aef Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 6 Feb 2019 10:07:24 -0800 Subject: SL-10461 Another attempt at getting approximage handling of projector ambiance in the alpha object shader. This will not be a perfect match for non-transparent objects but should be close enough. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 772859576f..9883ece648 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -86,9 +86,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec //get distance float d = length(lv); - float da = 1.0; - vec3 col = vec3(0); if (d > 0.0 && fa > 0.0) @@ -100,7 +98,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec da = max(0.0, dot(norm, lv)); //distance attenuation - float dist = d; + 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.0; @@ -109,9 +107,11 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec float spot = max(dot(-ln, lv), is_pointlight); da *= spot*spot; // GL_SPOT_EXPONENT=2 + // to match spotLight (but not multiSpotLight) *sigh* float lit = max(da * dist_atten,0.0); + col = lit * light_col * diffuse; - float amb_da = (da*da*0.5 + 0.5) * ambiance; + float amb_da = (da*da*0.5 + 0.25) * ambiance; amb_da *= dist_atten; amb_da = min(amb_da, 1.0f - lit); -- cgit v1.2.3 From 65927e0a76aaf8ff4dc268acdb12007265ff3a14 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 13 Feb 2019 13:09:14 -0800 Subject: SL-10181, SL-10546 Fix distortion map rendering in deferred mode not including underwater fog effects. Fix distortion map rendering not including post-deferred content at all. Fix distortion map rendering not including anything but sky when camera is underwater. Update sun_up_factor/sunmoon_glow_factor uniforms even when sun disc isn't in use. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 9883ece648..1ba10fa8b7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -215,10 +215,10 @@ void main() // keep it linear // color.rgb += light.rgb; +#endif #ifdef WATER_FOG color = applyWaterFogView(pos.xyz, color); -#endif #endif frag_color = color; -- cgit v1.2.3 From bc86ad9523460ae883ea840d7b11c9de542a14aa Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 22 Feb 2019 17:03:11 -0800 Subject: SL-5186 Add ambiance handling to the light loop in the forward incarnation of materialF and tweak alphaF to match lighing of material alpha-blend objects and non-ALM rendering. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 1ba10fa8b7..948a195b7a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -60,7 +60,7 @@ VARYING vec4 vertex_color; uniform mat4 inv_proj; uniform vec2 screen_res; - +uniform int sun_up_factor; uniform vec4 light_position[8]; uniform vec3 light_direction[8]; uniform vec4 light_attenuation[8]; @@ -173,13 +173,13 @@ void main() vec2 abnormal = encode_normal(norm.xyz); - float sun_da = dot(norm.xyz, sun_dir.xyz); - float moon_da = dot(norm.xyz, moon_dir.xyz); + vec3 light_dir = (sun_up_factor == 1) ? sun_dir: moon_dir; + float da = dot(norm.xyz, light_dir.xyz); - float final_da = max(sun_da, moon_da); + float final_da = da; final_da = min(final_da, shadow); final_da = clamp(final_da, 0.0f, 1.0f); - final_da = pow(final_da, display_gamma); + final_da = pow(final_da, 1.0/display_gamma); vec4 color = vec4(0,0,0,0); -- cgit v1.2.3 From f9896dc100ccd6dd2d92610cb4f71f61284f76a6 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 26 Feb 2019 10:09:32 -0800 Subject: SL-5186, SL-10612 Fix lighting and gamma correction differences between deferred and forward rendering including materials objects. Verify 10612 and 10500 remain fixed. Make sure all necessary deferred shaders get the atmospheric uniform updates for doing frag-based atmospherics. --- .../shaders/class1/deferred/alphaF.glsl | 42 ++++++++++++---------- 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 948a195b7a..df0ff4e654 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -70,16 +70,17 @@ uniform vec3 light_diffuse[8]; vec4 applyWaterFogView(vec3 pos, vec4 color); #endif +vec3 srgb_to_linear(vec3 c); +vec3 linear_to_srgb(vec3 c); + vec2 encode_normal (vec3 n); -vec3 scaleSoftClip(vec3 l); -vec3 atmosFragAmbient(vec3 light, vec3 sunlit); +vec3 scaleSoftClipFrag(vec3 l); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); -vec3 atmosFragAffectDirectionalLight(float light, vec3 sunlit); void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); -vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance) +vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance ,float shadow) { //get light vector vec3 lv = lp.xyz-v; @@ -96,23 +97,25 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec vec3 norm = normalize(n); da = max(0.0, dot(norm, lv)); + da = clamp(da, 0.0, 1.0); //distance attenuation 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.0; // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); da *= spot*spot; // GL_SPOT_EXPONENT=2 // to match spotLight (but not multiSpotLight) *sigh* - float lit = max(da * dist_atten,0.0); + float lit = max(min(da, shadow) * dist_atten,0.0); col = lit * light_col * diffuse; - float amb_da = (da*da*0.5 + 0.25) * ambiance; + float amb_da = ambiance; amb_da *= dist_atten; + amb_da += (da*0.5) * ambiance; + amb_da += (da*da*0.5 + 0.5) * ambiance; amb_da = min(amb_da, 1.0f - lit); col.rgb += amb_da * light_col * diffuse; @@ -165,6 +168,8 @@ void main() float final_alpha = diff.a; #endif + diff.rgb = srgb_to_linear(diff.rgb); + vec3 sunlit; vec3 amblit; vec3 additive; @@ -175,34 +180,32 @@ void main() vec3 light_dir = (sun_up_factor == 1) ? sun_dir: moon_dir; float da = dot(norm.xyz, light_dir.xyz); - - float final_da = da; - final_da = min(final_da, shadow); - final_da = clamp(final_da, 0.0f, 1.0f); - final_da = pow(final_da, 1.0/display_gamma); + da = clamp(da, 0.0, 1.0); vec4 color = vec4(0,0,0,0); - color.rgb = atmosFragAmbient(color.rgb, amblit); + color.rgb = amblit; color.a = final_alpha; - float ambient = abs(final_da); + float ambient = abs(da); ambient *= 0.5; ambient *= ambient; - ambient = (1.0-ambient); + ambient = 1.0 - ambient * smoothstep(0.0, 0.3, shadow); + + vec3 sun_contrib = min(da, shadow) * sunlit; color.rgb *= ambient; - color.rgb += (final_da * sunlit); + color.rgb += sun_contrib; color.rgb *= diff.rgb; //color.rgb = mix(diff.rgb, color.rgb, final_alpha); color.rgb = atmosFragLighting(color.rgb, additive, atten); - color.rgb = scaleSoftClip(color.rgb); + color.rgb = scaleSoftClipFrag(color.rgb); vec4 light = vec4(0,0,0,0); - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w, shadow); LIGHT_LOOP(1) LIGHT_LOOP(2) @@ -215,6 +218,9 @@ void main() // keep it linear // color.rgb += light.rgb; + + color.rgb = linear_to_srgb(color.rgb); + #endif #ifdef WATER_FOG -- cgit v1.2.3 From 6f820163ce3a42eb90edba6f3907952e7d83517c Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 26 Feb 2019 14:51:02 -0800 Subject: SL-10566 part the first Tie using deferred rendering in water reflection/distortion map generation to debug var again (claw back some performance lost to doing post-deferred in water map generation). Edit softenLightF for class1/class2 to make them comparable again. --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index df0ff4e654..f570908b45 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -76,7 +76,16 @@ vec3 linear_to_srgb(vec3 c); vec2 encode_normal (vec3 n); vec3 scaleSoftClipFrag(vec3 l); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); + +#if defined(VERT_ATMOSPHERICS) +vec3 getSunlitColor(); +vec3 getAmblitColor(); +vec3 getAdditiveColor(); +vec3 getAtmosAttenuation(); +void calcAtmospherics(vec3 inPositionEye, float ambFactor); +#else void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); +#endif float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); @@ -174,7 +183,15 @@ void main() vec3 amblit; vec3 additive; vec3 atten; + +#if VERT_ATMOSPHERICS + sunlit = getSunlitColor(); + amblit = getAmblitColor(); + additive = getAdditiveColor(); + atten = getAtmosAttenuation(); +#else calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); +#endif vec2 abnormal = encode_normal(norm.xyz); -- cgit v1.2.3 From 2b9943d6f2a02423f555d46e8100a68483f26244 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 26 Feb 2019 15:07:33 -0800 Subject: Fix up ifdefs to make OSX shader compiler happy. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index f570908b45..99988646c0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -184,7 +184,7 @@ void main() vec3 additive; vec3 atten; -#if VERT_ATMOSPHERICS +#if deifned(VERT_ATMOSPHERICS) sunlit = getSunlitColor(); amblit = getAmblitColor(); additive = getAdditiveColor(); -- cgit v1.2.3 From 4f1e39d4a4e75326a469576c16488bc62396c618 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 26 Feb 2019 16:13:32 -0800 Subject: Fix ifdef in alphaF. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 99988646c0..6e1f0f201b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -184,7 +184,7 @@ void main() vec3 additive; vec3 atten; -#if deifned(VERT_ATMOSPHERICS) +#if defined(VERT_ATMOSPHERICS) sunlit = getSunlitColor(); amblit = getAmblitColor(); additive = getAdditiveColor(); -- cgit v1.2.3 From 4c3050a3953153aa8753fc10706ad2ef464f3e3d Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sun, 3 Mar 2019 10:42:19 -0800 Subject: SL-10664, SL-10666 Fix up culling issues from perf work and fix Depth of Field rendering to get depth values properly. Baseline for performance work. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 6e1f0f201b..9191787273 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -118,7 +118,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec da *= spot*spot; // GL_SPOT_EXPONENT=2 // to match spotLight (but not multiSpotLight) *sigh* - float lit = max(min(da, shadow) * dist_atten,0.0); + float lit = max(da * dist_atten,0.0); col = lit * light_col * diffuse; float amb_da = ambiance; -- cgit v1.2.3 From 423fa1ac297e39c9395f45490278b8751188b6db Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 7 Mar 2019 10:56:26 -0800 Subject: SL-10618, SL-10698 Fix reflection/distortion map culling planes again. Fix broken handling of shadow disables in ALM forward shaders. --- .../shaders/class1/deferred/alphaF.glsl | 23 +++++++--------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 9191787273..a5076ef609 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -77,17 +77,11 @@ vec2 encode_normal (vec3 n); vec3 scaleSoftClipFrag(vec3 l); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); -#if defined(VERT_ATMOSPHERICS) -vec3 getSunlitColor(); -vec3 getAmblitColor(); -vec3 getAdditiveColor(); -vec3 getAtmosAttenuation(); -void calcAtmospherics(vec3 inPositionEye, float ambFactor); -#else void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); -#endif +#ifdef HAS_SHADOW float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); +#endif vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance ,float shadow) { @@ -142,7 +136,11 @@ void main() vec4 pos = vec4(vary_position, 1.0); vec3 norm = vary_norm; - float shadow = sampleDirectionalShadow(pos.xyz, norm.xyz, frag); + float shadow = 1.0f; + +#ifdef HAS_SHADOW + shadow = sampleDirectionalShadow(pos.xyz, norm.xyz, frag); +#endif #ifdef USE_INDEXED_TEX vec4 diff = diffuseLookup(vary_texcoord0.xy); @@ -184,14 +182,7 @@ void main() vec3 additive; vec3 atten; -#if defined(VERT_ATMOSPHERICS) - sunlit = getSunlitColor(); - amblit = getAmblitColor(); - additive = getAdditiveColor(); - atten = getAtmosAttenuation(); -#else calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); -#endif vec2 abnormal = encode_normal(norm.xyz); -- cgit v1.2.3 From c10754ea6d47f88f3499f86543a7d6c7d439fda6 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 13 Mar 2019 13:56:04 -0700 Subject: SL-10741 Remove shadow influence on ambient term causing inverted lighting in extreme setups. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index a5076ef609..251ec7d785 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -198,7 +198,7 @@ void main() float ambient = abs(da); ambient *= 0.5; ambient *= ambient; - ambient = 1.0 - ambient * smoothstep(0.0, 0.3, shadow); + ambient = 1.0 - ambient; vec3 sun_contrib = min(da, shadow) * sunlit; -- cgit v1.2.3 From a10ec81e82d79bd79d5b058fda1b370073bfb480 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 15 Mar 2019 08:13:04 -0700 Subject: SL-10743, SL-10744 Don't step on SUNLIGHT_COLOR uniform w/ syncLightState competing set. Put drawpool alpha render loop lighting setup changes as they were (this will give back some performance and possibly require reopening 10566). --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 251ec7d785..fdbf5ec840 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -118,7 +118,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec float amb_da = ambiance; amb_da *= dist_atten; amb_da += (da*0.5) * ambiance; - amb_da += (da*da*0.5 + 0.5) * ambiance; + amb_da += (da*da*0.5 + 0.25) * ambiance; amb_da = min(amb_da, 1.0f - lit); col.rgb += amb_da * light_col * diffuse; @@ -228,7 +228,6 @@ void main() color.rgb += light.rgb; color.rgb = linear_to_srgb(color.rgb); - #endif #ifdef WATER_FOG -- cgit v1.2.3 From fb7c887a5e09024731038eef0a57e5f1e8e08b2e Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 26 Mar 2019 10:28:25 -0700 Subject: More consistent lighting across ALM/non-ALM/deferred/forward rendering. --- .../newview/app_settings/shaders/class1/deferred/alphaF.glsl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index fdbf5ec840..dac93cee3a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -100,12 +100,14 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec vec3 norm = normalize(n); da = max(0.0, dot(norm, lv)); + //da = min(da, shadow); da = clamp(da, 0.0, 1.0); //distance attenuation 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.0f; // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); @@ -113,12 +115,16 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec // to match spotLight (but not multiSpotLight) *sigh* float lit = max(da * dist_atten,0.0); + + // the shadowmap is wrong for alpha objects + // since we only have 2 maps but N spots + //col = lit * light_col * diffuse * shadow; col = lit * light_col * diffuse; float amb_da = ambiance; + amb_da += (da*0.5) * (1.0 - shadow) * ambiance; + amb_da += (da*da*0.5 + 0.5) * (1.0 - shadow) * ambiance; amb_da *= dist_atten; - amb_da += (da*0.5) * ambiance; - amb_da += (da*da*0.5 + 0.25) * ambiance; amb_da = min(amb_da, 1.0f - lit); col.rgb += amb_da * light_col * diffuse; @@ -189,6 +195,7 @@ void main() vec3 light_dir = (sun_up_factor == 1) ? sun_dir: moon_dir; float da = dot(norm.xyz, light_dir.xyz); da = clamp(da, 0.0, 1.0); + da = pow(da, 1.0 / 1.3); vec4 color = vec4(0,0,0,0); -- cgit v1.2.3 From c699ee9a7f102aa541dcc102e8fa1de2d6c55bde Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 4 Apr 2019 17:19:59 -0700 Subject: SL-10854 Clamp ambient contrib to get darker shadows. New PCF sampling func. --- .../newview/app_settings/shaders/class1/deferred/alphaF.glsl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index dac93cee3a..d560a49c1f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -194,8 +194,12 @@ void main() vec3 light_dir = (sun_up_factor == 1) ? sun_dir: moon_dir; float da = dot(norm.xyz, light_dir.xyz); - da = clamp(da, 0.0, 1.0); - da = pow(da, 1.0 / 1.3); + + float final_da = da; + final_da = min(final_da, shadow); + final_da = max(final_da, 0.0f); + final_da = min(final_da, 1.0f); + final_da = pow(final_da, 1.0/1.3); vec4 color = vec4(0,0,0,0); @@ -205,9 +209,9 @@ void main() float ambient = abs(da); ambient *= 0.5; ambient *= ambient; - ambient = 1.0 - ambient; + ambient = 1.0 - max(0.9, ambient); - vec3 sun_contrib = min(da, shadow) * sunlit; + vec3 sun_contrib = final_da * sunlit; color.rgb *= ambient; color.rgb += sun_contrib; -- cgit v1.2.3 From 09bb0336f15027e907fbd28130b4ffda28a830cd Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 5 Apr 2019 09:19:46 -0700 Subject: SL-10854 part 2 Clamp ambient to keep shadows dark. Apply min with shadow value after we've pow'd by light gamma consistently between forward and deferred. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index d560a49c1f..1bc576a4ec 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -196,9 +196,7 @@ void main() float da = dot(norm.xyz, light_dir.xyz); float final_da = da; - final_da = min(final_da, shadow); - final_da = max(final_da, 0.0f); - final_da = min(final_da, 1.0f); + final_da = clamp(final_da, 0.0f, 1.0f); final_da = pow(final_da, 1.0/1.3); vec4 color = vec4(0,0,0,0); @@ -209,9 +207,10 @@ void main() float ambient = abs(da); ambient *= 0.5; ambient *= ambient; - ambient = 1.0 - max(0.9, ambient); + ambient = max(0.9, ambient); // keeps shadows dark + ambient = 1.0 - ambient; - vec3 sun_contrib = final_da * sunlit; + vec3 sun_contrib = min(final_da, shadow) * sunlit; color.rgb *= ambient; color.rgb += sun_contrib; -- cgit v1.2.3 From fff2aecf7f96de9e53620887210487a48dd45580 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 5 Apr 2019 14:35:55 -0700 Subject: SL-10821 Fix directionality of da and preserve bumps on completely shadowed areas. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 1bc576a4ec..68a735e813 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -194,7 +194,8 @@ void main() vec3 light_dir = (sun_up_factor == 1) ? sun_dir: moon_dir; float da = dot(norm.xyz, light_dir.xyz); - + da = clamp(da, -1.0, 1.0); + float final_da = da; final_da = clamp(final_da, 0.0f, 1.0f); final_da = pow(final_da, 1.0/1.3); @@ -204,13 +205,13 @@ void main() color.rgb = amblit; color.a = final_alpha; - float ambient = abs(da); + float ambient = da; ambient *= 0.5; ambient *= ambient; ambient = max(0.9, ambient); // keeps shadows dark ambient = 1.0 - ambient; - vec3 sun_contrib = min(final_da, shadow) * sunlit; + vec3 sun_contrib = mix(final_da, min(final_da, shadow), 0.1) * sunlit; color.rgb *= ambient; color.rgb += sun_contrib; -- cgit v1.2.3 From fe589170d3faa5ca681baca7b9a664e2d851cd6e Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 5 Apr 2019 15:54:21 -0700 Subject: SL-10896 Fix deferred water soften prog lightnorm getting stomped with rotated lightnorm, because it's a water shader and needs water atmo uniform values, but it's a deferred lighting shader that needs not-so-rotated lightnorms. Make sunlight_color not get auto-updated so we can get the correct value from mSunDiffuse. Remove mix to preserve bumps as it was washing out shadows. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 68a735e813..6e693bd33b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -211,7 +211,7 @@ void main() ambient = max(0.9, ambient); // keeps shadows dark ambient = 1.0 - ambient; - vec3 sun_contrib = mix(final_da, min(final_da, shadow), 0.1) * sunlit; + vec3 sun_contrib = min(final_da, shadow) * sunlit; color.rgb *= ambient; color.rgb += sun_contrib; -- cgit v1.2.3 From 282f91aaf38cd108ee96475e351623ae203c57a6 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 8 Apr 2019 10:34:59 -0700 Subject: Make ambient clamping consistent between class1/2 deferred lighting and forward rendering. Add decls for intermediate lighting values for debug. --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 6e693bd33b..fb24927b26 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -190,7 +190,7 @@ void main() calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); - vec2 abnormal = encode_normal(norm.xyz); + vec2 abnormal = encode_normal(norm.xyz); vec3 light_dir = (sun_up_factor == 1) ? sun_dir: moon_dir; float da = dot(norm.xyz, light_dir.xyz); @@ -208,15 +208,23 @@ void main() float ambient = da; ambient *= 0.5; ambient *= ambient; - ambient = max(0.9, ambient); // keeps shadows dark + ambient = max(0.66, ambient); // keeps shadows dark ambient = 1.0 - ambient; vec3 sun_contrib = min(final_da, shadow) * sunlit; color.rgb *= ambient; + +vec3 post_ambient = color.rgb; + color.rgb += sun_contrib; + +vec3 post_sunlight = color.rgb; + color.rgb *= diff.rgb; +vec3 post_diffuse = color.rgb; + //color.rgb = mix(diff.rgb, color.rgb, final_alpha); color.rgb = atmosFragLighting(color.rgb, additive, atten); @@ -224,6 +232,8 @@ void main() vec4 light = vec4(0,0,0,0); +vec3 prelight_linearish_maybe = color.rgb; + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w, shadow); LIGHT_LOOP(1) @@ -238,13 +248,19 @@ void main() // color.rgb += light.rgb; +vec3 postlight_linear = color.rgb; + +color.rgb = prelight_linearish_maybe; + color.rgb = linear_to_srgb(color.rgb); + #endif #ifdef WATER_FOG color = applyWaterFogView(pos.xyz, color); #endif + frag_color = color; } -- cgit v1.2.3 From 996d441ddc64996711b5a4eb3135607686992b86 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 8 Apr 2019 16:53:57 -0700 Subject: SL-5186 Make projector ambiance unshadowed in both forward and deferred for consistency. --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index fb24927b26..4b99592dbb 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -99,8 +99,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec lv = normalize(lv); vec3 norm = normalize(n); - da = max(0.0, dot(norm, lv)); - //da = min(da, shadow); + da = dot(norm, lv); da = clamp(da, 0.0, 1.0); //distance attenuation @@ -116,18 +115,15 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec // to match spotLight (but not multiSpotLight) *sigh* float lit = max(da * dist_atten,0.0); - // the shadowmap is wrong for alpha objects - // since we only have 2 maps but N spots - //col = lit * light_col * diffuse * shadow; - col = lit * light_col * diffuse; + col = lit * light_col * diffuse * shadow; float amb_da = ambiance; - amb_da += (da*0.5) * (1.0 - shadow) * ambiance; + amb_da += (da*0.5+0.5) * (1.0 - shadow) * ambiance; amb_da += (da*da*0.5 + 0.5) * (1.0 - shadow) * ambiance; amb_da *= dist_atten; amb_da = min(amb_da, 1.0f - lit); - col.rgb += amb_da * light_col * diffuse; + col.rgb += amb_da * 0.5 * light_col * diffuse; // no spec for alpha shader... } col = max(col, vec3(0)); @@ -234,7 +230,7 @@ vec3 post_diffuse = color.rgb; vec3 prelight_linearish_maybe = color.rgb; - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w, shadow); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w, 1.0); LIGHT_LOOP(1) LIGHT_LOOP(2) @@ -244,16 +240,17 @@ vec3 prelight_linearish_maybe = color.rgb; LIGHT_LOOP(6) LIGHT_LOOP(7) +vec3 light_linear = light.rgb; + // keep it linear // color.rgb += light.rgb; vec3 postlight_linear = color.rgb; -color.rgb = prelight_linearish_maybe; +//color.rgb = light_linear; color.rgb = linear_to_srgb(color.rgb); - #endif #ifdef WATER_FOG -- cgit v1.2.3 From f9c0b021ea1a695c0d5d4042981045fe265e7918 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 9 Apr 2019 13:02:58 -0700 Subject: SL-5186 Fix falloff on projectors in forward rendering (different falloff calcs than deferred). --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 4b99592dbb..4fe0d1351d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -92,8 +92,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec float d = length(lv); float da = 1.0; vec3 col = vec3(0); - - if (d > 0.0 && fa > 0.0) + if (d > 0.0) { //normalize light vector lv = normalize(lv); @@ -103,8 +102,9 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec da = clamp(da, 0.0, 1.0); //distance attenuation - float dist = d/la; - float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); + 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; dist_atten *= dist_atten; dist_atten *= 2.0f; @@ -230,7 +230,7 @@ vec3 post_diffuse = color.rgb; vec3 prelight_linearish_maybe = color.rgb; - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w, 1.0); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w * 0.5, 1.0); LIGHT_LOOP(1) LIGHT_LOOP(2) -- cgit v1.2.3 From d7d8a15092c91f6fa55547515b243b61a78868ff Mon Sep 17 00:00:00 2001 From: Geenz Date: Wed, 10 Apr 2019 02:49:25 -0700 Subject: Fullbright + elimination of all references to calcFragAtmospherics. --HG-- branch : OPEN-340 --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 4fe0d1351d..ca82dd9432 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -77,7 +77,7 @@ vec2 encode_normal (vec3 n); vec3 scaleSoftClipFrag(vec3 l); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); -void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); +void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); #ifdef HAS_SHADOW float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); @@ -184,7 +184,7 @@ void main() vec3 additive; vec3 atten; - calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); + calcAtmosphericVars(pos.xyz, 1.0, sunlit, amblit, additive, atten); vec2 abnormal = encode_normal(norm.xyz); -- cgit v1.2.3 From 27184c74b4b8085e362c6e21d5d1071889476fe9 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 10 Apr 2019 13:43:58 -0700 Subject: SL-10901 Fix up shadow sampling and tweak shadow biasing. Clean up shader decls of unused funcs. Clean up whitespace diffs from release. --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index ca82dd9432..ab7f779a39 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -83,7 +83,7 @@ void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, o float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); #endif -vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance ,float shadow) +vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance) { //get light vector vec3 lv = lp.xyz-v; @@ -115,15 +115,19 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec // to match spotLight (but not multiSpotLight) *sigh* float lit = max(da * dist_atten,0.0); - col = lit * light_col * diffuse * shadow; + col = lit * light_col * diffuse; float amb_da = ambiance; - amb_da += (da*0.5+0.5) * (1.0 - shadow) * ambiance; - amb_da += (da*da*0.5 + 0.5) * (1.0 - shadow) * ambiance; + if (da > 0) + { + 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.5 * light_col * diffuse; + // no spec for alpha shader... } col = max(col, vec3(0)); @@ -185,6 +189,7 @@ void main() vec3 atten; calcAtmosphericVars(pos.xyz, 1.0, sunlit, amblit, additive, atten); + sunlit *= 0.5; vec2 abnormal = encode_normal(norm.xyz); @@ -228,9 +233,9 @@ vec3 post_diffuse = color.rgb; vec4 light = vec4(0,0,0,0); -vec3 prelight_linearish_maybe = color.rgb; +vec3 prelight_linearish_maybe = srgb_to_linear(color.rgb); - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w * 0.5, 1.0); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w * 0.5); LIGHT_LOOP(1) LIGHT_LOOP(2) -- cgit v1.2.3 From a685e024a62751289ccfa41c962b039d1de748bd Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 23 Apr 2019 13:12:16 -0700 Subject: SL-10901 Bias shadow sampling and allow control of how dark shadows are (clamped ambient). --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index ab7f779a39..e8400ba66d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -83,6 +83,8 @@ void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, o float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); #endif +float getAmbientClamp(); + vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance) { //get light vector @@ -209,7 +211,7 @@ void main() float ambient = da; ambient *= 0.5; ambient *= ambient; - ambient = max(0.66, ambient); // keeps shadows dark + ambient = max(getAmbientClamp(), ambient); // keeps shadows dark ambient = 1.0 - ambient; vec3 sun_contrib = min(final_da, shadow) * sunlit; -- cgit v1.2.3 From 4ed05fc84fce0fbee76c583e91feed5aff2dbbfc Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 25 Apr 2019 10:59:00 -0700 Subject: Fix dark ALM and strangeness at Mid lighting (class 3 but with a darkness about it). Make a distinct class3/lighting/lightV which boosts to WL levels (* 2.0) and make lighting without WL atmo enabled use class 2 or below. Make forward shaders (alpha and materialF with alpha-blend mode on) more consistent with deferred lighting. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index e8400ba66d..8709053ac6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -201,7 +201,6 @@ void main() float final_da = da; final_da = clamp(final_da, 0.0f, 1.0f); - final_da = pow(final_da, 1.0/1.3); vec4 color = vec4(0,0,0,0); -- cgit v1.2.3 From 5766325290974ee2cfa30fd655060ef396d1e87a Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 25 Apr 2019 13:02:24 -0700 Subject: SL-10904, SL-10998, SL-11018 Fix handling of 1/light_y when y was tiny but getting even tinier. Add similar adjustment to shader version of same calc. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 8709053ac6..300900a9e5 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -229,13 +229,11 @@ vec3 post_diffuse = color.rgb; //color.rgb = mix(diff.rgb, color.rgb, final_alpha); - color.rgb = atmosFragLighting(color.rgb, additive, atten); + color.rgb = atmosFragLighting(color.rgb, additive, atten) * 2.0; color.rgb = scaleSoftClipFrag(color.rgb); vec4 light = vec4(0,0,0,0); -vec3 prelight_linearish_maybe = srgb_to_linear(color.rgb); - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w * 0.5); LIGHT_LOOP(1) -- cgit v1.2.3 From 948deb56d9aa11d61bba76a1e79040e8db0baf49 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 26 Apr 2019 07:59:20 -0700 Subject: Add projector light within da gtz test. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 300900a9e5..a63b9dec75 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -117,11 +117,10 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec // to match spotLight (but not multiSpotLight) *sigh* float lit = max(da * dist_atten,0.0); - col = lit * light_col * diffuse; - float amb_da = ambiance; if (da > 0) { + col = lit * light_col * diffuse; amb_da += (da*0.5+0.5) * ambiance; } amb_da += (da*da*0.5 + 0.5) * ambiance; -- cgit v1.2.3 From b5ba56c863184538bf45e99df81dd0b0aa5209b4 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 26 Apr 2019 08:03:17 -0700 Subject: Make alpha projectors do projector clip test for consistency with deferred spot behavior. --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index a63b9dec75..f49f274de0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -58,6 +58,7 @@ VARYING vec3 vary_norm; VARYING vec4 vertex_color; #endif +uniform mat4 proj_mat; uniform mat4 inv_proj; uniform vec2 screen_res; uniform int sun_up_factor; @@ -89,11 +90,22 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec { //get light vector vec3 lv = lp.xyz-v; - + + vec4 proj_tc = proj_mat * lp; + //get distance float d = length(lv); float da = 1.0; vec3 col = vec3(0); + if (proj_tc.z < 0 + || proj_tc.x < 0 + || proj_tc.z > 1 + || proj_tc.y < 0 + || proj_tc.y > 1) + { + return col; + } + if (d > 0.0) { //normalize light vector -- cgit v1.2.3 From f133be068a4aa23c02c47348f5c7d4a28e1d5c37 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 26 Apr 2019 16:02:21 -0700 Subject: Lighting WIP Consistency across class2/3/ALM lighting. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index f49f274de0..d11b81d2d3 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -194,6 +194,8 @@ void main() float final_alpha = diff.a; #endif + vec3 gamma_diff = diff.rgb; + diff.rgb = srgb_to_linear(diff.rgb); vec3 sunlit; @@ -239,10 +241,12 @@ vec3 post_sunlight = color.rgb; vec3 post_diffuse = color.rgb; //color.rgb = mix(diff.rgb, color.rgb, final_alpha); - - color.rgb = atmosFragLighting(color.rgb, additive, atten) * 2.0; + + color.rgb = atmosFragLighting(color.rgb, additive, atten); color.rgb = scaleSoftClipFrag(color.rgb); + //color.rgb = srgb_to_linear(color.rgb); + vec4 light = vec4(0,0,0,0); #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w * 0.5); -- cgit v1.2.3 From eff7acfb1caaa092a88555fca752dc9aea11625e Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 29 Apr 2019 08:53:09 -0700 Subject: Remove hack mul of sunlight in alpha shader and add some taps for debugging the lighting pipe. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index d11b81d2d3..11fcb3e87a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -204,7 +204,6 @@ void main() vec3 atten; calcAtmosphericVars(pos.xyz, 1.0, sunlit, amblit, additive, atten); - sunlit *= 0.5; vec2 abnormal = encode_normal(norm.xyz); @@ -240,12 +239,14 @@ vec3 post_sunlight = color.rgb; vec3 post_diffuse = color.rgb; - //color.rgb = mix(diff.rgb, color.rgb, final_alpha); + color.rgb = mix(diff.rgb, color.rgb, final_alpha); + + //color.rgb = srgb_to_linear(color.rgb); color.rgb = atmosFragLighting(color.rgb, additive, atten); color.rgb = scaleSoftClipFrag(color.rgb); - //color.rgb = srgb_to_linear(color.rgb); +vec3 post_atmo = color.rgb; vec4 light = vec4(0,0,0,0); -- cgit v1.2.3 From 0f83696585b8810c24d535432716215caf0c21e9 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 29 Apr 2019 11:11:05 -0700 Subject: SL-10956, SL-10969 Don't ignore far z in culling. Fix Mid lighting being very dark. Partial fix for broken projectors with forward rendering. --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 11fcb3e87a..1acb76bdd1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -98,8 +98,9 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec float da = 1.0; vec3 col = vec3(0); if (proj_tc.z < 0 - || proj_tc.x < 0 || proj_tc.z > 1 + || proj_tc.x < 0 + || proj_tc.x > 1 || proj_tc.y < 0 || proj_tc.y > 1) { @@ -139,7 +140,9 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec amb_da *= dist_atten; amb_da = min(amb_da, 1.0f - lit); +#ifndef NO_AMBIANCE col.rgb += amb_da * 0.5 * light_col * diffuse; +#endif // no spec for alpha shader... } @@ -260,17 +263,9 @@ vec3 post_atmo = color.rgb; LIGHT_LOOP(6) LIGHT_LOOP(7) -vec3 light_linear = light.rgb; + color.rgb = linear_to_srgb(color.rgb); - // keep it linear - // color.rgb += light.rgb; - -vec3 postlight_linear = color.rgb; - -//color.rgb = light_linear; - - color.rgb = linear_to_srgb(color.rgb); #endif #ifdef WATER_FOG -- cgit v1.2.3 From bfce96d684d5d056061ce16a36daba9a2bd0aa9d Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 30 Apr 2019 10:04:20 -0700 Subject: SL-10856 Remove ambient clamp to keep shadows dark. Partial fix for class 3 ambient term being wrong. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 1acb76bdd1..ae579d7f85 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -225,7 +225,6 @@ void main() float ambient = da; ambient *= 0.5; ambient *= ambient; - ambient = max(getAmbientClamp(), ambient); // keeps shadows dark ambient = 1.0 - ambient; vec3 sun_contrib = min(final_da, shadow) * sunlit; -- cgit v1.2.3 From c4032528aff8ef1938e897ec583bbf25a3e713e1 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 2 May 2019 13:49:35 -0700 Subject: Roll back sRGB decode changes from contrib for now. Fix direct light matching across alpha/blended-material/deferred. Get diffuse lighting to match from Low to Ultra. --- .../shaders/class1/deferred/alphaF.glsl | 68 +++++++++++++--------- 1 file changed, 41 insertions(+), 27 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index ae579d7f85..ecb1d599de 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -121,7 +121,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec fa += 1.0f; 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.0f; + dist_atten *= 2.0; // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); @@ -140,9 +140,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec amb_da *= dist_atten; amb_da = min(amb_da, 1.0f - lit); -#ifndef NO_AMBIANCE col.rgb += amb_da * 0.5 * light_col * diffuse; -#endif // no spec for alpha shader... } @@ -164,22 +162,26 @@ void main() shadow = sampleDirectionalShadow(pos.xyz, norm.xyz, frag); #endif +#ifdef USE_DIFFUSE_TEX + vec4 diffuse_linear = texture2D(diffuseMap,vary_texcoord0.xy); +#endif + #ifdef USE_INDEXED_TEX - vec4 diff = diffuseLookup(vary_texcoord0.xy); -#else - vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); + vec4 diffuse_linear = diffuseLookup(vary_texcoord0.xy); #endif + vec4 diffuse_srgb = vec4(linear_to_srgb(diffuse_linear.rgb), diffuse_linear.a); + #ifdef FOR_IMPOSTOR vec4 color; - color.rgb = diff.rgb; + color.rgb = diffuse_srgb.rgb; color.a = 1.0; #ifdef USE_VERTEX_COLOR - float final_alpha = diff.a * vertex_color.a; - diff.rgb *= vertex_color.rgb; + float final_alpha = diffuse_srgb.a * vertex_color.a; + diffuse_srgb.rgb *= vertex_color.rgb; #else - float final_alpha = diff.a; + float final_alpha = diffuse_srgb.a; #endif // Insure we don't pollute depth with invis pixels in impostor rendering @@ -191,16 +193,12 @@ void main() #else #ifdef USE_VERTEX_COLOR - float final_alpha = diff.a * vertex_color.a; - diff.rgb *= vertex_color.rgb; + float final_alpha = diffuse_linear.a * vertex_color.a; + diffuse_srgb.rgb *= vertex_color.rgb; #else - float final_alpha = diff.a; + float final_alpha = diffuse_linear.a; #endif - vec3 gamma_diff = diff.rgb; - - diff.rgb = srgb_to_linear(diff.rgb); - vec3 sunlit; vec3 amblit; vec3 additive; @@ -217,7 +215,7 @@ void main() float final_da = da; final_da = clamp(final_da, 0.0f, 1.0f); - vec4 color = vec4(0,0,0,0); + vec4 color = vec4(0.0); color.rgb = amblit; color.a = final_alpha; @@ -225,6 +223,7 @@ void main() float ambient = da; ambient *= 0.5; ambient *= ambient; + ambient = max(getAmbientClamp(), ambient); // keeps shadows dark ambient = 1.0 - ambient; vec3 sun_contrib = min(final_da, shadow) * sunlit; @@ -237,14 +236,12 @@ vec3 post_ambient = color.rgb; vec3 post_sunlight = color.rgb; - color.rgb *= diff.rgb; + color.rgb *= diffuse_linear.rgb; vec3 post_diffuse = color.rgb; - color.rgb = mix(diff.rgb, color.rgb, final_alpha); - - //color.rgb = srgb_to_linear(color.rgb); - + //color.rgb = mix(diffuse_srgb.rgb, color.rgb, final_alpha); + color.rgb = atmosFragLighting(color.rgb, additive, atten); color.rgb = scaleSoftClipFrag(color.rgb); @@ -252,7 +249,10 @@ vec3 post_atmo = color.rgb; vec4 light = vec4(0,0,0,0); - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w * 0.5); + // to linear! + color.rgb = srgb_to_linear(color.rgb); + + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diffuse_linear.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w * 0.5); LIGHT_LOOP(1) LIGHT_LOOP(2) @@ -262,15 +262,29 @@ vec3 post_atmo = color.rgb; LIGHT_LOOP(6) LIGHT_LOOP(7) + // sum local light contrib in linear colorspace + color.rgb += light.rgb; + + // back to sRGB as we're going directly to the final RT post-deferred gamma correction color.rgb = linear_to_srgb(color.rgb); - color.rgb += light.rgb; -#endif + +//color.rgb = amblit; +//color.rgb = vec3(ambient); +//color.rgb = sunlit; +//color.rgb = vec3(final_da); +//color.rgb = post_ambient; +//color.rgb = post_sunlight; +//color.rgb = sun_contrib; +//color.rgb = diffuse_srgb.rgb; +//color.rgb = post_diffuse; +//color.rgb = post_atmo; #ifdef WATER_FOG color = applyWaterFogView(pos.xyz, color); -#endif +#endif // WATER_FOG +#endif frag_color = color; } -- cgit v1.2.3 From 906b0be675e5467665f65180924e6117700b4cbb Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 3 May 2019 08:47:13 -0700 Subject: SL-11087, SL-11086, SL-11092 Fix sun/moon glow factor bustage. Make darkness an option. Fix moon fade shader logic getting confused when sun was below horizon. --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index ecb1d599de..0a189ff416 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -119,9 +119,9 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec //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_atten = (fa > 0) ? clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0) : 0.0f; dist_atten *= dist_atten; - dist_atten *= 2.0; + dist_atten *= 2.2f; // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); @@ -131,15 +131,14 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec float lit = max(da * dist_atten,0.0); float amb_da = ambiance; - if (da > 0) + if (lit > 0) { col = lit * light_col * 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); } - 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.5 * light_col * diffuse; // no spec for alpha shader... -- cgit v1.2.3 From 9c23ede9799a3277ae8e79f9832b3ea557fc069d Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 3 May 2019 09:12:53 -0700 Subject: SL-11075 Make alpha shader apply vert color everywhere. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 0a189ff416..b00e2290a9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -194,6 +194,7 @@ void main() #ifdef USE_VERTEX_COLOR float final_alpha = diffuse_linear.a * vertex_color.a; diffuse_srgb.rgb *= vertex_color.rgb; + diffuse_linear.rgb *= vertex_color.rgb; #else float final_alpha = diffuse_linear.a; #endif -- cgit v1.2.3 From 89c24095c6c1b778b93a4eb7ad398627f4d5479f Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 3 May 2019 12:02:59 -0700 Subject: SL-11085 Remove ambient term clamping to get less dark shadows where we want less dark shadows in ALM. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index b00e2290a9..c4d89f29f6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -223,7 +223,7 @@ void main() float ambient = da; ambient *= 0.5; ambient *= ambient; - ambient = max(getAmbientClamp(), ambient); // keeps shadows dark + //ambient = max(getAmbientClamp(), ambient); // keeps shadows dark ambient = 1.0 - ambient; vec3 sun_contrib = min(final_da, shadow) * sunlit; -- cgit v1.2.3 From 21c1941a4f4780c0675ae338cbbc5899aa7c0613 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 6 May 2019 10:16:31 -0700 Subject: Fix missin atten and atten only applied when da > 0 in material and alpha shaders resp. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index c4d89f29f6..2112fa8251 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -136,9 +136,9 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec col = lit * light_col * 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); } + amb_da *= dist_atten; + amb_da = min(amb_da, 1.0f - lit); col.rgb += amb_da * 0.5 * light_col * diffuse; // no spec for alpha shader... @@ -240,7 +240,7 @@ vec3 post_sunlight = color.rgb; vec3 post_diffuse = color.rgb; - //color.rgb = mix(diffuse_srgb.rgb, color.rgb, final_alpha); + //color.rgb = mix(diffuse_linear.rgb, color.rgb, final_alpha); color.rgb = atmosFragLighting(color.rgb, additive, atten); color.rgb = scaleSoftClipFrag(color.rgb); @@ -268,7 +268,6 @@ vec3 post_atmo = color.rgb; // back to sRGB as we're going directly to the final RT post-deferred gamma correction color.rgb = linear_to_srgb(color.rgb); - //color.rgb = amblit; //color.rgb = vec3(ambient); //color.rgb = sunlit; -- cgit v1.2.3 From c61f73321dbef9f0f5741830bfbaa8facd6ec060 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 6 May 2019 16:29:06 -0700 Subject: SL-11102, SL-11103 Fix diffuse boost in deferred lighting to match non-deferred. Make class2 soften not clamp shadow color to incoming alpha (make shadows appear on terrain underwater). --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 2112fa8251..dbd7abd7e5 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -240,8 +240,6 @@ vec3 post_sunlight = color.rgb; vec3 post_diffuse = color.rgb; - //color.rgb = mix(diffuse_linear.rgb, color.rgb, final_alpha); - color.rgb = atmosFragLighting(color.rgb, additive, atten); color.rgb = scaleSoftClipFrag(color.rgb); -- cgit v1.2.3 From b143aa96fcd6d16558464c98bcfd9984f7d29750 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 13 May 2019 15:33:48 -0700 Subject: SL-10856 Modify calc of sunlight to avoid clipping in gamma correct on values outside 0-1 range. Modify shaders to put back ambient clamp tuned to be close to ambient contrib in low/mid lighting. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index dbd7abd7e5..b439fbbff6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -223,8 +223,7 @@ void main() float ambient = da; ambient *= 0.5; ambient *= ambient; - //ambient = max(getAmbientClamp(), ambient); // keeps shadows dark - ambient = 1.0 - ambient; + ambient = min(getAmbientClamp(), 1.0 - ambient); vec3 sun_contrib = min(final_da, shadow) * sunlit; -- cgit v1.2.3 From e9dbee00262a437e4b3f971b37ea636e92032133 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 21 May 2019 16:00:45 -0700 Subject: SL-11238 Fix ambient light inputs to the renderer. Fix 3rd sky shader w/ mistaken density mod conversion. Make ambient clamp apply to all modes. Tune ALM ambient clamp to match non-ALM. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index b439fbbff6..e0bf58a5c2 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -223,7 +223,9 @@ void main() float ambient = da; ambient *= 0.5; ambient *= ambient; - ambient = min(getAmbientClamp(), 1.0 - ambient); + + float ambient_clamp = getAmbientClamp() + 0.2; + ambient = (1.0 - ambient) * ambient_clamp; vec3 sun_contrib = min(final_da, shadow) * sunlit; -- cgit v1.2.3 From db091d23db70952b4ad8b610ef02942a8f13f223 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 22 May 2019 11:00:30 -0700 Subject: 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. --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') 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; -- cgit v1.2.3 From d0a0eede63fdbd4ba597b86cbfbeb5b394ed2395 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 23 May 2019 09:58:33 -0700 Subject: Add render debug controls for forcing disable of ambient, sun, and local light contributions (engages AMBIENT_KILL, SUNLIGHT_KILL, and LOCAL_LIGHT_KILL defines in shaders to accomplish those tasks as required by each render mode). --- .../shaders/class1/deferred/alphaF.glsl | 81 ++++++++++------------ 1 file changed, 36 insertions(+), 45 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 1c826790fb..4a12659d56 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -88,64 +88,49 @@ float getAmbientClamp(); vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance) { - //get light vector - vec3 lv = lp.xyz-v; - - vec4 proj_tc = proj_mat * lp; - - //get distance - float d = length(lv); - float da = 1.0; - vec3 col = vec3(0); - if (proj_tc.z < 0 - || proj_tc.z > 1 - || proj_tc.x < 0 - || proj_tc.x > 1 - || proj_tc.y < 0 - || proj_tc.y > 1) - { - return col; - } + //get light vector + vec3 lv = lp.xyz-v; - if (d > 0.0 && la > 0.0 && fa > 0.0) - { - //normalize light vector - lv = normalize(lv); - vec3 norm = normalize(n); +la /= 20.0f; - da = dot(norm, lv); - da = clamp(da, 0.0, 1.0); + //get distance + float d = length(lv); + + float da = 1.0; -la /= 20.0f; - - //distance attenuation - 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; + vec3 col = vec3(0); - if (dist_atten < 0.0) - { - return col; - } + if (d > 0.0 && la > 0.0 && fa > 0.0) + { + //normalize light vector + lv = normalize(lv); + + //distance attenuation + 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.0f; + + // spotlight coefficient. + float spot = max(dot(-ln, lv), is_pointlight); + da *= spot*spot; // GL_SPOT_EXPONENT=2 - // spotlight coefficient. - float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 + //angular attenuation + da *= max(dot(n, lv), 0.0); - // to match spotLight (but not multiSpotLight) *sigh* - float lit = max(da * dist_atten,0.0); + float lit = max(da * dist_atten,0.0); +ambiance = 0.0f; float amb_da = ambiance; if (lit > 0) { col = lit * light_col * diffuse; amb_da += (da*0.5+0.5) * ambiance; - amb_da += (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.5 * light_col * diffuse; + col.rgb += amb_da * light_col * diffuse; // no spec for alpha shader... } @@ -223,7 +208,6 @@ void main() vec4 color = vec4(0.0); - color.rgb = amblit; color.a = final_alpha; float ambient = da; @@ -235,11 +219,16 @@ void main() vec3 sun_contrib = min(final_da, shadow) * sunlit; +#if !defined(AMBIENT_KILL) + color.rgb = amblit; color.rgb *= ambient; +#endif vec3 post_ambient = color.rgb; +#if !defined(SUNLIGHT_KILL) color.rgb += sun_contrib; +#endif vec3 post_sunlight = color.rgb; @@ -257,7 +246,7 @@ vec3 post_atmo = color.rgb; // to linear! color.rgb = srgb_to_linear(color.rgb); - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diffuse_linear.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w * 0.5); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diffuse_linear.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w); LIGHT_LOOP(1) LIGHT_LOOP(2) @@ -268,7 +257,9 @@ vec3 post_atmo = color.rgb; LIGHT_LOOP(7) // sum local light contrib in linear colorspace +#if !defined(LOCAL_LIGHT_KILL) color.rgb += light.rgb; +#endif // back to sRGB as we're going directly to the final RT post-deferred gamma correction color.rgb = linear_to_srgb(color.rgb); -- cgit v1.2.3 From 3c37658c02a2cf4b257203a9bc68246c5ac4042a Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 23 May 2019 11:16:23 -0700 Subject: Re-enable projector ambiance for forward alpha objects. Undo attenuation hacks and balance with deferred path projector lighting. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 4a12659d56..cd0494dc67 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -91,8 +91,6 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec //get light vector vec3 lv = lp.xyz-v; -la /= 20.0f; - //get distance float d = length(lv); @@ -109,7 +107,7 @@ la /= 20.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.0f; + //dist_atten *= 2.0f; // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); @@ -120,7 +118,6 @@ la /= 20.0f; float lit = max(da * dist_atten,0.0); -ambiance = 0.0f; float amb_da = ambiance; if (lit > 0) { -- cgit v1.2.3 From 3d9bd0fb8291ad3de4aaa20100149bd45680538b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 28 May 2019 14:36:00 -0700 Subject: SL-10969, SL-11073 Modify forward projector lighting to use falloff like the deferred lights. Make tex cache not evaluate evictions for size during validation passes. --- .../shaders/class1/deferred/alphaF.glsl | 57 ++++++++++++++++------ 1 file changed, 42 insertions(+), 15 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index cd0494dc67..2b5509400e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -88,45 +88,71 @@ float getAmbientClamp(); vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance) { + vec3 col = vec3(0); + //get light vector vec3 lv = lp.xyz-v; //get distance - float d = length(lv); - + float dist = length(lv); float da = 1.0; - vec3 col = vec3(0); + if (dist > la) + { + return col; + } + + dist /= la; - if (d > 0.0 && la > 0.0 && fa > 0.0) + /* clip to projector bounds + vec4 proj_tc = proj_mat * lp; + + if (proj_tc.z < 0 + || proj_tc.z > 1 + || proj_tc.x < 0 + || proj_tc.x > 1 + || proj_tc.y < 0 + || proj_tc.y > 1) + { + return col; + }*/ + + fa += 1.0; + if (dist > 0.0 && la > 0.0 && fa > 0.0) { //normalize light vector lv = normalize(lv); //distance attenuation - 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.0f; + dist_atten *= 2.0f; + + if (dist_atten <= 0.0) + { + return col; + } // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); da *= spot*spot; // GL_SPOT_EXPONENT=2 //angular attenuation - da *= max(dot(n, lv), 0.0); + da *= dot(n, lv); - float lit = max(da * dist_atten,0.0); + float lit = 0.0f; float amb_da = ambiance; - if (lit > 0) + if (da > 0) { + lit = max(da * dist_atten,0.0); col = lit * light_col * 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 * light_col * diffuse; // no spec for alpha shader... @@ -150,14 +176,14 @@ void main() #endif #ifdef USE_DIFFUSE_TEX - vec4 diffuse_linear = texture2D(diffuseMap,vary_texcoord0.xy); + vec4 diffuse_srgb = texture2D(diffuseMap,vary_texcoord0.xy); + vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a); #endif #ifdef USE_INDEXED_TEX vec4 diffuse_linear = diffuseLookup(vary_texcoord0.xy); -#endif - vec4 diffuse_srgb = vec4(linear_to_srgb(diffuse_linear.rgb), diffuse_linear.a); +#endif #ifdef FOR_IMPOSTOR vec4 color; @@ -229,12 +255,11 @@ vec3 post_ambient = color.rgb; vec3 post_sunlight = color.rgb; - color.rgb *= diffuse_linear.rgb; + color.rgb *= diffuse_srgb.rgb; vec3 post_diffuse = color.rgb; color.rgb = atmosFragLighting(color.rgb, additive, atten); - color.rgb = scaleSoftClipFrag(color.rgb); vec3 post_atmo = color.rgb; @@ -243,7 +268,7 @@ vec3 post_atmo = color.rgb; // to linear! color.rgb = srgb_to_linear(color.rgb); - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diffuse_linear.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diffuse_srgb.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w); LIGHT_LOOP(1) LIGHT_LOOP(2) @@ -258,6 +283,8 @@ vec3 post_atmo = color.rgb; color.rgb += light.rgb; #endif + color.rgb = scaleSoftClipFrag(color.rgb); + // back to sRGB as we're going directly to the final RT post-deferred gamma correction color.rgb = linear_to_srgb(color.rgb); -- cgit v1.2.3 From 2f2cf6d855e1e5977ef0ed3583238636e890220a Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 29 May 2019 15:57:24 -0700 Subject: SL-10969 Modify ambient handling and forward projector lighting again to stamp out alpha fires. --- .../shaders/class1/deferred/alphaF.glsl | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 2b5509400e..93359e0d4c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -102,8 +102,6 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec return col; } - dist /= la; - /* clip to projector bounds vec4 proj_tc = proj_mat * lp; @@ -117,16 +115,17 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec return col; }*/ - fa += 1.0; - if (dist > 0.0 && la > 0.0 && fa > 0.0) + if (dist > 0.0 && la > 0.0) { + dist /= la; + //normalize light vector lv = normalize(lv); //distance attenuation float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); dist_atten *= dist_atten; - dist_atten *= 2.0f; + //dist_atten *= 2.0f; if (dist_atten <= 0.0) { @@ -177,14 +176,14 @@ void main() #ifdef USE_DIFFUSE_TEX vec4 diffuse_srgb = texture2D(diffuseMap,vary_texcoord0.xy); - vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a); #endif #ifdef USE_INDEXED_TEX - vec4 diffuse_linear = diffuseLookup(vary_texcoord0.xy); - vec4 diffuse_srgb = vec4(linear_to_srgb(diffuse_linear.rgb), diffuse_linear.a); + vec4 diffuse_srgb = diffuseLookup(vary_texcoord0.xy); #endif + vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a); + #ifdef FOR_IMPOSTOR vec4 color; color.rgb = diffuse_srgb.rgb; @@ -236,9 +235,7 @@ void main() float ambient = da; ambient *= 0.5; ambient *= ambient; - - float ambient_clamp = getAmbientClamp() + 0.1; - ambient = (1.0 - ambient) * ambient_clamp; + ambient = (1.0 - ambient); vec3 sun_contrib = min(final_da, shadow) * sunlit; @@ -268,7 +265,7 @@ vec3 post_atmo = color.rgb; // to linear! color.rgb = srgb_to_linear(color.rgb); - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diffuse_srgb.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diffuse_linear.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w); LIGHT_LOOP(1) LIGHT_LOOP(2) -- cgit v1.2.3 From 58f7b981bdb415311f23dfffc39e7a841b3017a0 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 31 May 2019 13:47:44 -0700 Subject: SL-11337 Fix handling of ambient (was getting reset to 1,1,1,1 unintentionally). Modify shaders to balance ambient across render modes again. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 93359e0d4c..1ed25d1dba 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -240,7 +240,7 @@ void main() vec3 sun_contrib = min(final_da, shadow) * sunlit; #if !defined(AMBIENT_KILL) - color.rgb = amblit; + color.rgb = amblit * 0.5; color.rgb *= ambient; #endif -- cgit v1.2.3 From b79d0d2fdd047636598cbc9b088c3d4a10a84460 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 10 Jun 2019 09:15:35 -0700 Subject: SL-10969, SL-11051 Make fullbright alpha mask with mask cutoff == 0 not generate shadows. Adjust handling of ambient across forward and deferred again. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 1ed25d1dba..b4de492abc 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -40,7 +40,6 @@ out vec4 frag_color; uniform float display_gamma; uniform vec4 gamma; uniform mat3 env_mat; -uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; uniform vec3 moon_dir; @@ -78,7 +77,7 @@ vec2 encode_normal (vec3 n); vec3 scaleSoftClipFrag(vec3 l); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); -void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); +void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive, bool use_ao); #ifdef HAS_SHADOW float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); @@ -217,7 +216,7 @@ void main() vec3 additive; vec3 atten; - calcAtmosphericVars(pos.xyz, 1.0, sunlit, amblit, additive, atten); + calcAtmosphericVars(pos.xyz, 1.0, sunlit, amblit, additive, atten, false); vec2 abnormal = encode_normal(norm.xyz); @@ -240,7 +239,7 @@ void main() vec3 sun_contrib = min(final_da, shadow) * sunlit; #if !defined(AMBIENT_KILL) - color.rgb = amblit * 0.5; + color.rgb = amblit * 2.0; color.rgb *= ambient; #endif -- cgit v1.2.3 From 653133b9c035e7c34563b199e991189ca3046092 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 11 Jun 2019 13:03:06 -0700 Subject: SL-11370, SL-11372, SL-11337 Fix culling on Low+ water reflection pass. Make Mid+ / High use class1 deferred sky again (no rainbows, but faster!). Fix setting of cloud color for deferred sky/cloud shaders. Put water reflections back in wrong colorspace for consistency with release. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index b4de492abc..7dc2fb4cc0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -239,7 +239,7 @@ void main() vec3 sun_contrib = min(final_da, shadow) * sunlit; #if !defined(AMBIENT_KILL) - color.rgb = amblit * 2.0; + color.rgb = amblit; color.rgb *= ambient; #endif -- cgit v1.2.3 From 4abb342e9564a7740475c3abe60cd62ae5bbc34d Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 18 Jun 2019 13:14:27 -0700 Subject: SL-10969 Remove ambiance handling from alpha and blended materials objects for now. Still too many setups where they get blown out due to attenuation mismatches with deferred. --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 7dc2fb4cc0..241857dd92 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -96,12 +96,12 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec float dist = length(lv); float da = 1.0; - if (dist > la) + /*if (dist > la) { return col; } - /* clip to projector bounds + clip to projector bounds vec4 proj_tc = proj_mat * lp; if (proj_tc.z < 0 @@ -116,15 +116,15 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec if (dist > 0.0 && la > 0.0) { - dist /= la; + dist /= la; //normalize light vector lv = normalize(lv); //distance attenuation + fa += 1.0f; float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); dist_atten *= dist_atten; - //dist_atten *= 2.0f; if (dist_atten <= 0.0) { @@ -137,10 +137,11 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec //angular attenuation da *= dot(n, lv); + da = max(0.0, da); float lit = 0.0f; - float amb_da = ambiance; + float amb_da = 0.0;//ambiance; if (da > 0) { lit = max(da * dist_atten,0.0); @@ -151,7 +152,8 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec amb_da *= dist_atten; amb_da = min(amb_da, 1.0f - lit); - col.rgb += amb_da * light_col * diffuse; + // SL-10969 ... need to work out why this blows out in many setups... + //col.rgb += amb_da * light_col * diffuse; // no spec for alpha shader... } @@ -174,13 +176,14 @@ void main() #endif #ifdef USE_DIFFUSE_TEX - vec4 diffuse_srgb = texture2D(diffuseMap,vary_texcoord0.xy); + vec4 diffuse_tap = texture2D(diffuseMap,vary_texcoord0.xy); #endif #ifdef USE_INDEXED_TEX - vec4 diffuse_srgb = diffuseLookup(vary_texcoord0.xy); + vec4 diffuse_tap = diffuseLookup(vary_texcoord0.xy); #endif + vec4 diffuse_srgb = diffuse_tap; vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a); #ifdef FOR_IMPOSTOR @@ -205,7 +208,6 @@ void main() #ifdef USE_VERTEX_COLOR float final_alpha = diffuse_linear.a * vertex_color.a; - diffuse_srgb.rgb *= vertex_color.rgb; diffuse_linear.rgb *= vertex_color.rgb; #else float final_alpha = diffuse_linear.a; -- cgit v1.2.3 From 5bd055fe585233b3c43e02f2082f5a95f79b825b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 18 Jun 2019 14:33:28 -0700 Subject: SL-10829 the 2nd Made pointLightF use correct colorspace as multiPoint already was. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 241857dd92..20dc03d7a5 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -122,9 +122,9 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec lv = normalize(lv); //distance attenuation - fa += 1.0f; float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); dist_atten *= dist_atten; + dist_atten *= 2.0f; if (dist_atten <= 0.0) { -- cgit v1.2.3 From 7e5000bb64ca8eea3fe188ebb7bccff3bdfa82e7 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 2 Jul 2019 11:20:09 -0700 Subject: SL-11533 Make alpha shader include vertex color modulation in both srgb and linear flavors. --- .../newview/app_settings/shaders/class1/deferred/alphaF.glsl | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 20dc03d7a5..15408b3475 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -53,9 +53,7 @@ VARYING vec3 vary_position; VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; -#ifdef USE_VERTEX_COLOR VARYING vec4 vertex_color; -#endif uniform mat4 proj_mat; uniform mat4 inv_proj; @@ -191,12 +189,9 @@ void main() color.rgb = diffuse_srgb.rgb; color.a = 1.0; -#ifdef USE_VERTEX_COLOR float final_alpha = diffuse_srgb.a * vertex_color.a; diffuse_srgb.rgb *= vertex_color.rgb; -#else - float final_alpha = diffuse_srgb.a; -#endif + diffuse_linear.rgb *= vertex_color.rgb; // Insure we don't pollute depth with invis pixels in impostor rendering // @@ -206,12 +201,9 @@ void main() } #else -#ifdef USE_VERTEX_COLOR float final_alpha = diffuse_linear.a * vertex_color.a; + diffuse_srgb.rgb *= vertex_color.rgb; diffuse_linear.rgb *= vertex_color.rgb; -#else - float final_alpha = diffuse_linear.a; -#endif vec3 sunlit; vec3 amblit; -- cgit v1.2.3 From 664722168d7016d8bf80a65626bbff542913dc24 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 10 Jul 2019 14:50:59 -0700 Subject: SL-1491 Make sun additive contribition depend on facing the sun (without breaking fog). Put back scaling factor keeping sun contrib from blowing out with new FS param range for glow. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 15408b3475..759c49a0fa 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -75,7 +75,7 @@ vec2 encode_normal (vec3 n); vec3 scaleSoftClipFrag(vec3 l); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); -void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive, bool use_ao); +void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive, bool use_ao); #ifdef HAS_SHADOW float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); @@ -201,6 +201,8 @@ void main() } #else + vec3 light_dir = (sun_up_factor == 1) ? sun_dir: moon_dir; + float final_alpha = diffuse_linear.a * vertex_color.a; diffuse_srgb.rgb *= vertex_color.rgb; diffuse_linear.rgb *= vertex_color.rgb; @@ -210,11 +212,10 @@ void main() vec3 additive; vec3 atten; - calcAtmosphericVars(pos.xyz, 1.0, sunlit, amblit, additive, atten, false); + calcAtmosphericVars(pos.xyz, light_dir, 1.0, sunlit, amblit, additive, atten, false); vec2 abnormal = encode_normal(norm.xyz); - vec3 light_dir = (sun_up_factor == 1) ? sun_dir: moon_dir; float da = dot(norm.xyz, light_dir.xyz); da = clamp(da, -1.0, 1.0); -- cgit v1.2.3 From afdda55b8f6ad58c3e57185d3c352a923f4893aa Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 12 Jul 2019 14:45:15 -0700 Subject: SL-11588 Make avatar alpha shader ignore vertex color again. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 759c49a0fa..0c4707098b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -53,7 +53,9 @@ VARYING vec3 vary_position; VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; +#ifdef USE_VERTEX_COLOR VARYING vec4 vertex_color; +#endif uniform mat4 proj_mat; uniform mat4 inv_proj; @@ -203,9 +205,13 @@ void main() vec3 light_dir = (sun_up_factor == 1) ? sun_dir: moon_dir; - float final_alpha = diffuse_linear.a * vertex_color.a; + float final_alpha = diffuse_linear.a; + +#ifdef USE_VERTEX_COLOR + final_alpha *= vertex_color.a; diffuse_srgb.rgb *= vertex_color.rgb; diffuse_linear.rgb *= vertex_color.rgb; +#endif vec3 sunlit; vec3 amblit; -- cgit v1.2.3 From b507d63566e8896af702dd10f5643dc29068a8a9 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 23 Jul 2019 11:36:22 -0700 Subject: SL-11621 Remove all references to unused shader var global_gamma. Remove many unused decls for gamma from shaders. Make post-deferred gamma correction use display_gamma. Make setting display_gamma use the correct RenderDeferredDisplayGamma setting. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 0c4707098b..546a502ee1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -37,10 +37,7 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -uniform float display_gamma; -uniform vec4 gamma; uniform mat3 env_mat; - uniform vec3 sun_dir; uniform vec3 moon_dir; -- cgit v1.2.3 From cc5044bce06598aab9f405bba745f0e8209fc5ce Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Wed, 4 Mar 2020 15:56:02 -0600 Subject: WIP - fix various inconsistencies in sRGB vs linear color space. Fix inconsistencies between softenLightF.glsl, materialF.glsl, and alphaF.glsl --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 546a502ee1..814d5036db 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -22,7 +22,9 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - + +//class1/deferred/alphaF.glsl + #extension GL_ARB_texture_rectangle : enable /*[EXTRA_CODE_HERE]*/ @@ -51,7 +53,7 @@ VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; #ifdef USE_VERTEX_COLOR -VARYING vec4 vertex_color; +VARYING vec4 vertex_color; //vertex color should be treated as sRGB #endif uniform mat4 proj_mat; @@ -190,7 +192,7 @@ void main() float final_alpha = diffuse_srgb.a * vertex_color.a; diffuse_srgb.rgb *= vertex_color.rgb; - diffuse_linear.rgb *= vertex_color.rgb; + diffuse_linear.rgb = srgb_to_linear(diffuse_srgb.rgb); // Insure we don't pollute depth with invis pixels in impostor rendering // @@ -207,7 +209,7 @@ void main() #ifdef USE_VERTEX_COLOR final_alpha *= vertex_color.a; diffuse_srgb.rgb *= vertex_color.rgb; - diffuse_linear.rgb *= vertex_color.rgb; + diffuse_linear.rgb = srgb_to_linear(diffuse_srgb.rgb); #endif vec3 sunlit; @@ -249,7 +251,7 @@ vec3 post_ambient = color.rgb; vec3 post_sunlight = color.rgb; - color.rgb *= diffuse_srgb.rgb; + color.rgb *= diffuse_linear.rgb; vec3 post_diffuse = color.rgb; @@ -258,10 +260,7 @@ vec3 post_diffuse = color.rgb; vec3 post_atmo = color.rgb; vec4 light = vec4(0,0,0,0); - - // to linear! - color.rgb = srgb_to_linear(color.rgb); - + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diffuse_linear.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w); LIGHT_LOOP(1) @@ -298,7 +297,7 @@ vec3 post_atmo = color.rgb; #endif // WATER_FOG #endif - + frag_color = color; } -- cgit v1.2.3 From 7c7d71269f5b47397d14bbe44e341e4ac1d96889 Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Thu, 5 Mar 2020 16:28:06 -0600 Subject: WIP - Windlight sun lighting should happen in sRGB space, not linear space. This keeps ambient from getting overblown and better matches environment lighting with ALM on/off. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 814d5036db..e38eeab370 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -251,7 +251,7 @@ vec3 post_ambient = color.rgb; vec3 post_sunlight = color.rgb; - color.rgb *= diffuse_linear.rgb; + color.rgb *= diffuse_srgb.rgb; vec3 post_diffuse = color.rgb; @@ -261,6 +261,11 @@ vec3 post_atmo = color.rgb; vec4 light = vec4(0,0,0,0); + color.rgb = scaleSoftClipFrag(color.rgb); + + //convert to linear before applying local lights + color.rgb = srgb_to_linear(color.rgb); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diffuse_linear.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w); LIGHT_LOOP(1) @@ -275,9 +280,6 @@ vec3 post_atmo = color.rgb; #if !defined(LOCAL_LIGHT_KILL) color.rgb += light.rgb; #endif - - color.rgb = scaleSoftClipFrag(color.rgb); - // back to sRGB as we're going directly to the final RT post-deferred gamma correction color.rgb = linear_to_srgb(color.rgb); -- cgit v1.2.3 From 0390dc2fec2afdc053f373813d419178a70b299c Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Fri, 6 Mar 2020 14:33:58 -0600 Subject: Fix for mismatch on angular attenuation between sunlight on opaque and transparent objects from last commit. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index e38eeab370..dc484317e9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -223,6 +223,7 @@ void main() float da = dot(norm.xyz, light_dir.xyz); da = clamp(da, -1.0, 1.0); + da = pow(da, 1.0/1.3); float final_da = da; final_da = clamp(final_da, 0.0f, 1.0f); @@ -231,7 +232,7 @@ void main() color.a = final_alpha; - float ambient = da; + float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); ambient *= 0.5; ambient *= ambient; ambient = (1.0 - ambient); @@ -262,7 +263,7 @@ vec3 post_atmo = color.rgb; vec4 light = vec4(0,0,0,0); color.rgb = scaleSoftClipFrag(color.rgb); - + //convert to linear before applying local lights color.rgb = srgb_to_linear(color.rgb); -- cgit v1.2.3