DRTVWR-528, delete all unreferenced shader files, improve dev QoL

meow-7.2.2
Dave Houlton 2021-03-18 18:01:23 -06:00
parent 896dc82f6b
commit e745da0c0b
25 changed files with 0 additions and 1854 deletions

View File

@ -1,112 +0,0 @@
/**
* @file avatarAlphaNoColorV.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 projection_matrix;
ATTRIBUTE vec3 position;
ATTRIBUTE vec3 normal;
ATTRIBUTE vec2 texcoord0;
mat4 getSkinnedTransform();
void calcAtmospherics(vec3 inPositionEye);
float calcDirectionalLight(vec3 n, vec3 l);
vec3 atmosAmbient();
vec3 atmosAffectDirectionalLight(float lightIntensity);
VARYING vec3 vary_position;
VARYING vec3 vary_ambient;
VARYING vec3 vary_directional;
VARYING vec3 vary_fragcoord;
VARYING vec3 vary_pointlight_col;
VARYING vec2 vary_texcoord0;
VARYING vec3 vary_norm;
uniform float near_clip;
uniform vec4 color;
uniform vec4 light_position[8];
uniform vec3 light_direction[8];
uniform vec3 light_attenuation[8];
uniform vec3 light_diffuse[8];
float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight);
void main()
{
vary_texcoord0 = texcoord0;
vec4 pos;
vec3 norm;
mat4 trans = getSkinnedTransform();
vec4 pos_in = vec4(position.xyz, 1.0);
pos.x = dot(trans[0], pos_in);
pos.y = dot(trans[1], pos_in);
pos.z = dot(trans[2], pos_in);
pos.w = 1.0;
norm.x = dot(trans[0].xyz, normal);
norm.y = dot(trans[1].xyz, normal);
norm.z = dot(trans[2].xyz, normal);
norm = normalize(norm);
vary_norm = norm;
vec4 frag_pos = projection_matrix * pos;
gl_Position = frag_pos;
vary_position = pos.xyz;
calcAtmospherics(pos.xyz);
vec4 col = vec4(0.0, 0.0, 0.0, 1.0);
// Collect normal lights
col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z);
col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z);
col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z);
col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z);
col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z);
col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z);
vary_pointlight_col = col.rgb*color.rgb;
col.rgb = vec3(0,0,0);
// Add windlight lights
col.rgb = atmosAmbient();
vary_ambient = col.rgb*color.rgb;
vary_directional = color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), 0.0));
col.rgb = col.rgb * color.rgb;
vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip);
}

View File

@ -1,127 +0,0 @@
/**
* @file class3/deferred/cloudsF.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()
{
// 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);
if (cloud_scale >= 0.0001)
{
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
}

View File

@ -1,63 +0,0 @@
/**
* @file 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;
VARYING vec4 vertex_color;
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;
vertex_color = diffuse_color;
}

View File

@ -1,40 +0,0 @@
/**
* @file luminanceF.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]*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseMap;
VARYING vec2 vary_fragcoord;
void main()
{
frag_color = texture2DRect(diffuseMap, vary_fragcoord.xy);
}

View File

@ -1,45 +0,0 @@
/**
* @file giV.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_projection_matrix;
ATTRIBUTE vec3 position;
ATTRIBUTE vec4 diffuse_color;
VARYING vec2 vary_fragcoord;
VARYING vec4 vertex_color;
uniform vec2 screen_res;
void main()
{
//transform vertex
vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res;
vertex_color = diffuse_color;
}

View File

@ -1,99 +0,0 @@
/**
* @file postgiF.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]*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect depthMap;
uniform sampler2DRect normalMap;
uniform sampler2DRect giLightMap;
uniform sampler2D noiseMap;
uniform vec2 kern[32];
uniform float dist_factor;
uniform float blur_size;
uniform vec2 delta;
uniform int kern_length;
uniform float kern_scale;
uniform vec3 blur_quad;
VARYING vec2 vary_fragcoord;
uniform mat4 inv_proj;
uniform vec2 screen_res;
vec4 getPosition(vec2 pos_screen);
void main()
{
vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz;
norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
vec3 pos = getPosition(vary_fragcoord.xy).xyz;
vec3 ccol = texture2DRect(giLightMap, vary_fragcoord.xy).rgb;
vec2 dlt = kern_scale * delta/(1.0+norm.xy*norm.xy);
dlt /= max(-pos.z*dist_factor, 1.0);
float defined_weight = kern[0].x;
vec3 col = vec3(0.0);
for (int i = 0; i < kern_length; i++)
{
vec2 tc = vary_fragcoord.xy + kern[i].y*dlt;
vec3 sampNorm = texture2DRect(normalMap, tc.xy).xyz;
sampNorm = vec3((sampNorm.xy-0.5)*2.0,sampNorm.z); // unpack norm
float d = dot(norm.xyz, sampNorm);
if (d > 0.8)
{
vec3 samppos = getPosition(tc.xy).xyz;
samppos -= pos;
if (dot(samppos,samppos) < -0.05*pos.z)
{
col += texture2DRect(giLightMap, tc).rgb*kern[i].x;
defined_weight += kern[i].x;
}
}
}
col /= defined_weight;
//col = ccol;
col = col*col*blur_quad.x + col*blur_quad.y + blur_quad.z;
frag_color.rgb = col;
#ifdef IS_AMD_CARD
// If it's AMD make sure the GLSL compiler sees the arrays referenced once by static index. Otherwise it seems to optimise the storage awawy which leads to unfun crashes and artifacts.
vec2 dummy1 = kern[0];
vec2 dummy2 = kern[31];
#endif
}

View File

@ -1,55 +0,0 @@
/**
* @file shadowAlphaMaskF.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$
*/
/*[EXTRA_CODE_HERE]*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2D diffuseMap;
#if !defined(DEPTH_CLAMP)
VARYING float pos_zd2;
#endif
VARYING float pos_w;
VARYING float target_pos_x;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
void main()
{
float alpha = diffuseLookup(vary_texcoord0.xy).a * vertex_color.a;
frag_color = vec4(alpha, alpha, alpha, 1);
#if !defined(DEPTH_CLAMP)
gl_FragDepth = max(pos_zd2/pos_w+0.5, 0.0);
#endif
}

View File

@ -1,67 +0,0 @@
/**
* @file shadowAlphaMaskV.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 float pos_w;
VARYING float target_pos_x;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
void passTextureIndex();
void main()
{
//transform vertex
vec4 pre_pos = vec4(position.xyz, 1.0);
vec4 pos = modelview_projection_matrix * pre_pos;
target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x;
pos_w = pos.w;
#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;
vertex_color = diffuse_color;
}

View File

@ -1,33 +0,0 @@
/**
* @file fullbrightF.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$
*/
void main()
{
fullbright_lighting();
}

