diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/windlight')
17 files changed, 308 insertions, 646 deletions
diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl index 4e0618e276..41a848a14f 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl @@ -1,9 +1,9 @@ /** - * @file class1\windlight\atmosphericsF.glsl + * @file class2\wl\atmosphericsF.glsl * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2005, Linden Research, Inc. + * 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 @@ -22,27 +22,31 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - -vec3 atmosFragAmbient(vec3 light, vec3 sunlit) -{ - /* stub function for fallback compatibility on class1 hardware */ - return light; -} + +vec3 getAdditiveColor(); +vec3 getAtmosAttenuation(); +vec3 scaleSoftClipFrag(vec3 light); + +vec3 srgb_to_linear(vec3 col); +vec3 linear_to_srgb(vec3 col); + +uniform float sky_hdr_scale; vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten) -{ - /* stub function for fallback compatibility on class1 hardware */ +{ + light *= atten.r; + additive = srgb_to_linear(additive*2.0); + additive *= sky_hdr_scale; + light += additive; return light; } -vec3 atmosFragAffectDirectionalLight(float light, vec3 sunlit) +vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten) { - return light * sunlit; + return atmosFragLighting(light, additive, atten); } vec3 atmosLighting(vec3 light) { - /* stub function for fallback compatibility on class1 hardware */ - return light; + return atmosFragLighting(light, getAdditiveColor(), getAtmosAttenuation()); } - diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl index ea2690ba09..a8aa5a36a3 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl @@ -1,9 +1,9 @@ /** - * @file class1\windlight\atmosphericsFuncs.glsl + * @file class2\windlight\atmosphericsFuncs.glsl * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2019, Linden Research, Inc. + * Copyright (C) 2022, 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 @@ -22,29 +22,34 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ -uniform vec4 lightnorm; -uniform vec4 sunlight_color; -uniform vec4 moonlight_color; + +uniform vec3 lightnorm; +uniform vec3 sunlight_color; +uniform vec3 moonlight_color; uniform int sun_up_factor; -uniform vec4 ambient_color; -uniform vec4 blue_horizon; -uniform vec4 blue_density; +uniform vec3 ambient_color; +uniform vec3 blue_horizon; +uniform vec3 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 vec3 glow; uniform float scene_light_strength; -uniform mat3 ssao_effect_mat; -uniform int no_atmo; uniform float sun_moon_glow_factor; +uniform float sky_sunlight_scale; +uniform float sky_ambient_scale; float getAmbientClamp() { return 1.0f; } +vec3 srgb_to_linear(vec3 col); +vec3 legacy_adjust(vec3 col); + +// return colors in sRGB space void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, - out vec3 atten, bool use_ao) + out vec3 atten) { vec3 rel_pos = inPositionEye; @@ -53,17 +58,18 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou vec3 rel_pos_norm = normalize(rel_pos); float rel_pos_len = length(rel_pos); - vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; - + + vec3 sunlight = (sun_up_factor == 1) ? sunlight_color: moonlight_color; + // sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes - vec4 light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); + vec3 light_atten = (blue_density + vec3(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 - vec4 combined_haze = blue_density + vec4(haze_density); - vec4 blue_weight = blue_density / combined_haze; - vec4 haze_weight = vec4(haze_density) / combined_haze; + vec3 combined_haze = blue_density + vec3(haze_density); + vec3 blue_weight = blue_density / combined_haze; + vec3 haze_weight = vec3(haze_density) / combined_haze; //(TERRAIN) compute sunlight from lightnorm y component. Factor is roughly cosecant(sun elevation) (for short rays like terrain) float above_horizon_factor = 1.0 / max(1e-6, lightnorm.y); @@ -101,24 +107,10 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou haze_glow *= sun_moon_glow_factor; - vec4 amb_color = ambient_color; + vec3 amb_color = ambient_color; // increase ambient when there are more clouds - vec4 tmpAmbient = amb_color + (vec4(1.) - amb_color) * 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); - */ - if (use_ao) - { - tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a); - } + vec3 tmpAmbient = amb_color + (vec3(1.) - amb_color) * cloud_shadow * 0.5; // Similar/Shared Algorithms: // indra\llinventory\llsettingssky.cpp -- LLSettingsSky::calculateLightSettings() @@ -128,7 +120,38 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou additive = (blue_horizon.rgb * blue_weight.rgb) * (cs + tmpAmbient.rgb) + (haze_horizon * haze_weight.rgb) * (cs * haze_glow + tmpAmbient.rgb); // brightness of surface both sunlight and ambient - sunlit = sunlight.rgb * 0.5; - amblit = tmpAmbient.rgb * .25; + + sunlit = sunlight.rgb; + amblit = tmpAmbient; + additive *= vec3(1.0 - combined_haze); } + +vec3 srgb_to_linear(vec3 col); + +// provide a touch of lighting in the opposite direction of the sun light + // so areas in shadow don't lose all detail +float ambientLighting(vec3 norm, vec3 light_dir) +{ + float ambient = min(abs(dot(norm.xyz, light_dir.xyz)), 1.0); + ambient *= 0.5; + ambient *= ambient; + ambient = (1.0 - ambient); + return ambient; +} + + +// return lit amblit in linear space, leave sunlit and additive in sRGB space +void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 additive, + out vec3 atten) +{ + calcAtmosphericVars(inPositionEye, light_dir, 1.0, sunlit, amblit, additive, atten); + + // multiply to get similar colors as when the "scaleSoftClip" implementation was doubling color values + // (allows for mixing of light sources other than sunlight e.g. reflection probes) + sunlit *= sky_sunlight_scale; + amblit *= sky_ambient_scale; + + amblit = srgb_to_linear(amblit); + amblit *= ambientLighting(norm, light_dir); +} diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersF.glsl index 206a51db27..800d08047a 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersF.glsl @@ -1,5 +1,5 @@ -/** - * @file class1\windlight\atmosphericsHelpersF.glsl +/** + * @file class2\wl\atmosphericsHelpersV.glsl * * $LicenseInfo:firstyear=2005&license=viewerlgpl$ * Second Life Viewer Source Code @@ -22,30 +22,23 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - -uniform vec4 sunlight_color; -uniform vec4 light_ambient; -uniform int no_atmo; -vec3 atmosAmbient() -{ - if (no_atmo == 1) return vec3(0.16); - return light_ambient.rgb; -} +// Output variables + +uniform float scene_light_strength; -vec3 atmosAffectDirectionalLight(float lightIntensity) +vec3 atmosFragAmbient(vec3 light, vec3 amblit) { - return sunlight_color.rgb * lightIntensity; + return amblit + light / 2.0; } -vec3 atmosGetDiffuseSunlightColor() +vec3 atmosFragAffectDirectionalLight(float lightIntensity, vec3 sunlit) { - return sunlight_color.rgb; + return sunlit * lightIntensity; } -vec3 scaleDownLight(vec3 light) +vec3 scaleDownLightFrag(vec3 light) { - /* stub function for fallback compatibility on class1 hardware */ - return light; + return (light / scene_light_strength ); } diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl index c266f9732f..6ecbfaecb1 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl @@ -1,5 +1,5 @@ -/** - * @file class1\windlight\atmosphericsHelpersV.glsl +/** + * @file class2\wl\atmosphericsHelpersV.glsl * * $LicenseInfo:firstyear=2005&license=viewerlgpl$ * Second Life Viewer Source Code @@ -23,35 +23,35 @@ * $/LicenseInfo$ */ -uniform vec4 sunlight_color; -uniform vec4 light_ambient; -uniform int no_atmo; + + +// Output variables +vec3 getSunlitColor(); +vec3 getAmblitColor(); +vec3 getAdditiveColor(); +vec3 getAtmosAttenuation(); +vec3 getPositionEye(); + +uniform float scene_light_strength; vec3 atmosAmbient() { - if (no_atmo == 1) return vec3(0.66); - return light_ambient.rgb; + return getAmblitColor(); } vec3 atmosAffectDirectionalLight(float lightIntensity) { - return sunlight_color.rgb * lightIntensity; + return getSunlitColor() * lightIntensity; } vec3 atmosGetDiffuseSunlightColor() { - return sunlight_color.rgb; + return getSunlitColor(); } vec3 scaleDownLight(vec3 light) { - /* stub function for fallback compatibility on class1 hardware */ - return light; + return (light / scene_light_strength ); } -vec3 scaleUpLight(vec3 light) -{ - /* stub function for fallback compatibility on class1 hardware */ - return light; -} diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl index 20457ad125..cc3617ba61 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl @@ -1,5 +1,5 @@ -/** - * @file class1\windlight\atmosphericsV.glsl +/** + * @file class2\wl\atmosphericsV.glsl * * $LicenseInfo:firstyear=2005&license=viewerlgpl$ * Second Life Viewer Source Code @@ -22,14 +22,35 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - +// out param funcs + +uniform vec3 sun_dir; +uniform vec3 moon_dir; +uniform int sun_up_factor; + +void setSunlitColor(vec3 v); +void setAmblitColor(vec3 v); +void setAdditiveColor(vec3 v); +void setAtmosAttenuation(vec3 v); void setPositionEye(vec3 v); -void calcAtmospherics(vec3 inPositionEye) -{ - /* stub function for fallback compatibility on class1 hardware */ - setPositionEye(inPositionEye); -} +vec3 getAdditiveColor(); +void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); + +void calcAtmospherics(vec3 inPositionEye) { + vec3 P = inPositionEye; + setPositionEye(P); + vec3 tmpsunlit = vec3(1); + vec3 tmpamblit = vec3(1); + vec3 tmpaddlit = vec3(1); + vec3 tmpattenlit = vec3(1); + vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; + calcAtmosphericVars(inPositionEye, light_dir, 1, tmpsunlit, tmpamblit, tmpaddlit, tmpattenlit); + setSunlitColor(tmpsunlit); + setAmblitColor(tmpamblit); + setAdditiveColor(tmpaddlit); + setAtmosAttenuation(tmpattenlit); +} diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl index 3b4d358cfa..34669a6796 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl @@ -1,37 +1,48 @@ -/** - * @file class1\windlight\atmosphericVarsF.glsl +/** + * @file class2\wl\atmosphericVarsF.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$ */ + -VARYING vec3 vary_AdditiveColor; -VARYING vec3 vary_AtmosAttenuation; - -vec3 getAmblitColor() { return vec3(0, 0, 0); } +in vec3 vary_AdditiveColor; +in vec3 vary_AtmosAttenuation; -vec3 getAdditiveColor() { return vary_AdditiveColor; } +vec3 getSunlitColor() +{ + return vec3(0,0,0); +} -vec3 getAtmosAttenuation() { return vec3(vary_AtmosAttenuation); } +vec3 getAmblitColor() +{ + return vec3(0,0,0); +} -vec3 getSunlitColor() { return vec3(0, 0, 0); } +vec3 getAdditiveColor() +{ + return vary_AdditiveColor; +} -vec3 getPositionEye() { return vec3(0, 0, 0); } +vec3 getAtmosAttenuation() +{ + return vec3(vary_AtmosAttenuation); +} diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl index 1fea2c3628..1b854d80b3 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl @@ -1,30 +1,31 @@ -/** - * @file class1\windlight\atmosphericVarsV.glsl +/** + * @file class2\wl\atmosphericVars.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$ */ + -VARYING vec3 vary_AdditiveColor; -VARYING vec3 vary_AtmosAttenuation; +out vec3 vary_AdditiveColor; +out vec3 vary_AtmosAttenuation; vec3 additive_color; vec3 atmos_attenuation; @@ -32,25 +33,52 @@ vec3 sunlit_color; vec3 amblit_color; vec3 position_eye; -vec3 getSunlitColor() { return sunlit_color; } -void setSunlitColor(vec3 v) { sunlit_color = v; } +vec3 getSunlitColor() +{ + return sunlit_color; +} +vec3 getAmblitColor() +{ + return amblit_color; +} -vec3 getAdditiveColor() { return additive_color; } -void setAdditiveColor(vec3 v) +vec3 getAdditiveColor() +{ + return additive_color; +} +vec3 getAtmosAttenuation() { - additive_color = v; - vary_AdditiveColor = v; + return atmos_attenuation; } -vec3 getAmblitColor() { return amblit_color; } -void setAmblitColor(vec3 v) { amblit_color = v; } +vec3 getPositionEye() +{ + return position_eye; +} -vec3 getAtmosAttenuation() { return atmos_attenuation; } -void setAtmosAttenuation(vec3 v) +void setPositionEye(vec3 v) { - atmos_attenuation = v; - vary_AtmosAttenuation = v; + position_eye = v; } -vec3 getPositionEye() { return position_eye; } -void setPositionEye(vec3 v) { position_eye = v; } +void setSunlitColor(vec3 v) +{ + sunlit_color = v; +} + +void setAmblitColor(vec3 v) +{ + amblit_color = v; +} + +void setAdditiveColor(vec3 v) +{ + additive_color = v; + vary_AdditiveColor = v; +} + +void setAtmosAttenuation(vec3 v) +{ + atmos_attenuation = v; + vary_AtmosAttenuation = v; +} diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterF.glsl index f83434b7ec..7a6741fe0e 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterF.glsl @@ -1,38 +1,50 @@ -/** - * @file class1\windlight\atmosphericVarsWaterF.glsl +/** + * @file class2\wl\atmosphericVarsWaterF.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$ */ + +in vec3 vary_PositionEye; +in vec3 vary_AdditiveColor; +in vec3 vary_AtmosAttenuation; -VARYING vec3 vary_PositionEye; -VARYING vec3 vary_AdditiveColor; -VARYING vec3 vary_AtmosAttenuation; - -vec3 getSunlitColor() { return vec3(0, 0, 0); } - -vec3 getAmblitColor() { return vec3(0, 0, 0); } - -vec3 getAdditiveColor() { return vary_AdditiveColor; } - -vec3 getAtmosAttenuation() { return vary_AtmosAttenuation; } +vec3 getSunlitColor() +{ + return vec3(0,0,0); +} +vec3 getAmblitColor() +{ + return vec3(0,0,0); +} +vec3 getAdditiveColor() +{ + return vary_AdditiveColor; +} +vec3 getAtmosAttenuation() +{ + return vary_AtmosAttenuation; +} +vec3 getPositionEye() +{ + return vary_PositionEye; +} -vec3 getPositionEye() { return vary_PositionEye; } diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterV.glsl index 65d1176777..23c3aed4d8 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterV.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterV.glsl @@ -1,51 +1,81 @@ -/** - * @file class1\windlight\atmosphericVarsWaterV.glsl +/** + * @file class2\wl\atmosphericVarsWaterV.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$ */ - -VARYING vec3 vary_PositionEye; -VARYING vec3 vary_AdditiveColor; -VARYING vec3 vary_AtmosAttenuation; + +out vec3 vary_PositionEye; +out vec3 vary_AdditiveColor; +out vec3 vary_AtmosAttenuation; vec3 atmos_attenuation; vec3 sunlit_color; vec3 amblit_color; -vec3 getSunlitColor() { return sunlit_color; } -void setSunlitColor(vec3 v) { sunlit_color = v; } +vec3 getSunlitColor() +{ + return sunlit_color; +} +vec3 getAmblitColor() +{ + return amblit_color; +} + +vec3 getAdditiveColor() +{ + return vary_AdditiveColor; +} +vec3 getAtmosAttenuation() +{ + return atmos_attenuation; +} + +vec3 getPositionEye() +{ + return vary_PositionEye; +} + +void setPositionEye(vec3 v) +{ + vary_PositionEye = v; +} + +void setSunlitColor(vec3 v) +{ + sunlit_color = v; +} -vec3 getAmblitColor() { return amblit_color; } -void setAmblitColor(vec3 v) { amblit_color = v; } +void setAmblitColor(vec3 v) +{ + amblit_color = v; +} -vec3 getAdditiveColor() { return vary_AdditiveColor; } -void setAdditiveColor(vec3 v) { vary_AdditiveColor = v; } +void setAdditiveColor(vec3 v) +{ + vary_AdditiveColor = v; +} -vec3 getAtmosAttenuation() { return atmos_attenuation; } void setAtmosAttenuation(vec3 v) { - atmos_attenuation = v; - vary_AtmosAttenuation = v; + atmos_attenuation = v; + vary_AtmosAttenuation = v; } - -vec3 getPositionEye() { return vary_PositionEye; } -void setPositionEye(vec3 v) { vary_PositionEye = v; } diff --git a/indra/newview/app_settings/shaders/class1/windlight/cloudShadowF.glsl b/indra/newview/app_settings/shaders/class1/windlight/cloudShadowF.glsl deleted file mode 100644 index 82fad4db5a..0000000000 --- a/indra/newview/app_settings/shaders/class1/windlight/cloudShadowF.glsl +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @file class1/windlight/cloudShadowF.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, 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$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2D diffuseMap; - -VARYING vec4 pos; -VARYING float target_pos_x; -VARYING float vary_CloudDensity; -VARYING vec2 vary_texcoord0; -VARYING vec2 vary_texcoord1; -VARYING vec2 vary_texcoord2; -VARYING vec2 vary_texcoord3; - -uniform sampler2D cloud_noise_texture; -uniform sampler2D cloud_noise_texture_next; -uniform float blend_factor; -uniform vec4 cloud_pos_density1; -uniform vec4 cloud_pos_density2; -uniform vec4 sunlight_color; -uniform vec4 cloud_color; -uniform float cloud_shadow; -uniform float cloud_scale; -uniform float cloud_variance; -uniform vec3 camPosLocal; -uniform vec3 sun_dir; -uniform float sun_size; -uniform float far_z; - -#if !defined(DEPTH_CLAMP) -VARYING vec4 post_pos; -#endif - -vec4 cloudNoise(vec2 uv) -{ - vec4 a = texture2D(cloud_noise_texture, uv); - vec4 b = texture2D(cloud_noise_texture_next, uv); - vec4 cloud_noise_sample = mix(a, b, blend_factor); - return normalize(cloud_noise_sample); -} - -void main() -{ - if (cloud_scale >= 0.0001) - { - // Set variables - vec2 uv1 = vary_texcoord0.xy; - vec2 uv2 = vary_texcoord1.xy; - vec2 uv3 = vary_texcoord2.xy; - float cloudDensity = 2.0 * (cloud_shadow - 0.25); - - vec2 uv4 = vary_texcoord3.xy; - - vec2 disturbance = vec2(cloudNoise(uv1 / 8.0f).x, cloudNoise((uv3 + uv1) / 16.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); - vec2 disturbance2 = vec2(cloudNoise((uv1 + uv3) / 4.0f).x, cloudNoise((uv4 + uv2) / 8.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); - - // Offset texture coords - uv1 += cloud_pos_density1.xy + (disturbance * 0.2); //large texture, visible density - uv2 += cloud_pos_density1.xy; //large texture, self shadow - uv3 += cloud_pos_density2.xy; //small texture, visible density - uv4 += cloud_pos_density2.xy; //small texture, self shadow - - float density_variance = min(1.0, (disturbance.x* 2.0 + disturbance.y* 2.0 + disturbance2.x + disturbance2.y) * 4.0); - - cloudDensity *= 1.0 - (density_variance * density_variance); - - // Compute alpha1, the main cloud opacity - float alpha1 = (cloudNoise(uv1).x - 0.5) + (cloudNoise(uv3).x - 0.5) * cloud_pos_density2.z; - alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10 * cloud_pos_density1.z, 1.); - - // And smooth - alpha1 = 1. - alpha1 * alpha1; - alpha1 = 1. - alpha1 * alpha1; - - if (alpha1 < 0.001f) - { - discard; - } - - // Compute alpha2, for self shadowing effect - // (1 - alpha2) will later be used as percentage of incoming sunlight - float alpha2 = (cloudNoise(uv2).x - 0.5); - alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.); - - // And smooth - alpha2 = 1. - alpha2; - alpha2 = 1. - alpha2 * alpha2; - - frag_color = vec4(alpha1, alpha1, alpha1, 1); - } - else - { - frag_color = vec4(1); - } - -#if !defined(DEPTH_CLAMP) - gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); -#endif - -} diff --git a/indra/newview/app_settings/shaders/class1/windlight/cloudShadowV.glsl b/indra/newview/app_settings/shaders/class1/windlight/cloudShadowV.glsl deleted file mode 100644 index 09b6004481..0000000000 --- a/indra/newview/app_settings/shaders/class1/windlight/cloudShadowV.glsl +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @file class1\windlight\cloudShadowV.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, 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$ - */ - -uniform mat4 texture_matrix0; -uniform mat4 modelview_projection_matrix; -uniform float shadow_target_width; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec4 diffuse_color; -ATTRIBUTE vec2 texcoord0; - -#if !defined(DEPTH_CLAMP) -VARYING float pos_zd2; -#endif - -VARYING vec4 pos; -VARYING float target_pos_x; -VARYING vec2 vary_texcoord0; - -void passTextureIndex(); - -void main() -{ - //transform vertex - vec4 pre_pos = vec4(position.xyz, 1.0); - pos = modelview_projection_matrix * pre_pos; - target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x; - -#if !defined(DEPTH_CLAMP) - pos_zd2 = pos.z * 0.5; - gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); -#else - gl_Position = pos; -#endif - - passTextureIndex(); - - vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; -} diff --git a/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl b/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl index fc51e81177..027bfb866f 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl @@ -1,5 +1,5 @@ /** - * @file class1\windlight\gammaF.glsl + * @file class2\wl\gammaF.glsl * * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code @@ -22,31 +22,34 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - -uniform int no_atmo; + + // DEPRECATED + +//soft clip effect has been moved to postDeferredGammaCorrect legacyGamma, this file is effectively dead +// but these functions need to be removed from all existing shaders before removing this file vec3 scaleSoftClipFrag(vec3 light) { - // For compatibility with lower cards. Do nothing. - return light; + return light; +} + +vec3 scaleSoftClipFragLinear(vec3 light) +{ // identical to non-linear version and that's probably close enough + return light; } -/// Soft clips the light with a gamma correction vec3 scaleSoftClip(vec3 light) { - // For compatibility with lower cards. Do nothing - return light; + return light; } -vec3 fullbrightScaleSoftClipFrag(vec3 light, vec3 additive, vec3 atten) +vec3 fullbrightScaleSoftClipFrag(vec3 light, vec3 add, vec3 atten) { - // For compatibility with lower cards. Do nothing - return light; + return light; } vec3 fullbrightScaleSoftClip(vec3 light) { - // For compatibility with lower cards. Do nothing return light; } diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl deleted file mode 100644 index 2425a2ad04..0000000000 --- a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @file class1\wl\moonF.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, 2020 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$ - */ - -#extension GL_ARB_texture_rectangle : enable - -/*[EXTRA_CODE_HERE]*/ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform vec4 color; -uniform vec4 sunlight_color; -uniform vec4 moonlight_color; -uniform vec3 moon_dir; -uniform float moon_brightness; -uniform sampler2D diffuseMap; - -VARYING vec2 vary_texcoord0; - -vec3 scaleSoftClip(vec3 light); - -void main() -{ - // Restore Pre-EEP alpha fade moon near horizon - float fade = 1.0; - if( moon_dir.z > 0 ) - fade = clamp( moon_dir.z*moon_dir.z*4.0, 0.0, 1.0 ); - - vec4 c = texture2D(diffuseMap, vary_texcoord0.xy); -// c.rgb = pow(c.rgb, vec3(0.7f)); // can't use "srgb_to_linear(color.rgb)" as that is a deferred only function - c.rgb *= moonlight_color.rgb; - c.rgb *= moon_brightness; - - c.rgb *= fade; - c.a *= fade; - - c.rgb = scaleSoftClip(c.rgb); - - frag_color = vec4(c.rgb, c.a); -} - diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonV.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonV.glsl deleted file mode 100644 index 2fceb5f743..0000000000 --- a/indra/newview/app_settings/shaders/class1/windlight/moonV.glsl +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @file class1\wl\moonV.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 2020 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$ - */ - -uniform mat4 texture_matrix0; -uniform mat4 modelview_matrix; -uniform mat4 modelview_projection_matrix; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec2 texcoord0; - -VARYING vec2 vary_texcoord0; - -void main() -{ - //transform vertex - vec4 vert = vec4(position.xyz, 1.0); - vec4 pos = (modelview_matrix * vert); - - gl_Position = modelview_projection_matrix*vert; - - vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; -} diff --git a/indra/newview/app_settings/shaders/class1/windlight/sunDiscF.glsl b/indra/newview/app_settings/shaders/class1/windlight/sunDiscF.glsl deleted file mode 100644 index 5a41dc644a..0000000000 --- a/indra/newview/app_settings/shaders/class1/windlight/sunDiscF.glsl +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @file class1\wl\sunDiscF.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, 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$ - */ - -#extension GL_ARB_texture_rectangle : enable - -/*[EXTRA_CODE_HERE]*/ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -vec3 fullbrightAtmosTransport(vec3 light); -vec3 fullbrightScaleSoftClip(vec3 light); - -uniform sampler2D diffuseMap; -uniform sampler2D altDiffuseMap; -uniform float blend_factor; // interp factor between sun A/B -VARYING vec2 vary_texcoord0; -VARYING float sun_fade; - -void main() -{ - vec4 sunA = texture2D(diffuseMap, vary_texcoord0.xy); - vec4 sunB = texture2D(altDiffuseMap, vary_texcoord0.xy); - vec4 c = mix(sunA, sunB, blend_factor); - -// SL-9806 stars poke through -// c.a *= sun_fade; - - c.rgb = fullbrightAtmosTransport(c.rgb); - c.rgb = fullbrightScaleSoftClip(c.rgb); - frag_color = c; -} - diff --git a/indra/newview/app_settings/shaders/class1/windlight/sunDiscV.glsl b/indra/newview/app_settings/shaders/class1/windlight/sunDiscV.glsl deleted file mode 100644 index 6c0e795f6b..0000000000 --- a/indra/newview/app_settings/shaders/class1/windlight/sunDiscV.glsl +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @file class1\wl\sunDiscV.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$ - */ - -uniform mat4 texture_matrix0; -uniform mat4 modelview_matrix; -uniform mat4 modelview_projection_matrix; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec2 texcoord0; - -VARYING vec2 vary_texcoord0; -VARYING float sun_fade; - -void calcAtmospherics(vec3 eye_pos); - -void main() -{ - //transform vertex - vec3 offset = vec3(0, 0, 50); - vec4 vert = vec4(position.xyz - offset, 1.0); - vec4 pos = modelview_projection_matrix*vert; - - sun_fade = smoothstep(0.3, 1.0, (position.z + 50) / 512.0f); - gl_Position = pos; - - calcAtmospherics(pos.xyz); - - vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; -} diff --git a/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl deleted file mode 100644 index a937d9fa99..0000000000 --- a/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @file class1/windlight/transportF.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, 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$ - */ - -uniform int no_atmo; - -vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten) -{ - /* stub function for fallback compatibility on class1 hardware */ - return light; -} - -vec3 atmosTransport(vec3 light) -{ - /* stub function for fallback compatibility on class1 hardware */ - return light; -} - -vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) -{ - /* stub function for fallback compatibility on class1 hardware */ - return light; -} - -vec3 fullbrightAtmosTransport(vec3 light) -{ - /* stub function for fallback compatibility on class1 hardware */ - return light; -} - -vec3 fullbrightShinyAtmosTransport(vec3 light) -{ - /* stub function for fallback compatibility on class1 hardware */ - return light; -} |