diff options
author | Erik Kundiman <erik@megapahit.org> | 2025-09-09 07:27:14 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2025-09-09 14:22:41 +0800 |
commit | b9ab04cd6e253848bad865fc1b5ea993a2a060f3 (patch) | |
tree | bdbab3489daf2ac7b1595355d9708497df4f1e02 /indra/newview/app_settings/shaders/class1/deferred | |
parent | 4568096b3078d2d8980646f5b0b2f93762eb1caa (diff) | |
parent | ccf0114f36968d6cf6dfb11e1c5a035406314924 (diff) |
Merge remote-tracking branch 'mobserveur/experimental2'
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred')
3 files changed, 58 insertions, 18 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/MPHDRDisplayGammaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/MPHDRDisplayGammaF.glsl new file mode 100644 index 0000000000..7107cfcbce --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/MPHDRDisplayGammaF.glsl @@ -0,0 +1,55 @@ +/** + * @file postDeferredGammaCorrect.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +/*[EXTRA_CODE_HERE]*/ + +out vec4 frag_color; + +uniform sampler2D diffuseRect; + +uniform float gamma = 2.2; +uniform float mpHDRBoost; + +in vec2 vary_fragcoord; + +vec3 clampHDRRange(vec3 color); + +vec3 HDRDisplayGamma(vec3 linearRGB) +{ + bvec3 cutoff = lessThan(linearRGB, vec3(0.0031308)); + vec3 higher = vec3(1.055)*pow(linearRGB, vec3(1.0/gamma)) - vec3(0.055); + vec3 lower = linearRGB * vec3(12.92); + + return mix(higher, lower, cutoff); +} + +void main() +{ + vec4 diff = texture(diffuseRect, vary_fragcoord); + diff.rgb = mpHDRBoost * HDRDisplayGamma(diff.rgb); + diff.rgb = clampHDRRange(diff.rgb); + frag_color = diff; +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/SMAA.glsl b/indra/newview/app_settings/shaders/class1/deferred/SMAA.glsl index 60a8300352..fdb77cce6e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/SMAA.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/SMAA.glsl @@ -1351,10 +1351,6 @@ float4 SMAABlendingWeightCalculationPS(float2 texcoord, //----------------------------------------------------------------------------- // Neighborhood Blending Pixel Shader (Third Pass) -vec3 srgb_to_linear(vec3 cs); -vec4 srgb_to_linear4(vec4 cs); -vec3 linear_to_srgb(vec3 cl); - float4 SMAANeighborhoodBlendingPS(float2 texcoord, float4 offset, SMAATexture2D(colorTex), @@ -1373,7 +1369,6 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord, SMAA_BRANCH if (dot(a, float4(1.0, 1.0, 1.0, 1.0)) < 1e-5) { float4 color = SMAASampleLevelZero(colorTex, texcoord); - color.rgb = srgb_to_linear(color.rgb); #if SMAA_REPROJECTION float2 velocity = SMAA_DECODE_VELOCITY(SMAASampleLevelZero(velocityTex, texcoord)); @@ -1382,8 +1377,6 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord, color.a = sqrt(5.0 * length(velocity)); #endif - color.rgb = linear_to_srgb(color.rgb); - return color; } else { bool h = max(a.x, a.z) > max(a.y, a.w); // max(horizontal) > max(vertical) @@ -1400,15 +1393,8 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord, // We exploit bilinear filtering to mix current pixel with the chosen // neighbor: - //float4 color = blendingWeight.x * SMAASampleLevelZero(colorTex, blendingCoord.xy); - //color += blendingWeight.y * SMAASampleLevelZero(colorTex, blendingCoord.zw); - float4 color = SMAASampleLevelZero(colorTex, blendingCoord.xy); - color.rgb = srgb_to_linear(color.rgb); - color = blendingWeight.x * color; - - float4 color2 = SMAASampleLevelZero(colorTex, blendingCoord.zw); - color2.rgb = srgb_to_linear(color2.rgb); - color += blendingWeight.y * color2; + float4 color = blendingWeight.x * SMAASampleLevelZero(colorTex, blendingCoord.xy); + color += blendingWeight.y * SMAASampleLevelZero(colorTex, blendingCoord.zw); #if SMAA_REPROJECTION // Antialias velocity for proper reprojection in a later stage: @@ -1419,7 +1405,6 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord, color.a = sqrt(5.0 * length(velocity)); #endif - color.rgb = linear_to_srgb(color.rgb); return color; } } diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 4ccc6f54a8..197ce48a45 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -30,7 +30,7 @@ out vec4 frag_color; uniform sampler2D diffuseRect; uniform float gamma; -uniform vec2 screen_res; +//uniform vec2 screen_res; in vec2 vary_fragcoord; vec3 linear_to_srgb(vec3 cl); |