View File

@ -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
}

View File

@ -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;
}

View File

@ -1,119 +0,0 @@
/**
* @file class3/deferred/cloudsF.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 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;
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);
}
vec4 computeMoments(float depth, float alpha);
void main()
{
if (cloud_scale >= 0.001)
{
// 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 = computeMoments(length(pos), alpha1);
}
else
{
frag_color = vec4(0);
}
}

View File

@ -1,63 +0,0 @@
/**
* @file 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;
VARYING vec4 vertex_color;
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;
vertex_color = diffuse_color;
}

View File

@ -1,202 +0,0 @@
/**
* @file depthToShadowVolumeG.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$
*/
#extension GL_ARB_geometry_shader4 : enable
#extension GL_ARB_texture_rectangle : enable
/*[EXTRA_CODE_HERE]*/
layout (triangles) in;
layout (triangle_strip, max_vertices = 128) out;
uniform sampler2DRect depthMap;
uniform mat4 shadowMatrix[6];
uniform vec4 lightpos;
VARYING vec2 vary_texcoord0;
out vec3 to_vec;
void cross_products(out vec4 ns[3], int a, int b, int c)
{
ns[0] = cross(gl_PositionIn[b].xyz - gl_PositionIn[a].xyz, gl_PositionIn[c].xyz - gl_PositionIn[a].xyz);
ns[1] = cross(gl_PositionIn[c].xyz - gl_PositionIn[b].xyz, gl_PositionIn[a].xyz - gl_PositionIn[b].xyz);
ns[2] = cross(gl_PositionIn[a].xyz - gl_PositionIn[c].xyz, gl_PositionIn[b].xyz - gl_PositionIn[c].xyz);
}
vec3 getLightDirection(vec4 lightpos, vec3 pos)
{
vec3 lightdir = lightpos.xyz - lightpos.w * pos;
return lightdir;
}
void emitTri(vec4 v[3])
{
gl_Position = proj_matrix * v[0];
EmitVertex();
gl_Position = proj_matrix * v[1];
EmitVertex();
gl_Position = proj_matrix * v[2];
EmitVertex();
EndPrimitive();
}
void emitQuad(vec4 v[4]
{
// Emit a quad as a triangle strip.
gl_Position = proj_matrix*v[0];
EmitVertex();
gl_Position = proj_matrix*v[1];
EmitVertex();
gl_Position = proj_matrix*v[2];
EmitVertex();
gl_Position = proj_matrix*v[3];
EmitVertex();
EndPrimitive();
}
void emitPrimitives(int layer)
{
int i = layer;
gl_Layer = i;
vec4 depth1 = vec4(texture2DRect(depthMap, tc0).rg, texture2DRect(depthMap, tc1).rg));
vec3 depth2 = vec4(texture2DRect(depthMap, tc2).rg, texture2DRect(depthMap, tc3).rg));
vec3 depth3 = vec4(texture2DRect(depthMap, tc4).rg, texture2DRect(depthMap, tc5).rg));
vec3 depth4 = vec4(texture2DRect(depthMap, tc6).rg, texture2DRect(depthMap, tc7).rg));
depth1 = min(depth1, depth2);
depth1 = min(depth1, depth3);
depth1 = min(depth1, depth4);
vec2 depth = min(depth1.xy, depth1.zw);
int side = sqrt(gl_VerticesIn);
for (int j = 0; j < side; j++)
{
for (int k = 0; k < side; ++k)
{
vec3 pos = gl_PositionIn[(j * side) + k].xyz;
vec4 v = shadowMatrix[i] * vec4(pos, 1.0);
gl_Position = v;
to_vec = pos - light_position.xyz * depth;
EmitVertex();
}
EndPrimitive();
}
vec3 norms[3]; // Normals
vec3 lightdir3]; // Directions toward light
vec4 v[4]; // Temporary vertices
vec4 or_pos[3] =
{ // Triangle oriented toward light source
gl_PositionIn[0],
gl_PositionIn[2],
gl_PositionIn[4]
};
// Compute normal at each vertex.
cross_products(n, 0, 2, 4);
// Compute direction from vertices to light.
lightdir[0] = getLightDirection(lightpos, gl_PositionIn[0].xyz);
lightdir[1] = getLightDirection(lightpos, gl_PositionIn[2].xyz);
lightdir[2] = getLightDirection(lightpos, gl_PositionIn[4].xyz);
// Check if the main triangle faces the light.
bool faces_light = true;
if (!(dot(ns[0],d[0]) > 0
|dot(ns[1],d[1]) > 0
|dot(ns[2],d[2]) > 0))
{
// Flip vertex winding order in or_pos.
or_pos[1] = gl_PositionIn[4];
or_pos[2] = gl_PositionIn[2];
faces_light = false;
}
// Near cap: simply render triangle.
emitTri(or_pos);
// Far cap: extrude positions to infinity.
v[0] =vec4(lightpos.w * or_pos[0].xyz - lightpos.xyz,0);
v[1] =vec4(lightpos.w * or_pos[2].xyz - lightpos.xyz,0);
v[2] =vec4(lightpos.w * or_pos[1].xyz - lightpos.xyz,0);
emitTri(v);
// Loop over all edges and extrude if needed.
for ( int i=0; i<3; i++ )
{
// Compute indices of neighbor triangle.
int v0 = i*2;
int nb = (i*2+1);
int v1 = (i*2+2) % 6;
cross_products(n, v0, nb, v1);
// Compute direction to light, again as above.
d[0] =lightpos.xyz-lightpos.w*gl_PositionIn[v0].xyz;
d[1] =lightpos.xyz-lightpos.w*gl_PositionIn[nb].xyz;
d[2] =lightpos.xyz-lightpos.w*gl_PositionIn[v1].xyz;
bool is_parallel = gl_PositionIn[nb].w < 1e-5;
// Extrude the edge if it does not have a
// neighbor, or if it's a possible silhouette.
if (is_parallel ||
( faces_light != (dot(ns[0],d[0])>0 ||
dot(ns[1],d[1])>0 ||
dot(ns[2],d[2])>0) ))
{
// Make sure sides are oriented correctly.
int i0 = faces_light ? v0 : v1;
int i1 = faces_light ? v1 : v0;
v[0] = gl_PositionIn[i0];
v[1] = vec4(lightpos.w*gl_PositionIn[i0].xyz - lightpos.xyz, 0);
v[2] = gl_PositionIn[i1];
v[3] = vec4(lightpos.w*gl_PositionIn[i1].xyz - lightpos.xyz, 0);
emitQuad(v);
}
}
}
void main()
{
// Output
emitPrimitives(0);
}

View File

@ -1,70 +0,0 @@
/**
* @file class3/deferred/gatherSkyShF.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_data[3];
#else
#define frag_data gl_FragData
#endif
VARYING vec2 vary_frag;
uniform vec2 screen_res;
uniform sampler2D sh_input_r;
uniform sampler2D sh_input_g;
uniform sampler2D sh_input_b;
void main()
{
vec2 offset = vec2(2.0) / screen_res;
vec4 r = vec4(0);
vec4 g = vec4(0);
vec4 b = vec4(0);
vec2 tc = vary_frag * 2.0;
r += texture2D(sh_input_r, tc + vec2(0, 0));
r += texture2D(sh_input_r, tc + vec2(offset.x, 0));
r += texture2D(sh_input_r, tc + vec2(0, offset.y));
r += texture2D(sh_input_r, tc + vec2(offset.x, offset.y));
r /= 4.0f;
g += texture2D(sh_input_g, tc + vec2(0, 0));
g += texture2D(sh_input_g, tc + vec2(offset.x, 0));
g += texture2D(sh_input_g, tc + vec2(0, offset.y));
g += texture2D(sh_input_g, tc + vec2(offset.x, offset.y));
g /= 4.0f;
b += texture2D(sh_input_b, tc + vec2(0, 0));
b += texture2D(sh_input_b, tc + vec2(offset.x, 0));
b += texture2D(sh_input_b, tc + vec2(0, offset.y));
b += texture2D(sh_input_b, tc + vec2(offset.x, offset.y));
b /= 4.0f;
frag_data[0] = r;
frag_data[1] = g;
frag_data[2] = b;
}

View File

@ -1,40 +0,0 @@
/**
* @file gatherSkyShV.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$
*/
ATTRIBUTE vec3 position;
ATTRIBUTE vec2 texcoord0;
VARYING vec2 vary_frag;
uniform vec2 screen_res;
void main()
{
// pass through untransformed fullscreen pos
float oo_divisor = screen_res.x / 64.0;
vec3 pos = (position.xyz * oo_divisor) + vec3(oo_divisor - 1, oo_divisor - 1, 0);
gl_Position = vec4(pos.xyz, 1.0);
vary_frag = texcoord0 * oo_divisor;
}

