Imported existing code
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @file atmosphericsF.glsl
|
||||
*
|
||||
* Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
|
||||
* $License$
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// The fragment shader for the terrain atmospherics
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
vec3 getAdditiveColor();
|
||||
vec3 getAtmosAttenuation();
|
||||
|
||||
uniform sampler2D cloudMap;
|
||||
uniform vec4 cloud_pos_density1;
|
||||
|
||||
vec3 atmosLighting(vec3 light)
|
||||
{
|
||||
light *= getAtmosAttenuation().r;
|
||||
light += getAdditiveColor();
|
||||
return (2.0 * light);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @file atmosphericsHelpersV.glsl
|
||||
*
|
||||
* Copyright (c) 2005-$CurrentYear$, Linden Research, Inc.
|
||||
* $License$
|
||||
*/
|
||||
|
||||
// Output variables
|
||||
vec3 getSunlitColor();
|
||||
vec3 getAmblitColor();
|
||||
vec3 getAdditiveColor();
|
||||
vec3 getAtmosAttenuation();
|
||||
vec3 getPositionEye();
|
||||
|
||||
uniform float scene_light_strength;
|
||||
|
||||
vec3 atmosAmbient(vec3 light)
|
||||
{
|
||||
return getAmblitColor() + light / 2.0;
|
||||
}
|
||||
|
||||
vec3 atmosAffectDirectionalLight(float lightIntensity)
|
||||
{
|
||||
return getSunlitColor() * lightIntensity;
|
||||
}
|
||||
|
||||
vec3 atmosGetDiffuseSunlightColor()
|
||||
{
|
||||
return getSunlitColor();
|
||||
}
|
||||
|
||||
vec3 scaleDownLight(vec3 light)
|
||||
{
|
||||
return (light / scene_light_strength );
|
||||
}
|
||||
|
||||
vec3 scaleUpLight(vec3 light)
|
||||
{
|
||||
return (light * scene_light_strength);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* @file atmosphericsV.glsl
|
||||
*
|
||||
* Copyright (c) 2005-$CurrentYear$, Linden Research, Inc.
|
||||
* $License$
|
||||
*/
|
||||
|
||||
// varying param funcs
|
||||
void setSunlitColor(vec3 v);
|
||||
void setAmblitColor(vec3 v);
|
||||
void setAdditiveColor(vec3 v);
|
||||
void setAtmosAttenuation(vec3 v);
|
||||
void setPositionEye(vec3 v);
|
||||
|
||||
vec3 getAdditiveColor();
|
||||
|
||||
//varying vec4 vary_CloudUVs;
|
||||
//varying float vary_CloudDensity;
|
||||
|
||||
// Inputs
|
||||
uniform vec4 morphFactor;
|
||||
uniform vec3 camPosLocal;
|
||||
//uniform vec4 camPosWorld;
|
||||
|
||||
uniform vec4 lightnorm;
|
||||
uniform vec4 sunlight_color;
|
||||
uniform vec4 ambient;
|
||||
uniform vec4 blue_horizon;
|
||||
uniform vec4 blue_density;
|
||||
uniform vec4 haze_horizon;
|
||||
uniform vec4 haze_density;
|
||||
uniform vec4 cloud_shadow;
|
||||
uniform vec4 density_multiplier;
|
||||
uniform vec4 distance_multiplier;
|
||||
uniform vec4 max_y;
|
||||
uniform vec4 glow;
|
||||
|
||||
void calcAtmospherics(vec3 inPositionEye) {
|
||||
|
||||
vec3 P = inPositionEye;
|
||||
setPositionEye(P);
|
||||
|
||||
//(TERRAIN) limit altitude
|
||||
if (P.y > max_y.x) P *= (max_y.x / P.y);
|
||||
if (P.y < -max_y.x) P *= (-max_y.x / P.y);
|
||||
|
||||
vec3 tmpLightnorm = lightnorm.xyz;
|
||||
|
||||
vec3 Pn = normalize(P);
|
||||
float Plen = length(P);
|
||||
|
||||
vec4 temp1 = vec4(0);
|
||||
vec3 temp2 = vec3(0);
|
||||
vec4 blue_weight;
|
||||
vec4 haze_weight;
|
||||
vec4 sunlight = sunlight_color;
|
||||
vec4 light_atten;
|
||||
|
||||
//sunlight attenuation effect (hue and brightness) due to atmosphere
|
||||
//this is used later for sunlight modulation at various altitudes
|
||||
light_atten = (blue_density * 1.0 + vec4(haze_density.r) * 0.25) * (density_multiplier.x * max_y.x);
|
||||
//I had thought blue_density and haze_density should have equal weighting,
|
||||
//but attenuation due to haze_density tends to seem too strong
|
||||
|
||||
temp1 = blue_density + vec4(haze_density.r);
|
||||
blue_weight = blue_density / temp1;
|
||||
haze_weight = vec4(haze_density.r) / temp1;
|
||||
|
||||
//(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain)
|
||||
temp2.y = max(0.0, tmpLightnorm.y);
|
||||
temp2.y = 1. / temp2.y;
|
||||
sunlight *= exp( - light_atten * temp2.y);
|
||||
|
||||
// main atmospheric scattering line integral
|
||||
temp2.z = Plen * density_multiplier.x;
|
||||
|
||||
// Transparency (-> temp1)
|
||||
// ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier.x in a variable because the ati
|
||||
// compiler gets confused.
|
||||
temp1 = exp(-temp1 * temp2.z * distance_multiplier.x);
|
||||
|
||||
//final atmosphere attenuation factor
|
||||
setAtmosAttenuation(temp1.rgb);
|
||||
//vary_AtmosAttenuation = distance_multiplier / 10000.;
|
||||
//vary_AtmosAttenuation = density_multiplier * 100.;
|
||||
//vary_AtmosAttenuation = vec4(Plen / 100000., 0., 0., 1.);
|
||||
|
||||
//compute haze glow
|
||||
//(can use temp2.x as temp because we haven't used it yet)
|
||||
temp2.x = dot(Pn, tmpLightnorm.xyz);
|
||||
temp2.x = 1. - temp2.x;
|
||||
//temp2.x is 0 at the sun and increases away from sun
|
||||
temp2.x = max(temp2.x, .03); //was glow.y
|
||||
//set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot)
|
||||
temp2.x *= glow.x;
|
||||
//higher glow.x gives dimmer glow (because next step is 1 / "angle")
|
||||
temp2.x = pow(temp2.x, glow.z);
|
||||
//glow.z should be negative, so we're doing a sort of (1 / "angle") function
|
||||
|
||||
//add "minimum anti-solar illumination"
|
||||
temp2.x += .25;
|
||||
|
||||
|
||||
//increase ambient when there are more clouds
|
||||
vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow.x * 0.5;
|
||||
|
||||
//haze color
|
||||
setAdditiveColor(
|
||||
vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow.x) + tmpAmbient)
|
||||
+ (haze_horizon.r * haze_weight) * (sunlight*(1.-cloud_shadow.x) * temp2.x
|
||||
+ tmpAmbient)));
|
||||
|
||||
//brightness of surface both sunlight and ambient
|
||||
setSunlitColor(vec3(sunlight * .5));
|
||||
setAmblitColor(vec3(tmpAmbient * .25));
|
||||
setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1));
|
||||
|
||||
// vary_SunlitColor = vec3(0);
|
||||
// vary_AmblitColor = vec3(0);
|
||||
// vary_AdditiveColor = vec4(Pn, 1.0);
|
||||
|
||||
/*
|
||||
const float cloudShadowScale = 100.;
|
||||
// Get cloud uvs for shadowing
|
||||
vec3 cloudPos = inPositionEye + camPosWorld - cloudShadowScale / 2.;
|
||||
vary_CloudUVs.xy = cloudPos.xz / cloudShadowScale;
|
||||
|
||||
// We can take uv1 and multiply it by (TerrainSpan / CloudSpan)
|
||||
// cloudUVs *= (((worldMaxZ - worldMinZ) * 20) /40000.);
|
||||
vary_CloudUVs *= (10000./40000.);
|
||||
|
||||
// Offset by sun vector * (CloudAltitude / CloudSpan)
|
||||
vary_CloudUVs.x += tmpLightnorm.x / tmpLightnorm.y * (3000./40000.);
|
||||
vary_CloudUVs.y += tmpLightnorm.z / tmpLightnorm.y * (3000./40000.);
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @file atmosphericVars.glsl
|
||||
*
|
||||
* Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
|
||||
* $License$
|
||||
*/
|
||||
|
||||
varying vec3 vary_PositionEye;
|
||||
|
||||
varying vec3 vary_SunlitColor;
|
||||
varying vec3 vary_AmblitColor;
|
||||
varying vec3 vary_AdditiveColor;
|
||||
varying vec3 vary_AtmosAttenuation;
|
||||
|
||||
vec3 getPositionEye()
|
||||
{
|
||||
return vary_PositionEye;
|
||||
}
|
||||
vec3 getSunlitColor()
|
||||
{
|
||||
return vary_SunlitColor;
|
||||
}
|
||||
vec3 getAmblitColor()
|
||||
{
|
||||
return vary_AmblitColor;
|
||||
}
|
||||
vec3 getAdditiveColor()
|
||||
{
|
||||
return vary_AdditiveColor;
|
||||
}
|
||||
vec3 getAtmosAttenuation()
|
||||
{
|
||||
return vary_AtmosAttenuation;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* @file atmosphericVars.glsl
|
||||
*
|
||||
* Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
|
||||
* $License$
|
||||
*/
|
||||
|
||||
varying vec3 vary_PositionEye;
|
||||
|
||||
varying vec3 vary_SunlitColor;
|
||||
varying vec3 vary_AmblitColor;
|
||||
varying vec3 vary_AdditiveColor;
|
||||
varying vec3 vary_AtmosAttenuation;
|
||||
|
||||
vec3 getPositionEye()
|
||||
{
|
||||
return vary_PositionEye;
|
||||
}
|
||||
vec3 getSunlitColor()
|
||||
{
|
||||
return vary_SunlitColor;
|
||||
}
|
||||
vec3 getAmblitColor()
|
||||
{
|
||||
return vary_AmblitColor;
|
||||
}
|
||||
vec3 getAdditiveColor()
|
||||
{
|
||||
return vary_AdditiveColor;
|
||||
}
|
||||
vec3 getAtmosAttenuation()
|
||||
{
|
||||
return vary_AtmosAttenuation;
|
||||
}
|
||||
|
||||
|
||||
void setPositionEye(vec3 v)
|
||||
{
|
||||
vary_PositionEye = v;
|
||||
}
|
||||
|
||||
void setSunlitColor(vec3 v)
|
||||
{
|
||||
vary_SunlitColor = v;
|
||||
}
|
||||
|
||||
void setAmblitColor(vec3 v)
|
||||
{
|
||||
vary_AmblitColor = v;
|
||||
}
|
||||
|
||||
void setAdditiveColor(vec3 v)
|
||||
{
|
||||
vary_AdditiveColor = v;
|
||||
}
|
||||
|
||||
void setAtmosAttenuation(vec3 v)
|
||||
{
|
||||
vary_AtmosAttenuation = v;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* @file WLCloudsF.glsl
|
||||
*
|
||||
* Copyright (c) 2005-$CurrentYear$, Linden Research, Inc.
|
||||
* $License$
|
||||
*/
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// The fragment shader for the sky
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
varying vec4 vary_CloudColorSun;
|
||||
varying vec4 vary_CloudColorAmbient;
|
||||
varying float vary_CloudDensity;
|
||||
|
||||
uniform sampler2D cloud_noise_texture;
|
||||
uniform vec4 cloud_pos_density1;
|
||||
uniform vec4 cloud_pos_density2;
|
||||
uniform vec4 gamma;
|
||||
|
||||
/// Soft clips the light with a gamma correction
|
||||
vec3 scaleSoftClip(vec3 light) {
|
||||
//soft clip effect:
|
||||
light = 1. - clamp(light, vec3(0.), vec3(1.));
|
||||
light = 1. - pow(light, gamma.xxx);
|
||||
|
||||
return light;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// Set variables
|
||||
vec2 uv1 = gl_TexCoord[0].xy;
|
||||
vec2 uv2 = gl_TexCoord[1].xy;
|
||||
|
||||
vec4 cloudColorSun = vary_CloudColorSun;
|
||||
vec4 cloudColorAmbient = vary_CloudColorAmbient;
|
||||
float cloudDensity = vary_CloudDensity;
|
||||
vec2 uv3 = gl_TexCoord[2].xy;
|
||||
vec2 uv4 = gl_TexCoord[3].xy;
|
||||
|
||||
// Offset texture coords
|
||||
uv1 += cloud_pos_density1.xy; //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
|
||||
|
||||
|
||||
// Compute alpha1, the main cloud opacity
|
||||
float alpha1 = (texture2D(cloud_noise_texture, uv1).x - 0.5) + (texture2D(cloud_noise_texture, 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;
|
||||
|
||||
|
||||
// Compute alpha2, for self shadowing effect
|
||||
// (1 - alpha2) will later be used as percentage of incoming sunlight
|
||||
float alpha2 = (texture2D(cloud_noise_texture, 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;
|
||||
|
||||
// Combine
|
||||
vec4 color;
|
||||
color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient);
|
||||
color *= 2.;
|
||||
|
||||
/// Gamma correct for WL (soft clip effect).
|
||||
gl_FragColor.rgb = scaleSoftClip(color.rgb);
|
||||
gl_FragColor.a = alpha1;
|
||||
}
|
||||
|
||||
163
indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
Normal file
163
indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
Normal file
@@ -0,0 +1,163 @@
|
||||
/**
|
||||
* @file WLCloudsV.glsl
|
||||
*
|
||||
* Copyright (c) 2005-$CurrentYear$, Linden Research, Inc.
|
||||
* $License$
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// The vertex shader for creating the atmospheric sky
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Output parameters
|
||||
varying vec4 vary_CloudColorSun;
|
||||
varying vec4 vary_CloudColorAmbient;
|
||||
varying float vary_CloudDensity;
|
||||
|
||||
// Inputs
|
||||
uniform vec3 camPosLocal;
|
||||
|
||||
uniform vec4 lightnorm;
|
||||
uniform vec4 sunlight_color;
|
||||
uniform vec4 ambient;
|
||||
uniform vec4 blue_horizon;
|
||||
uniform vec4 blue_density;
|
||||
uniform vec4 haze_horizon;
|
||||
uniform vec4 haze_density;
|
||||
|
||||
uniform vec4 cloud_shadow;
|
||||
uniform vec4 density_multiplier;
|
||||
uniform vec4 max_y;
|
||||
|
||||
uniform vec4 glow;
|
||||
|
||||
uniform vec4 cloud_color;
|
||||
|
||||
uniform vec4 cloud_scale;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
// World / view / projection
|
||||
gl_Position = ftransform();
|
||||
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
|
||||
// Get relative position
|
||||
vec3 P = gl_Vertex.xyz - camPosLocal.xyz + vec3(0,50,0);
|
||||
|
||||
// Set altitude
|
||||
if (P.y > 0.)
|
||||
{
|
||||
P *= (max_y.x / P.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
P *= (-32000. / P.y);
|
||||
}
|
||||
|
||||
// Can normalize then
|
||||
vec3 Pn = normalize(P);
|
||||
float Plen = length(P);
|
||||
|
||||
// Initialize temp variables
|
||||
vec4 temp1 = vec4(0.);
|
||||
vec4 temp2 = vec4(0.);
|
||||
vec4 blue_weight;
|
||||
vec4 haze_weight;
|
||||
vec4 sunlight = sunlight_color;
|
||||
vec4 light_atten;
|
||||
|
||||
|
||||
// Sunlight attenuation effect (hue and brightness) due to atmosphere
|
||||
// this is used later for sunlight modulation at various altitudes
|
||||
light_atten = (blue_density * 1.0 + haze_density.x * 0.25) * (density_multiplier.x * max_y.x);
|
||||
|
||||
// Calculate relative weights
|
||||
temp1 = blue_density + haze_density.x;
|
||||
blue_weight = blue_density / temp1;
|
||||
haze_weight = haze_density.x / temp1;
|
||||
|
||||
// Compute sunlight from P & lightnorm (for long rays like sky)
|
||||
temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y );
|
||||
temp2.y = 1. / temp2.y;
|
||||
sunlight *= exp( - light_atten * temp2.y);
|
||||
|
||||
// Distance
|
||||
temp2.z = Plen * density_multiplier.x;
|
||||
|
||||
// Transparency (-> temp1)
|
||||
// ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati
|
||||
// compiler gets confused.
|
||||
temp1 = exp(-temp1 * temp2.z);
|
||||
|
||||
|
||||
// Compute haze glow
|
||||
temp2.x = dot(Pn, lightnorm.xyz);
|
||||
temp2.x = 1. - temp2.x;
|
||||
// temp2.x is 0 at the sun and increases away from sun
|
||||
temp2.x = max(temp2.x, .001);
|
||||
// Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot)
|
||||
temp2.x *= glow.x;
|
||||
// Higher glow.x gives dimmer glow (because next step is 1 / "angle")
|
||||
temp2.x = pow(temp2.x, glow.z);
|
||||
// glow.z should be negative, so we're doing a sort of (1 / "angle") function
|
||||
|
||||
// Add "minimum anti-solar illumination"
|
||||
temp2.x += .25;
|
||||
|
||||
// Increase ambient when there are more clouds
|
||||
vec4 tmpAmbient = ambient;
|
||||
tmpAmbient += (1. - tmpAmbient) * cloud_shadow.x * 0.5;
|
||||
|
||||
// Dim sunlight by cloud shadow percentage
|
||||
sunlight *= (1. - cloud_shadow.x);
|
||||
|
||||
// Haze color below cloud
|
||||
vec4 additiveColorBelowCloud = ( blue_horizon * blue_weight * (sunlight + tmpAmbient)
|
||||
+ (haze_horizon.r * haze_weight) * (sunlight * temp2.x + tmpAmbient)
|
||||
);
|
||||
|
||||
// CLOUDS
|
||||
|
||||
sunlight = sunlight_color;
|
||||
temp2.y = max(0., lightnorm.y * 2.);
|
||||
temp2.y = 1. / temp2.y;
|
||||
sunlight *= exp( - light_atten * temp2.y);
|
||||
|
||||
// Cloud color out
|
||||
vary_CloudColorSun = (sunlight * temp2.x) * cloud_color;
|
||||
vary_CloudColorAmbient = tmpAmbient * cloud_color;
|
||||
|
||||
// Attenuate cloud color by atmosphere
|
||||
temp1 = sqrt(temp1); //less atmos opacity (more transparency) below clouds
|
||||
vary_CloudColorSun *= temp1;
|
||||
vary_CloudColorAmbient *= temp1;
|
||||
vec4 oHazeColorBelowCloud = additiveColorBelowCloud * (1. - temp1);
|
||||
|
||||
// Make a nice cloud density based on the cloud_shadow value that was passed in.
|
||||
vary_CloudDensity = 2. * (cloud_shadow.x - 0.25);
|
||||
|
||||
|
||||
// Texture coords
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_TexCoord[0].xy -= 0.5;
|
||||
gl_TexCoord[0].xy /= cloud_scale.x;
|
||||
gl_TexCoord[0].xy += 0.5;
|
||||
|
||||
gl_TexCoord[1] = gl_TexCoord[0];
|
||||
gl_TexCoord[1].x += lightnorm.x * 0.0125;
|
||||
gl_TexCoord[1].y += lightnorm.z * 0.0125;
|
||||
|
||||
gl_TexCoord[2] = gl_TexCoord[0] * 16.;
|
||||
gl_TexCoord[3] = gl_TexCoord[1] * 16.;
|
||||
|
||||
// Combine these to minimize register use
|
||||
vary_CloudColorAmbient += oHazeColorBelowCloud;
|
||||
|
||||
// needs this to compile on mac
|
||||
//vary_AtmosAttenuation = vec3(0.0,0.0,0.0);
|
||||
|
||||
// END CLOUDS
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @file gammaF.glsl
|
||||
*
|
||||
* Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
|
||||
* $License$
|
||||
*/
|
||||
|
||||
uniform vec4 gamma;
|
||||
|
||||
vec3 getAtmosAttenuation();
|
||||
|
||||
/// Soft clips the light with a gamma correction
|
||||
vec3 scaleSoftClip(vec3 light) {
|
||||
//soft clip effect:
|
||||
light = 1. - clamp(light, vec3(0.), vec3(1.));
|
||||
light = 1. - pow(light, gamma.xxx);
|
||||
|
||||
return light;
|
||||
}
|
||||
|
||||
vec3 fullbrightScaleSoftClip(vec3 light) {
|
||||
return mix(scaleSoftClip(light.rgb), light.rgb, getAtmosAttenuation());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @file WLSkyF.glsl
|
||||
*
|
||||
* Copyright (c) 2005-$CurrentYear$, Linden Research, Inc.
|
||||
* $License$
|
||||
*/
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// The fragment shader for the sky
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
varying vec4 vary_HazeColor;
|
||||
|
||||
uniform sampler2D cloud_noise_texture;
|
||||
uniform vec4 gamma;
|
||||
|
||||
/// Soft clips the light with a gamma correction
|
||||
vec3 scaleSoftClip(vec3 light) {
|
||||
//soft clip effect:
|
||||
light = 1. - clamp(light, vec3(0.), vec3(1.));
|
||||
light = 1. - pow(light, gamma.xxx);
|
||||
|
||||
return light;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// Potential Fill-rate optimization. Add cloud calculation
|
||||
// back in and output alpha of 0 (so that alpha culling kills
|
||||
// the fragment) if the sky wouldn't show up because the clouds
|
||||
// are fully opaque.
|
||||
|
||||
vec4 color;
|
||||
color = vary_HazeColor;
|
||||
color *= 2.;
|
||||
|
||||
/// Gamma correct for WL (soft clip effect).
|
||||
gl_FragColor.rgb = scaleSoftClip(color.rgb);
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
138
indra/newview/app_settings/shaders/class2/windlight/skyV.glsl
Normal file
138
indra/newview/app_settings/shaders/class2/windlight/skyV.glsl
Normal file
@@ -0,0 +1,138 @@
|
||||
/**
|
||||
* @file WLSkyV.glsl
|
||||
*
|
||||
* Copyright (c) 2005-$CurrentYear$, Linden Research, Inc.
|
||||
* $License$
|
||||
*/
|
||||
|
||||
// SKY ////////////////////////////////////////////////////////////////////////
|
||||
// The vertex shader for creating the atmospheric sky
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Output parameters
|
||||
varying vec4 vary_HazeColor;
|
||||
|
||||
// Inputs
|
||||
uniform vec3 camPosLocal;
|
||||
|
||||
uniform vec4 lightnorm;
|
||||
uniform vec4 sunlight_color;
|
||||
uniform vec4 ambient;
|
||||
uniform vec4 blue_horizon;
|
||||
uniform vec4 blue_density;
|
||||
uniform vec4 haze_horizon;
|
||||
uniform vec4 haze_density;
|
||||
|
||||
uniform vec4 cloud_shadow;
|
||||
uniform vec4 density_multiplier;
|
||||
uniform vec4 max_y;
|
||||
|
||||
uniform vec4 glow;
|
||||
|
||||
uniform vec4 cloud_color;
|
||||
|
||||
uniform vec4 cloud_scale;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
// World / view / projection
|
||||
gl_Position = ftransform();
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
|
||||
// Get relative position
|
||||
vec3 P = gl_Vertex.xyz - camPosLocal.xyz + vec3(0,50,0);
|
||||
//vec3 P = gl_Vertex.xyz + vec3(0,50,0);
|
||||
|
||||
// Set altitude
|
||||
if (P.y > 0.)
|
||||
{
|
||||
P *= (max_y.x / P.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
P *= (-32000. / P.y);
|
||||
}
|
||||
|
||||
// Can normalize then
|
||||
vec3 Pn = normalize(P);
|
||||
float Plen = length(P);
|
||||
|
||||
// Initialize temp variables
|
||||
vec4 temp1 = vec4(0.);
|
||||
vec4 temp2 = vec4(0.);
|
||||
vec4 blue_weight;
|
||||
vec4 haze_weight;
|
||||
vec4 sunlight = sunlight_color;
|
||||
vec4 light_atten;
|
||||
|
||||
|
||||
// Sunlight attenuation effect (hue and brightness) due to atmosphere
|
||||
// this is used later for sunlight modulation at various altitudes
|
||||
light_atten = (blue_density * 1.0 + haze_density.x * 0.25) * (density_multiplier.x * max_y.x);
|
||||
|
||||
// Calculate relative weights
|
||||
temp1 = blue_density + haze_density.x;
|
||||
blue_weight = blue_density / temp1;
|
||||
haze_weight = haze_density.x / temp1;
|
||||
|
||||
// Compute sunlight from P & lightnorm (for long rays like sky)
|
||||
temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y );
|
||||
temp2.y = 1. / temp2.y;
|
||||
sunlight *= exp( - light_atten * temp2.y);
|
||||
|
||||
// Distance
|
||||
temp2.z = Plen * density_multiplier.x;
|
||||
|
||||
// Transparency (-> temp1)
|
||||
// ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati
|
||||
// compiler gets confused.
|
||||
temp1 = exp(-temp1 * temp2.z);
|
||||
|
||||
|
||||
// Compute haze glow
|
||||
temp2.x = dot(Pn, lightnorm.xyz);
|
||||
temp2.x = 1. - temp2.x;
|
||||
// temp2.x is 0 at the sun and increases away from sun
|
||||
temp2.x = max(temp2.x, .001);
|
||||
// Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot)
|
||||
temp2.x *= glow.x;
|
||||
// Higher glow.x gives dimmer glow (because next step is 1 / "angle")
|
||||
temp2.x = pow(temp2.x, glow.z);
|
||||
// glow.z should be negative, so we're doing a sort of (1 / "angle") function
|
||||
|
||||
// Add "minimum anti-solar illumination"
|
||||
temp2.x += .25;
|
||||
|
||||
|
||||
// Haze color above cloud
|
||||
vary_HazeColor = ( blue_horizon * blue_weight * (sunlight + ambient)
|
||||
+ (haze_horizon.r * haze_weight) * (sunlight * temp2.x + ambient)
|
||||
);
|
||||
|
||||
|
||||
// Increase ambient when there are more clouds
|
||||
vec4 tmpAmbient = ambient;
|
||||
tmpAmbient += (1. - tmpAmbient) * cloud_shadow.x * 0.5;
|
||||
|
||||
// Dim sunlight by cloud shadow percentage
|
||||
sunlight *= (1. - cloud_shadow.x);
|
||||
|
||||
// Haze color below cloud
|
||||
vec4 additiveColorBelowCloud = ( blue_horizon * blue_weight * (sunlight + tmpAmbient)
|
||||
+ (haze_horizon.r * haze_weight) * (sunlight * temp2.x + tmpAmbient)
|
||||
);
|
||||
|
||||
// Final atmosphere additive
|
||||
vary_HazeColor *= (1. - temp1);
|
||||
|
||||
// Attenuate cloud color by atmosphere
|
||||
temp1 = sqrt(temp1); //less atmos opacity (more transparency) below clouds
|
||||
|
||||
// At horizon, blend high altitude sky color towards the darker color below the clouds
|
||||
vary_HazeColor += (additiveColorBelowCloud - vary_HazeColor) * (1. - sqrt(temp1));
|
||||
|
||||
// won't compile on mac without this being set
|
||||
//vary_AtmosAttenuation = vec3(0.0,0.0,0.0);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @file transportF.glsl
|
||||
*
|
||||
* Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
|
||||
* $License$
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// The fragment shader for the terrain atmospherics
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
vec3 getAdditiveColor();
|
||||
vec3 getAtmosAttenuation();
|
||||
|
||||
uniform sampler2D cloudMap;
|
||||
uniform vec4 cloud_pos_density1;
|
||||
|
||||
vec3 atmosTransport(vec3 light) {
|
||||
light *= getAtmosAttenuation().r;
|
||||
light += getAdditiveColor() * 2.0;
|
||||
return light;
|
||||
}
|
||||
|
||||
vec3 fullbrightAtmosTransport(vec3 light) {
|
||||
float brightness = dot(light.rgb, vec3(0.33333));
|
||||
|
||||
return mix(atmosTransport(light.rgb), light.rgb + getAdditiveColor().rgb, brightness * brightness);
|
||||
}
|
||||
|
||||
vec3 fullbrightShinyAtmosTransport(vec3 light) {
|
||||
float brightness = dot(light.rgb, vec3(0.33333));
|
||||
|
||||
return mix(atmosTransport(light.rgb), (light.rgb + getAdditiveColor().rgb) * (2.0 - brightness), brightness * brightness);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user