Apertura del repositorio

This commit is contained in:
2025-05-24 18:09:39 -03:00
parent 76e6359dad
commit d883ddd0d0
35253 changed files with 2891973 additions and 2 deletions
@@ -0,0 +1,133 @@
/**
* @file srgbF.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$
*/
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
}
vec4 srgb_to_linear4(vec4 cs)
{
vec4 low_range = cs / vec4(12.92);
vec4 high_range = pow((cs+vec4(0.055))/vec4(1.055), vec4(2.4));
bvec4 lte = lessThanEqual(cs,vec4(0.04045));
#ifdef OLD_SELECT
vec4 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;
result.a = lte.a ? low_range.a : high_range.a;
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 ColorFromRadiance(vec3 radiance)
{
return vec3(1.0) - exp(-radiance * 0.0001);
}
vec3 rgb2hsv(vec3 c)
{
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-3;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
const mat3 inv_ACESOutputMat = mat3(0.643038, 0.0592687, 0.0059619, 0.311187, 0.931436, 0.063929, 0.0457755, 0.00929492, 0.930118 );
const mat3 inv_ACESInputMat = mat3( 1.76474, -0.147028, -0.0363368, -0.675778, 1.16025, -0.162436, -0.0889633, -0.0132237, 1.19877 );
vec3 inv_RRTAndODTFit(vec3 x)
{
float A = 0.0245786;
float B = 0.000090537;
float C = 0.983729;
float D = 0.4329510;
float E = 0.238081;
return (A - D * x)/(2.0 * (C * x - 1.0)) - sqrt(pow(D * x - A, vec3(2.0)) - 4.0 * (C * x - 1.0) * (B + E * x))/(2.0 * (C * x - 1.0));
}
// experimental inverse of ACES Hill tonemapping
vec3 inv_toneMapACES_Hill(vec3 color)
{
color = inv_ACESOutputMat * color;
// Apply RRT and ODT
color = inv_RRTAndODTFit(color);
color = inv_ACESInputMat * color;
return color;
}
@@ -0,0 +1,34 @@
/**
* @file waterF.glsl
*
* $LicenseInfo:firstyear=2023&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2023, 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$
*/
// error fallback on compilation failure
out vec4 frag_color;
void main()
{
frag_color = vec4(1,0,1,1);
}
@@ -0,0 +1,144 @@
/**
* @file class1\environment\waterFogF.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 vec4 waterPlane;
uniform vec4 waterFogColor;
uniform float waterFogDensity;
uniform float waterFogKS;
vec3 srgb_to_linear(vec3 col);
vec3 linear_to_srgb(vec3 col);
vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten);
// get a water fog color that will apply the appropriate haze to a color given
// a blend function of (ONE, SOURCE_ALPHA)
vec4 getWaterFogViewNoClip(vec3 pos)
{
vec3 view = normalize(pos);
//normalize view vector
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 = pow(min(t1/t2*t3, 1.0), 1.0/1.7);
float D = pow(0.98, l*kd);
return vec4(srgb_to_linear(kc.rgb)*L, D);
}
vec4 getWaterFogView(vec3 pos)
{
if (dot(pos, waterPlane.xyz) + waterPlane.w > 0.0)
{
return vec4(0,0,0,1);
}
return getWaterFogViewNoClip(pos);
}
vec4 applyWaterFogView(vec3 pos, vec4 color)
{
vec4 fogged = getWaterFogView(pos);
color.rgb = color.rgb * fogged.a + fogged.rgb;
return color;
}
vec4 applyWaterFogViewLinearNoClip(vec3 pos, vec4 color)
{
vec4 fogged = getWaterFogViewNoClip(pos);
color.rgb *= fogged.a;
color.rgb += fogged.rgb;
return color;
}
vec4 applyWaterFogViewLinear(vec3 pos, vec4 color)
{
if (dot(pos, waterPlane.xyz) + waterPlane.w > 0.0)
{
return color;
}
return applyWaterFogViewLinearNoClip(pos, color);
}
// for post deferred shaders, apply sky and water fog in a way that is consistent with
// the deferred rendering haze post effects
vec4 applySkyAndWaterFog(vec3 pos, vec3 additive, vec3 atten, vec4 color)
{
bool eye_above_water = dot(vec3(0), waterPlane.xyz) + waterPlane.w > 0.0;
bool obj_above_water = dot(pos.xyz, waterPlane.xyz) + waterPlane.w > 0.0;
if (eye_above_water)
{
if (!obj_above_water)
{
color.rgb = applyWaterFogViewLinearNoClip(pos, color).rgb;
}
else
{
color.rgb = atmosFragLighting(color.rgb, additive, atten);
}
}
else
{
if (obj_above_water)
{
color.rgb = atmosFragLighting(color.rgb, additive, atten);
}
else
{
color.rgb = applyWaterFogViewLinearNoClip(pos, color).rgb;
}
}
return color;
}
@@ -0,0 +1,109 @@
/**
* @file class1\environment\waterV.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 modelview_matrix;
uniform mat3 normal_matrix;
uniform mat4 modelview_projection_matrix;
in vec3 position;
void calcAtmospherics(vec3 inPositionEye);
uniform vec2 waveDir1;
uniform vec2 waveDir2;
uniform float time;
uniform vec3 eyeVec;
uniform float waterHeight;
uniform vec3 lightDir;
out vec4 refCoord;
out vec4 littleWave;
out vec4 view;
out vec3 vary_position;
out vec3 vary_light_dir;
out vec3 vary_tangent;
out vec3 vary_normal;
out vec2 vary_fragcoord;
float wave(vec2 v, float t, float f, vec2 d, float s)
{
return (dot(d, v)*f + t*s)*f;
}
void main()
{
//transform vertex
vec4 pos = vec4(position.xyz, 1.0);
mat4 modelViewProj = modelview_projection_matrix;
vary_position = (modelview_matrix * pos).xyz;
vary_light_dir = normal_matrix * lightDir;
vary_normal = normal_matrix * vec3(0, 0, 1);
vary_tangent = normal_matrix * vec3(1, 0, 0);
vec4 oPosition;
//get view vector
vec3 oEyeVec;
oEyeVec.xyz = pos.xyz-eyeVec;
float d = length(oEyeVec.xy);
float ld = min(d, 2560.0);
pos.xy = eyeVec.xy + oEyeVec.xy/d*ld;
view.xyz = oEyeVec;
d = clamp(ld/1536.0-0.5, 0.0, 1.0);
d *= d;
oPosition = vec4(position, 1.0);
// oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d); // SL-11589 remove "U" shaped horizon
oPosition = modelViewProj * oPosition;
refCoord.xyz = oPosition.xyz + vec3(0,0,0.2);
//get wave position parameter (create sweeping horizontal waves)
vec3 v = pos.xyz;
v.x += (cos(v.x*0.08/*+time*0.01*/)+sin(v.y*0.02))*6.0;
//push position for further horizon effect.
pos.xyz = oEyeVec.xyz*(waterHeight/oEyeVec.z);
pos.w = 1.0;
pos = modelview_matrix*pos;
calcAtmospherics(pos.xyz);
//pass wave parameters to pixel shader
vec2 bigWave = (v.xy) * vec2(0.04,0.04) + waveDir1 * time * 0.055;
//get two normal map (detail map) texture coordinates
littleWave.xy = (v.xy) * vec2(0.45, 0.9) + waveDir2 * time * 0.13;
littleWave.zw = (v.xy) * vec2(0.1, 0.2) + waveDir1 * time * 0.1;
view.w = bigWave.y;
refCoord.w = bigWave.x;
gl_Position = oPosition;
}