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

Sky fixes.

Make class1 sky use pre-projection pos to get proper distances for attenuation.

Make all sky shaders use the dist_mul again.

Revert to using old sky tessellation logic (may regress bugs addressed by new tess code).
parent 7f243958
No related branches found
No related tags found
No related merge requests found
...@@ -41,6 +41,7 @@ uniform vec4 gamma; ...@@ -41,6 +41,7 @@ uniform vec4 gamma;
/// Soft clips the light with a gamma correction /// Soft clips the light with a gamma correction
vec3 scaleSoftClip(vec3 light); vec3 scaleSoftClip(vec3 light);
vec3 srgb_to_linear(vec3 c);
void main() void main()
{ {
......
...@@ -66,7 +66,7 @@ void main() ...@@ -66,7 +66,7 @@ void main()
gl_Position = pos; gl_Position = pos;
// Get relative position // Get relative position
vec3 P = pos.xyz - camPosLocal.xyz + vec3(0,50,0); vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0);
// Set altitude // Set altitude
if (P.y > 0.) if (P.y > 0.)
...@@ -81,7 +81,7 @@ void main() ...@@ -81,7 +81,7 @@ void main()
// Can normalize then // Can normalize then
vec3 Pn = normalize(P); vec3 Pn = normalize(P);
float Plen = length(P); float Plen = length(P);
// Initialize temp variables // Initialize temp variables
vec4 temp1 = vec4(0.); vec4 temp1 = vec4(0.);
...@@ -114,9 +114,7 @@ void main() ...@@ -114,9 +114,7 @@ void main()
// Transparency (-> temp1) // Transparency (-> temp1)
// ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati
// compiler gets confused. // compiler gets confused.
//temp1 = exp(-temp1 * temp2.z * dist_mul); temp1 = exp(-temp1 * temp2.z * dist_mul);
temp1 = exp(-temp1 * dist_mul);
// Compute haze glow // Compute haze glow
temp2.x = dot(Pn, lightnorm.xyz); temp2.x = dot(Pn, lightnorm.xyz);
...@@ -132,12 +130,13 @@ void main() ...@@ -132,12 +130,13 @@ void main()
// Add "minimum anti-solar illumination" // Add "minimum anti-solar illumination"
temp2.x += .25; temp2.x += .25;
temp2.x *= sun_moon_glow_factor; //temp2.x *= sun_moon_glow_factor;
vec4 color = ( blue_horizon * blue_weight * (sunlight + ambient_color) vec4 color = ( blue_horizon * blue_weight * (sunlight + ambient_color)
+ (haze_horizon * haze_weight) * (sunlight * temp2.x + ambient_color) + (haze_horizon * haze_weight) * (sunlight * temp2.x + ambient_color)
); );
// Final atmosphere additive // Final atmosphere additive
color *= (1. - temp1); color *= (1. - temp1);
......
...@@ -141,8 +141,7 @@ void main() ...@@ -141,8 +141,7 @@ void main()
// Transparency (-> temp1) // Transparency (-> temp1)
// ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati
// compiler gets confused. // compiler gets confused.
//temp1 = exp(-temp1 * temp2.z * dist_mul); temp1 = exp(-temp1 * temp2.z * dist_mul);
temp1 = exp(-temp1 * dist_mul);
// Compute haze glow // Compute haze glow
temp2.x = dot(Pn, lightnorm.xyz); temp2.x = dot(Pn, lightnorm.xyz);
......
...@@ -111,7 +111,7 @@ void main() ...@@ -111,7 +111,7 @@ void main()
// Transparency (-> temp1) // Transparency (-> temp1)
// ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati
// compiler gets confused. // compiler gets confused.
temp1 = exp(-temp1 * dist_mul); temp1 = exp(-temp1 * temp2.z * dist_mul);
// Compute haze glow // Compute haze glow
temp2.x = dot(Pn, lightnorm.xyz); temp2.x = dot(Pn, lightnorm.xyz);
......
...@@ -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 * t; return (F_PI / 8.f) * t;
} }
void LLVOWLSky::resetVertexBuffers() void LLVOWLSky::resetVertexBuffers()
...@@ -382,7 +382,11 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, ...@@ -382,7 +382,11 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_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
#if NEW_TESS
for(i = begin_stack; i <= end_stack; ++i) for(i = begin_stack; i <= end_stack; ++i)
#else
for(i = begin_stack + 1; i <= end_stack+1; ++i)
#endif
{ {
phi0 = calcPhi(i); phi0 = calcPhi(i);
...@@ -396,7 +400,22 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, ...@@ -396,7 +400,22 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack,
y0 = cos(phi0); y0 = cos(phi0);
z0 = sin(phi0) * sin(theta); z0 = sin(phi0) * sin(theta);
#if NEW_TESS
*vertices++ = LLVector3(x0 * RADIUS, y0 * RADIUS, z0 * RADIUS); *vertices++ = LLVector3(x0 * RADIUS, y0 * RADIUS, z0 * RADIUS);
#else
if (i == num_stacks-2)
{
*vertices++ = LLVector3(x0*RADIUS, y0*RADIUS-1024.f*2.f, z0*RADIUS);
}
else if (i == num_stacks-1)
{
*vertices++ = LLVector3(0, y0*RADIUS-1024.f*2.f, 0);
}
else
{
*vertices++ = LLVector3(x0 * RADIUS, y0 * RADIUS, z0 * RADIUS);
}
#endif
++count_verts; ++count_verts;
...@@ -404,7 +423,7 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, ...@@ -404,7 +423,7 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack,
// note: x and z are transposed in order for things to animate // note: x and z are transposed in order for things to animate
// correctly in the global coordinate system where +x is east and // correctly in the global coordinate system where +x is east and
// +y is north // +y is north
*texCoords++ = LLVector2((-z0 + 1.f) / 2.f, (-x0 + 1.f) / 2.f); *texCoords++ = LLVector2((-z0 + 1.f) / 2.f, (-x0 + 1.f) / 2.f);
} }
} }
......
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