View File

@ -1,111 +0,0 @@
/**
* @file class3/deferred/genSkyShF.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_data[3];
#else
#define frag_data gl_FragData
#endif
VARYING vec2 vary_frag;
uniform vec3 sun_dir;
uniform sampler2D transmittance_texture;
uniform sampler3D scattering_texture;
uniform sampler3D single_mie_scattering_texture;
uniform sampler2D irradiance_texture;
vec3 GetSkyLuminance(vec3 camPos, vec3 view_dir, float shadow_length, vec3 dir, out vec3 transmittance);
vec3 calcDirection(vec2 tc)
{
float phi = tc.y * 2.0 * 3.14159265;
float cosTheta = sqrt(1.0 - tc.x);
float sinTheta = sqrt(1.0 - cosTheta * cosTheta);
return vec3(cos(phi) * sinTheta, sin(phi) * sinTheta, cosTheta);
}
// reverse mapping above to convert a hemisphere direction into phi/theta values
void getPhiAndThetaFromDirection(vec3 dir, out float phi, out float theta)
{
float sin_theta;
float cos_theta;
cos_theta = dir.z;
theta = acos(cos_theta);
sin_theta = sin(theta);
phi = abs(sin_theta) > 0.0001 ? acos(dir.x / sin_theta) : 1.0;
}
// reverse mapping above to convert a hemisphere direction into an SH texture sample pos
vec2 calcShUvFromDirection(vec3 dir)
{
vec2 uv;
float phi;
float theta;
getPhiAndThetaFromDirection(dir, phi, theta);
uv.y = phi / 2.0 * 3.14159265;
uv.x = theta / 2.0 * 3.14159265;
return uv;
}
void projectToL1(vec3 n, vec3 c, vec4 basis, out vec4 coeffs[3])
{
coeffs[0] = vec4(basis.x, n * basis.yzw * c.r);
coeffs[1] = vec4(basis.x, n * basis.yzw * c.g);
coeffs[2] = vec4(basis.x, n * basis.yzw * c.b);
}
void main()
{
float Y00 = sqrt(1.0 / 3.14159265) * 0.5;
float Y1x = sqrt(3.0 / 3.14159265) * 0.5;
float Y1y = Y1x;
float Y1z = Y1x;
vec4 L1 = vec4(Y00, Y1x, Y1y, Y1z);
vec3 view_direction = calcDirection(vary_frag);
vec3 sun_direction = normalize(sun_dir);
vec3 cam_pos = vec3(0, 0, 6360);
vec3 transmittance;
vec3 radiance = GetSkyLuminance(cam_pos, view_direction, 0.0f, sun_direction, transmittance);
vec3 color = vec3(1.0) - exp(-radiance * 0.0001);
color = pow(color, vec3(1.0/2.2));
vec4 coeffs[3];
coeffs[0] = vec4(0);
coeffs[1] = vec4(0);
coeffs[2] = vec4(0);
projectToL1(view_direction, color.rgb, L1, coeffs);
frag_data[0] = coeffs[0];
frag_data[1] = coeffs[1];
frag_data[2] = coeffs[2];
}

View File

@ -1,37 +0,0 @@
/**
* @file genSkyShV.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$
*/
ATTRIBUTE vec3 position;
ATTRIBUTE vec2 texcoord0;
VARYING vec2 vary_frag;
void main()
{
// pass through untransformed fullscreen pos
gl_Position = vec4(position.xyz, 1.0);
vary_frag = texcoord0;
}

