Skip to content
Snippets Groups Projects
Commit 7423a86a authored by Graham Linden's avatar Graham Linden
Browse files

SL-10751

Fix skydome VB generation to cover entire range of phi (give sky pants).

Add shader code to fade out clouds to simulate old look at altitude.
parent edf8ba6e
No related branches found
No related tags found
No related merge requests found
...@@ -51,6 +51,7 @@ VARYING vec2 vary_texcoord0; ...@@ -51,6 +51,7 @@ VARYING vec2 vary_texcoord0;
VARYING vec2 vary_texcoord1; VARYING vec2 vary_texcoord1;
VARYING vec2 vary_texcoord2; VARYING vec2 vary_texcoord2;
VARYING vec2 vary_texcoord3; VARYING vec2 vary_texcoord3;
VARYING float altitude_blend_factor;
/// Soft clips the light with a gamma correction /// Soft clips the light with a gamma correction
vec3 scaleSoftClip(vec3 light); vec3 scaleSoftClip(vec3 light);
...@@ -102,10 +103,8 @@ void main() ...@@ -102,10 +103,8 @@ void main()
alpha1 = 1. - alpha1 * alpha1; alpha1 = 1. - alpha1 * alpha1;
alpha1 = 1. - alpha1 * alpha1; alpha1 = 1. - alpha1 * alpha1;
if (alpha1 < 0.001f) alpha1 *= altitude_blend_factor;
{ alpha1 = clamp(alpha1, 0.0, 1.0);
discard;
}
// Compute alpha2, for self shadowing effect // Compute alpha2, for self shadowing effect
// (1 - alpha2) will later be used as percentage of incoming sunlight // (1 - alpha2) will later be used as percentage of incoming sunlight
...@@ -119,6 +118,7 @@ void main() ...@@ -119,6 +118,7 @@ void main()
// Combine // Combine
vec4 color; vec4 color;
color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient); color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient);
color.rgb= max(vec3(0), color.rgb);
color *= 2.; color *= 2.;
/// Gamma correct for WL (soft clip effect). /// Gamma correct for WL (soft clip effect).
......
...@@ -41,6 +41,7 @@ VARYING vec2 vary_texcoord0; ...@@ -41,6 +41,7 @@ VARYING vec2 vary_texcoord0;
VARYING vec2 vary_texcoord1; VARYING vec2 vary_texcoord1;
VARYING vec2 vary_texcoord2; VARYING vec2 vary_texcoord2;
VARYING vec2 vary_texcoord3; VARYING vec2 vary_texcoord3;
VARYING float altitude_blend_factor;
// Inputs // Inputs
uniform vec3 camPosLocal; uniform vec3 camPosLocal;
...@@ -77,12 +78,15 @@ void main() ...@@ -77,12 +78,15 @@ void main()
// Get relative position // Get relative position
vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0); 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 // Set altitude
if (P.y > 0.) if (P.y > 0.)
{ {
P *= (max_y / P.y); P *= (max_y / P.y);
} }
else else
if (P.y <= 0.0)
{ {
P *= (-32000. / P.y); P *= (-32000. / P.y);
} }
...@@ -122,7 +126,6 @@ void main() ...@@ -122,7 +126,6 @@ void main()
// compiler gets confused. // compiler gets confused.
temp1 = exp(-temp1 * temp2.z); temp1 = exp(-temp1 * temp2.z);
// Compute haze glow // Compute haze glow
temp2.x = dot(Pn, lightnorm.xyz); temp2.x = dot(Pn, lightnorm.xyz);
temp2.x = 1. - temp2.x; temp2.x = 1. - temp2.x;
......
...@@ -52,6 +52,7 @@ VARYING vec2 vary_texcoord0; ...@@ -52,6 +52,7 @@ VARYING vec2 vary_texcoord0;
VARYING vec2 vary_texcoord1; VARYING vec2 vary_texcoord1;
VARYING vec2 vary_texcoord2; VARYING vec2 vary_texcoord2;
VARYING vec2 vary_texcoord3; VARYING vec2 vary_texcoord3;
VARYING float altitude_blend_factor;
/// Soft clips the light with a gamma correction /// Soft clips the light with a gamma correction
vec3 scaleSoftClip(vec3 light); vec3 scaleSoftClip(vec3 light);
...@@ -103,6 +104,8 @@ void main() ...@@ -103,6 +104,8 @@ void main()
alpha1 = 1. - alpha1 * alpha1; alpha1 = 1. - alpha1 * alpha1;
alpha1 = 1. - alpha1 * alpha1; alpha1 = 1. - alpha1 * alpha1;
alpha1 *= altitude_blend_factor;
if (alpha1 < 0.001f) if (alpha1 < 0.001f)
{ {
discard; discard;
......
...@@ -40,6 +40,7 @@ VARYING vec2 vary_texcoord0; ...@@ -40,6 +40,7 @@ VARYING vec2 vary_texcoord0;
VARYING vec2 vary_texcoord1; VARYING vec2 vary_texcoord1;
VARYING vec2 vary_texcoord2; VARYING vec2 vary_texcoord2;
VARYING vec2 vary_texcoord3; VARYING vec2 vary_texcoord3;
VARYING float altitude_blend_factor;
// Inputs // Inputs
uniform vec3 camPosLocal; uniform vec3 camPosLocal;
...@@ -76,6 +77,9 @@ void main() ...@@ -76,6 +77,9 @@ void main()
// Get relative position // Get relative position
vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0); 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 // Set altitude
if (P.y > 0.) if (P.y > 0.)
{ {
...@@ -86,6 +90,7 @@ void main() ...@@ -86,6 +90,7 @@ void main()
P *= (-32000. / P.y); P *= (-32000. / P.y);
} }
// Can normalize then // Can normalize then
vec3 Pn = normalize(P); vec3 Pn = normalize(P);
float Plen = length(P); float Plen = length(P);
......
...@@ -111,7 +111,7 @@ inline F32 LLVOWLSky::calcPhi(U32 i) ...@@ -111,7 +111,7 @@ inline F32 LLVOWLSky::calcPhi(U32 i)
t = t*t; t = t*t;
t = 1.f - t; t = 1.f - t;
return F_PI_BY_TWO * t; return F_PI * t;
} }
void LLVOWLSky::resetVertexBuffers() void LLVOWLSky::resetVertexBuffers()
...@@ -248,8 +248,11 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) ...@@ -248,8 +248,11 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable)
LL_ERRS() << "Failed updating WindLight sky geometry." << LL_ENDL; LL_ERRS() << "Failed updating WindLight sky geometry." << LL_ENDL;
} }
U32 vertex_count = 0;
U32 index_count = 0;
// fill it // 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 // and unlock the buffer
segment->flush(); segment->flush();
...@@ -360,7 +363,10 @@ void LLVOWLSky::initStars() ...@@ -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<LLVector3> & vertices,
LLStrider<LLVector2> & texCoords, LLStrider<LLVector2> & texCoords,
LLStrider<U16> & indices) LLStrider<U16> & indices)
...@@ -380,7 +386,7 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, U32 end_stack, ...@@ -380,7 +386,7 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, U32 end_stack,
llassert(end_stack <= num_stacks); llassert(end_stack <= num_stacks);
// stacks are iterated one-indexed since phi(0) was handled by the fan above // 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); phi0 = calcPhi(i);
...@@ -434,6 +440,9 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, U32 end_stack, ...@@ -434,6 +440,9 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, U32 end_stack,
*indices++ = i * num_slices + k ; *indices++ = i * num_slices + k ;
count_indices++ ; count_indices++ ;
} }
vertex_count = count_verts;
index_count = count_indices;
} }
void LLVOWLSky::updateStarColors() void LLVOWLSky::updateStarColors()
......
...@@ -66,6 +66,8 @@ class LLVOWLSky : public LLStaticViewerObject { ...@@ -66,6 +66,8 @@ class LLVOWLSky : public LLStaticViewerObject {
// begin_stack is the first stack to be included, end_stack is the first // begin_stack is the first stack to be included, end_stack is the first
// stack not to be included. // stack not to be included.
static void buildStripsBuffer(U32 begin_stack, U32 end_stack, static void buildStripsBuffer(U32 begin_stack, U32 end_stack,
U32& vertex_count,
U32& index_count,
LLStrider<LLVector3> & vertices, LLStrider<LLVector3> & vertices,
LLStrider<LLVector2> & texCoords, LLStrider<LLVector2> & texCoords,
LLStrider<U16> & indices); LLStrider<U16> & indices);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment