diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl')
-rw-r--r-- | indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 70 |
1 files changed, 37 insertions, 33 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index d7407332e5..a137bea30f 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -23,16 +23,19 @@ * $/LicenseInfo$ */ - - #extension GL_ARB_texture_rectangle : enable +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + uniform sampler2DRect diffuseRect; uniform sampler2DRect specularRect; uniform sampler2DRect normalMap; uniform sampler2DRect lightMap; uniform sampler2DRect depthMap; -uniform sampler2D noiseMap; uniform samplerCube environmentMap; uniform sampler2D lightFunc; uniform vec3 gi_quad; @@ -50,23 +53,24 @@ 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 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 float scene_light_strength; -uniform vec3 env_mat[3]; +uniform mat3 env_mat; uniform vec4 shadow_clip; uniform mat3 ssao_effect_mat; uniform mat4 inv_proj; uniform vec2 screen_res; -varying vec4 vary_light; -varying vec2 vary_fragcoord; +uniform vec3 sun_dir; + +VARYING vec2 vary_fragcoord; vec3 vary_PositionEye; @@ -145,10 +149,6 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) { 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); @@ -163,13 +163,13 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) { //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); + light_atten = (blue_density + vec4(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 - temp1 = blue_density + vec4(haze_density.r); + temp1 = blue_density + vec4(haze_density); blue_weight = blue_density / temp1; - haze_weight = vec4(haze_density.r) / temp1; + haze_weight = vec4(haze_density) / temp1; //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) temp2.y = max(0.0, tmpLightnorm.y); @@ -177,12 +177,12 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) { sunlight *= exp( - light_atten * temp2.y); // main atmospheric scattering line integral - temp2.z = Plen * density_multiplier.x; + temp2.z = Plen * density_multiplier; // Transparency (-> temp1) - // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier.x in a variable because the ati + // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati // compiler gets confused. - temp1 = exp(-temp1 * temp2.z * distance_multiplier.x); + temp1 = exp(-temp1 * temp2.z * distance_multiplier); //final atmosphere attenuation factor setAtmosAttenuation(temp1.rgb); @@ -203,7 +203,7 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) { temp2.x += .25; //increase ambient when there are more clouds - vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow.x * 0.5; + vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * 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 @@ -217,8 +217,8 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) { //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 + vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient) + + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x + tmpAmbient))); //brightness of surface both sunlight and ambient @@ -280,9 +280,8 @@ void main() vec3 pos = getPosition_d(tc, depth).xyz; vec3 norm = texture2DRect(normalMap, tc).xyz; norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm - //vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz; - - float da = max(dot(norm.xyz, vary_light.xyz), 0.0); + + float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); vec4 diffuse = texture2DRect(diffuseRect, tc); @@ -309,13 +308,18 @@ void main() // the old infinite-sky shiny reflection // vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); - float sa = dot(refnormpersp, vary_light.xyz); - vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a; + float sa = dot(refnormpersp, sun_dir.xyz); + vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*(6 * texture2D(lightFunc, vec2(sa, spec.a)).r); // add the two types of shiny together vec3 spec_contrib = dumbshiny * spec.rgb; - bloom = dot(spec_contrib, spec_contrib); + bloom = dot(spec_contrib, spec_contrib) / 4; col += spec_contrib; + + //add environmentmap + vec3 env_vec = env_mat * refnormpersp; + col = mix(col.rgb, textureCube(environmentMap, env_vec).rgb, + max(spec.a-diffuse.a*2.0, 0.0)); } col = atmosLighting(col); @@ -328,6 +332,6 @@ void main() col = diffuse.rgb; } - gl_FragColor.rgb = col; - gl_FragColor.a = bloom; + frag_color.rgb = col; + frag_color.a = bloom; } |