From 18eb8ac90ce409ba620f6fe8ff487e6195d9c3eb Mon Sep 17 00:00:00 2001 From: "Michael Pohoreski (Ptolemy Linden)" Date: Fri, 15 Nov 2019 15:45:08 -0800 Subject: [PATCH 1/9] QoL fix: remove extra blank lines for every source line when dumping shader source --- indra/llrender/llshadermgr.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index bce3720d3b..dcb34c6761 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -570,9 +570,20 @@ static std::string get_object_log(GLhandleARB ret) //dump shader source for debugging void LLShaderMgr::dumpShaderSource(U32 shader_code_count, GLcharARB** shader_code_text) { - for (GLuint i = 0; i < shader_code_count; i++) + for (U32 i = 0; i < shader_code_count; i++) { + GLcharARB *line = shader_code_text[i]; + size_t len = strlen( line ); + char last = len > 0 ? line[len - 1] : 0; + + // LL_ENDL already outputs a newline so temporarily strip off the end newline to prevent EVERY line outputting an (extra) blank line + if (last == '\n') + line[len - 1] = 0; + LL_SHADER_LOADING_WARNS() << i << ": " << shader_code_text[i] << LL_ENDL; + + if (last == '\n') + line[len - 1] = '\n'; } LL_SHADER_LOADING_WARNS() << LL_ENDL; } From 24920de799c8e2dd26854923c7a10fc4a551dd5d Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Tue, 19 Nov 2019 12:15:45 -0700 Subject: [PATCH 2/9] SL-11055 Add back pre-EEP fog burnthrough for fullbrights --- .../shaders/class2/windlight/transportF.glsl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl index d2d839ed05..a06f4f22ad 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl @@ -51,7 +51,14 @@ vec3 atmosTransport(vec3 light) vec3 fullbrightAtmosTransport(vec3 light) { float brightness = dot(light.rgb * 0.5, vec3(0.3333)) + 0.1; - return atmosTransportFrag(light * 0.5, getAdditiveColor() * brightness, getAtmosAttenuation()); + vec3 attenColor = atmosTransportFrag(light * 0.5, getAdditiveColor() * brightness, getAtmosAttenuation()); + + // attenColor is an accurate fog-attenuated result for any brightness + // But, the pre-EEP shader included a brightness-indexed lerp to a non-attenuated version + // of the color - effectively a fog 'burn-through' for very bright pixels. To more closely + // match the pre-EEP behavior, we'll also lerp to the pre-EEP color, based on overall brightness + float preEepBright = dot(light.rgb, vec3(0.3333)); + retun mix(attenColor, (light.rgb + getAdditiveColor().rgb) * (2.0 - preEepBright), preEepBright * preEepBright); } vec3 fullbrightShinyAtmosTransport(vec3 light) From f1f029bc92b7f2c816de0e01947da739e7c571bd Mon Sep 17 00:00:00 2001 From: "Michael Pohoreski (Ptolemy Linden)" Date: Wed, 20 Nov 2019 15:27:26 -0800 Subject: [PATCH 3/9] SL-11406 Fix fullbright to better match non-EEP. Also minor cleanup. --- .../shaders/class1/deferred/materialF.glsl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index fafecd57cc..a7dce5c7a5 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -264,8 +264,7 @@ void main() tnorm = vary_normal; #endif - norm.xyz = tnorm; - norm.xyz = normalize(norm.xyz); + norm.xyz = normalize(tnorm.xyz); vec2 abnormal = encode_normal(norm.xyz); @@ -277,7 +276,14 @@ void main() final_color.a = max(final_color.a, emissive_brightness); - vec4 final_normal = vec4(encode_normal(normalize(tnorm)), env_intensity, 0.0); + // SL-11406 Fullbright: Object > Texture > Shininess > Environment Intensity + // We can either modify the output environment intensity + // OR + // adjust the final color via + // final_color *= 0.666666; + // We remap the environment intensity to simulate what non-EEP is doing. + float ei = env_intensity*0.5 + 0.5; + vec4 final_normal = vec4(abnormal, ei, 0.0); vec4 final_specular = spec; final_specular.a = specular_color.a; @@ -316,8 +322,9 @@ void main() vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); - float da = dot(normalize(norm.xyz), normalize(light_dir.xyz)); - da = clamp(da, -1.0, 1.0); + float da = dot(norm.xyz, normalize(light_dir.xyz)); + // Dot product is guaranteed to be in -1 < dot() < +1 range for normalized vectors + // da = clamp(da, -1.0, 1.0); float final_da = da; final_da = clamp(final_da, 0.0, 1.0); From e1ea2c2b1eda89cf08fc31d3d1970446daea1883 Mon Sep 17 00:00:00 2001 From: "Michael Pohoreski (Ptolemy Linden)" Date: Thu, 21 Nov 2019 05:25:18 +0000 Subject: [PATCH 4/9] SL-11406 Fix fullbright to better match non-EEP. Minor optimization cleanup. --- .../shaders/class1/deferred/materialF.glsl | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 9505f2eb74..e640c2d7ae 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -264,8 +264,7 @@ void main() tnorm = vary_normal; #endif - norm.xyz = tnorm; - norm.xyz = normalize(norm.xyz); + norm.xyz = normalize(tnorm.xyz); vec2 abnormal = encode_normal(norm.xyz); @@ -277,7 +276,20 @@ void main() final_color.a = max(final_color.a, emissive_brightness); - vec4 final_normal = vec4(abnormal, env_intensity, 0.0); + // SL-11406 Fullbright: Object > Texture > Shininess > Environment Intensity = 1 + // NOTE: There are two shaders that are used depending on the EI byte value: + // EI = 0 fullbright + // EI > 0 .. 255 material + // When it is passed to us it is normalized. + // We can either modify the output environment intensity + // OR + // adjust the final color via: + // final_color *= 0.666666; + // We remap the environment intensity to closely simulate what non-EEP is doing. + // At midnight the brightness is exact. + // At midday the brightness is very close. + float ei = env_intensity*0.5 + 0.5; + vec4 final_normal = vec4(abnormal, ei, 0.0); vec4 final_specular = spec; final_specular.a = specular_color.a; @@ -316,11 +328,11 @@ void main() vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); - float da = dot(normalize(norm.xyz), normalize(light_dir.xyz)); - da = clamp(da, -1.0, 1.0); + float da = dot(norm.xyz, normalize(light_dir.xyz)); + // Dot product is guaranteed to be in -1 <= da <= +1 range for normalized vectors + // da = clamp(da, -1.0, 1.0); - float final_da = da; - final_da = clamp(final_da, 0.0, 1.0); + float final_da = clamp(da, 0.0, 1.0); float ambient = da; ambient *= 0.5; @@ -458,3 +470,4 @@ vec3 post_atmo = color.rgb; #endif } + From bd761b0833923f2fb6d3cd8430ebd3287be861f8 Mon Sep 17 00:00:00 2001 From: "Michael Pohoreski (Ptolemy Linden)" Date: Fri, 22 Nov 2019 23:41:20 +0000 Subject: [PATCH 5/9] Cleanup inconsistent types --- indra/llrender/llshadermgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index dcb34c6761..896dd566c1 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -574,7 +574,7 @@ void LLShaderMgr::dumpShaderSource(U32 shader_code_count, GLcharARB** shader_cod { GLcharARB *line = shader_code_text[i]; size_t len = strlen( line ); - char last = len > 0 ? line[len - 1] : 0; + GLcharARB last = len > 0 ? line[len - 1] : 0; // LL_ENDL already outputs a newline so temporarily strip off the end newline to prevent EVERY line outputting an (extra) blank line if (last == '\n') From a164daad74fc0c8729aac5601df23c0f5cb3c02c Mon Sep 17 00:00:00 2001 From: "Michael Pohoreski (Ptolemy Linden)" Date: Sat, 23 Nov 2019 00:02:30 +0000 Subject: [PATCH 6/9] Cleanup comments --- .../app_settings/shaders/class1/deferred/materialF.glsl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index e640c2d7ae..c23314a4b9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -276,7 +276,11 @@ void main() final_color.a = max(final_color.a, emissive_brightness); - // SL-11406 Fullbright: Object > Texture > Shininess > Environment Intensity = 1 + // Texture + // [x] Full Bright Object + // Shininess (specular) + // [X] Texture + // Environment Intensity = 1 // NOTE: There are two shaders that are used depending on the EI byte value: // EI = 0 fullbright // EI > 0 .. 255 material @@ -329,9 +333,6 @@ void main() float da = dot(norm.xyz, normalize(light_dir.xyz)); - // Dot product is guaranteed to be in -1 <= da <= +1 range for normalized vectors - // da = clamp(da, -1.0, 1.0); - float final_da = clamp(da, 0.0, 1.0); float ambient = da; From 41330f4a39e996fbcd4afa931973127a4abbcf86 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Mon, 25 Nov 2019 15:03:09 -0700 Subject: [PATCH 7/9] Roll back commit 41531 --- .../shaders/class2/windlight/transportF.glsl | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl index a06f4f22ad..d2d839ed05 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl @@ -51,14 +51,7 @@ vec3 atmosTransport(vec3 light) vec3 fullbrightAtmosTransport(vec3 light) { float brightness = dot(light.rgb * 0.5, vec3(0.3333)) + 0.1; - vec3 attenColor = atmosTransportFrag(light * 0.5, getAdditiveColor() * brightness, getAtmosAttenuation()); - - // attenColor is an accurate fog-attenuated result for any brightness - // But, the pre-EEP shader included a brightness-indexed lerp to a non-attenuated version - // of the color - effectively a fog 'burn-through' for very bright pixels. To more closely - // match the pre-EEP behavior, we'll also lerp to the pre-EEP color, based on overall brightness - float preEepBright = dot(light.rgb, vec3(0.3333)); - retun mix(attenColor, (light.rgb + getAdditiveColor().rgb) * (2.0 - preEepBright), preEepBright * preEepBright); + return atmosTransportFrag(light * 0.5, getAdditiveColor() * brightness, getAtmosAttenuation()); } vec3 fullbrightShinyAtmosTransport(vec3 light) From 020ffe1bd3bb428abc0219d808a6a032cb6c2aeb Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Tue, 3 Dec 2019 17:49:49 -0700 Subject: [PATCH 8/9] SL-11055 Increase fog burn-through for fullbrights (for reals) --- .../app_settings/shaders/class2/windlight/transportF.glsl | 5 +++-- .../app_settings/shaders/class3/windlight/transportF.glsl | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl index d2d839ed05..8fc5d750e3 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl @@ -38,8 +38,9 @@ vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten) { return light * 2.0; } - light *= atten.r; - light += additive; + // fullbright responds minimally to atmos scatter effects + light *= min(15.0 * atten.r, 1.0); + light += (0.1 * additive); return light * 2.0; } diff --git a/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl index 08eb119510..18705f785f 100644 --- a/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl +++ b/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl @@ -38,8 +38,9 @@ vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten) { return light; } - light *= atten.r; - light += additive; + // fullbright responds minimally to atmos scatter effects + light *= min(15.0 * atten.r, 1.0); + light += (0.1 * additive); return light * 2.0; } From 05e54ac96be519e5f60f2681ac3226dab7dcb8b2 Mon Sep 17 00:00:00 2001 From: "Michael Pohoreski (Ptolemy Linden)" Date: Tue, 10 Dec 2019 14:41:03 -0800 Subject: [PATCH 9/9] SL-11406: Skip avatars being effected. --- .../app_settings/shaders/class1/deferred/materialF.glsl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index c23314a4b9..52c69b46ea 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -292,8 +292,12 @@ void main() // We remap the environment intensity to closely simulate what non-EEP is doing. // At midnight the brightness is exact. // At midday the brightness is very close. +#ifdef HAS_SKIN + vec4 final_normal = vec4(abnormal, env_intensity, 0.0); +#else float ei = env_intensity*0.5 + 0.5; vec4 final_normal = vec4(abnormal, ei, 0.0); +#endif vec4 final_specular = spec; final_specular.a = specular_color.a;