View File

@ -1,37 +0,0 @@
/**
* @file pointShadowBlur.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 samplerCube cube_map;
in vec3 to_vec;
out vec4 fragColor;
void main()
{
vec4 vcol = texture(cube_map, to_vec);
fragColor = vec4(vcol.rgb, 1.0);
}

View File

@ -1,73 +0,0 @@
/**
* @file class3/deferred/shVisF.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$
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
/////////////////////////////////////////////////////////////////////////
// Fragment shader for L1 SH debug rendering
/////////////////////////////////////////////////////////////////////////
uniform sampler2D sh_input_r;
uniform sampler2D sh_input_g;
uniform sampler2D sh_input_b;
uniform mat3 inv_modelviewprojection;
VARYING vec4 vary_pos;
void main(void)
{
vec2 coord = vary_pos.xy + vec2(0.5,0.5);
coord.x *= (1.6/0.9);
if (dot(coord, coord) > 0.25)
{
discard;
}
vec4 n = vec4(coord*2.0, 0.0, 1);
//n.y = -n.y;
n.z = sqrt(max(1.0-n.x*n.x-n.y*n.y, 0.0));
//n.xyz = inv_modelviewprojection * n.xyz;
vec4 l1tap = vec4(1.0/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265));
vec4 l1r = texture2D(sh_input_r, vec2(0,0));
vec4 l1g = texture2D(sh_input_g, vec2(0,0));
vec4 l1b = texture2D(sh_input_b, vec2(0,0));
vec3 indirect = vec3(
dot(l1r, l1tap * n),
dot(l1g, l1tap * n),
dot(l1b, l1tap * n));
//indirect = pow(indirect, vec3(0.45));
indirect *= 3.0;
frag_color = vec4(indirect, 1.0);
}

View File

@ -1,33 +0,0 @@
/**
* @file class3/deferred/shVisV.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$
*/
ATTRIBUTE vec3 position;
VARYING vec4 vary_pos;
void main()
{
// Output
vary_pos = vec4(position, 1);
gl_Position = vary_pos;
}

View File

@ -1,58 +0,0 @@
/**
* @file shadowAlphaMaskF.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$
*/
/*[EXTRA_CODE_HERE]*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2D diffuseMap;
#if !defined(DEPTH_CLAMP)
VARYING float pos_zd2;
#endif
VARYING float pos_w;
VARYING float target_pos_x;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
VARYING vec3 pos;
vec4 computeMoments(float depth, float a);
void main()
{
float alpha = diffuseLookup(vary_texcoord0.xy).a * vertex_color.a;
frag_color = computeMoments(length(pos), float a);
#if !defined(DEPTH_CLAMP)
gl_FragDepth = max(pos_zd2/pos_w+0.5, 0.0);
#endif
}

View File

@ -1,66 +0,0 @@
/**
* @file shadowAlphaMaskV.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 float target_pos_x;
VARYING vec4 pos;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
void passTextureIndex();
void main()
{
//transform vertex
vec4 pre_pos = vec4(position.xyz, 1.0);
vec4 pos = modelview_projection_matrix * pre_pos;
target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x;
pos_w = pos.w;
#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;
vertex_color = diffuse_color;
}

View File

@ -1,73 +0,0 @@
/**
* @file class3\wl\advancedAtmoF.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
in vec3 view_dir;
uniform vec3 cameraPosLocal;
uniform vec3 sun_dir;
uniform float sun_size;
uniform sampler2D transmittance_texture;
uniform sampler3D scattering_texture;
uniform sampler3D mie_scattering_texture;
uniform sampler2D irradiance_texture;
vec3 GetSolarLuminance();
vec3 GetSkyLuminance(vec3 camPos, vec3 view_dir, float shadow_length, vec3 sun_dir, out vec3 transmittance);
vec3 GetSkyLuminanceToPoint(vec3 camPos, vec3 pos, float shadow_length, vec3 sun_dir, out vec3 transmittance);
vec3 GetSunAndSkyIlluminance(vec3 pos, vec3 norm, vec3 sun_dir, out vec3 sky_irradiance);
void main()
{
vec3 view_direction = normalize(view_dir);
vec3 camPos = cameraPosLocal;
vec3 transmittance;
vec3 sky_illum;
vec3 radiance = GetSkyLuminance(camPos, view_direction, 0.0f, sun_dir, transmittance);
vec3 radiance2 = GetSunAndSkyIlluminance(camPos, view_direction, sun_dir, sky_illum);
//radiance *= transmittance;
// If the view ray intersects the Sun, add the Sun radiance.
if (dot(view_direction, sun_dir) >= sun_size)
{
radiance = radiance + transmittance * GetSolarLuminance();
}
//vec3 color = vec3(1.0) - exp(-radiance);
//color = pow(color, vec3(1.0 / 2.2));
frag_color.rgb = radiance;
frag_color.a = 1.0;
}

View File

@ -1,43 +0,0 @@
/**
* @file class3\wl\advancedAtmoV.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 mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
// Inputs
uniform vec3 camPosLocal;
out vec3 view_dir;
void main()
{
// World / view / projection
gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
// this will be normalized in the frag shader...
view_dir = position.xyz - camPosLocal.xyz;
}