diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index 60ccfa64dbc1d79945154f9fc86584a9fe207c19..3fcb416601c542543e2dcb5e9bea3cfca0145102 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -51,6 +51,7 @@ VARYING vec2 vary_texcoord0; VARYING vec2 vary_texcoord1; VARYING vec2 vary_texcoord2; VARYING vec2 vary_texcoord3; +VARYING float altitude_blend_factor; /// Soft clips the light with a gamma correction vec3 scaleSoftClip(vec3 light); @@ -102,10 +103,8 @@ void main() alpha1 = 1. - alpha1 * alpha1; alpha1 = 1. - alpha1 * alpha1; - if (alpha1 < 0.001f) - { - discard; - } + alpha1 *= altitude_blend_factor; + alpha1 = clamp(alpha1, 0.0, 1.0); // Compute alpha2, for self shadowing effect // (1 - alpha2) will later be used as percentage of incoming sunlight @@ -119,6 +118,7 @@ void main() // Combine vec4 color; color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient); + color.rgb= max(vec3(0), color.rgb); color *= 2.; /// Gamma correct for WL (soft clip effect). diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl index 4beb334f5a0bea7519008c9eefc5ed6df1e52f36..cfe5632ec08e7c8141e3ffc3d0a05d9d2316339e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl @@ -41,6 +41,7 @@ VARYING vec2 vary_texcoord0; VARYING vec2 vary_texcoord1; VARYING vec2 vary_texcoord2; VARYING vec2 vary_texcoord3; +VARYING float altitude_blend_factor; // Inputs uniform vec3 camPosLocal; @@ -77,12 +78,15 @@ void main() // Get relative position vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0); + altitude_blend_factor = (P.y > -4096.0) ? 1.0 : 1.0 - clamp(abs(P.y) / max_y, 0.0, 1.0); + // Set altitude if (P.y > 0.) { P *= (max_y / P.y); } else + if (P.y <= 0.0) { P *= (-32000. / P.y); } @@ -122,7 +126,6 @@ void main() // compiler gets confused. temp1 = exp(-temp1 * temp2.z); - // Compute haze glow temp2.x = dot(Pn, lightnorm.xyz); temp2.x = 1. - temp2.x; diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index 93024bf4e71281f5685b339d2ed66d26974d7c1a..666ae84e5c1e31ad22694715547cb8fd9ef8029f 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -52,6 +52,7 @@ VARYING vec2 vary_texcoord0; VARYING vec2 vary_texcoord1; VARYING vec2 vary_texcoord2; VARYING vec2 vary_texcoord3; +VARYING float altitude_blend_factor; /// Soft clips the light with a gamma correction vec3 scaleSoftClip(vec3 light); @@ -103,6 +104,8 @@ void main() alpha1 = 1. - alpha1 * alpha1; alpha1 = 1. - alpha1 * alpha1; + alpha1 *= altitude_blend_factor; + if (alpha1 < 0.001f) { discard; diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl index fb978691dad0d28872c62ff385bca7aee96df1b1..3cb69c33a1c528233fd43af58e178de9f86e3010 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl @@ -40,6 +40,7 @@ VARYING vec2 vary_texcoord0; VARYING vec2 vary_texcoord1; VARYING vec2 vary_texcoord2; VARYING vec2 vary_texcoord3; +VARYING float altitude_blend_factor; // Inputs uniform vec3 camPosLocal; @@ -76,6 +77,9 @@ void main() // Get relative position vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0); + // fade clouds beyond a certain point so the bottom of the sky dome doesn't look silly at high altitude + altitude_blend_factor = (P.y > -4096.0) ? 1.0 : 1.0 - clamp(abs(P.y) / max_y, 0.0, 1.0); + // Set altitude if (P.y > 0.) { @@ -86,6 +90,7 @@ void main() P *= (-32000. / P.y); } + // Can normalize then vec3 Pn = normalize(P); float Plen = length(P); diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp index 37689e06837c5f2eea2e7477626b04924b678dc6..40cb0d2c2422ef9d3d4dd1fdbfc9f73c19553b55 100644 --- a/indra/newview/llvowlsky.cpp +++ b/indra/newview/llvowlsky.cpp @@ -111,7 +111,7 @@ inline F32 LLVOWLSky::calcPhi(U32 i) t = t*t; t = 1.f - t; - return F_PI_BY_TWO * t; + return F_PI * t; } void LLVOWLSky::resetVertexBuffers() @@ -248,8 +248,11 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) LL_ERRS() << "Failed updating WindLight sky geometry." << LL_ENDL; } + U32 vertex_count = 0; + U32 index_count = 0; + // fill it - buildStripsBuffer(begin_stack, end_stack, vertices, texCoords, indices); + buildStripsBuffer(begin_stack, end_stack, vertex_count, index_count, vertices, texCoords, indices); // and unlock the buffer segment->flush(); @@ -360,7 +363,10 @@ void LLVOWLSky::initStars() } } -void LLVOWLSky::buildStripsBuffer(U32 begin_stack, U32 end_stack, +void LLVOWLSky::buildStripsBuffer(U32 begin_stack, + U32 end_stack, + U32& vertex_count, + U32& index_count, LLStrider<LLVector3> & vertices, LLStrider<LLVector2> & texCoords, LLStrider<U16> & indices) @@ -380,7 +386,7 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, U32 end_stack, llassert(end_stack <= num_stacks); // stacks are iterated one-indexed since phi(0) was handled by the fan above - for(i = begin_stack + 1; i <= end_stack+1; ++i) + for(i = begin_stack; i <= end_stack; ++i) { phi0 = calcPhi(i); @@ -434,6 +440,9 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, U32 end_stack, *indices++ = i * num_slices + k ; count_indices++ ; } + + vertex_count = count_verts; + index_count = count_indices; } void LLVOWLSky::updateStarColors() diff --git a/indra/newview/llvowlsky.h b/indra/newview/llvowlsky.h index 73ecf1a71780c4a32bd581e1250bf48bda9c0882..2b7ebe75dd7ef05fcb957d67cd895098db359bc6 100644 --- a/indra/newview/llvowlsky.h +++ b/indra/newview/llvowlsky.h @@ -66,6 +66,8 @@ class LLVOWLSky : public LLStaticViewerObject { // begin_stack is the first stack to be included, end_stack is the first // stack not to be included. static void buildStripsBuffer(U32 begin_stack, U32 end_stack, + U32& vertex_count, + U32& index_count, LLStrider<LLVector3> & vertices, LLStrider<LLVector2> & texCoords, LLStrider<U16> & indices);