SL-11370, SL-11372, SL-11337

Fix culling on Low+ water reflection pass.

Make Mid+ / High use class1 deferred sky again (no rainbows, but faster!).

Fix setting of cloud color for deferred sky/cloud shaders.

Put water reflections back in wrong colorspace for consistency with release.
master
Graham Linden 2019-06-11 13:03:06 -07:00
parent c15baecbfb
commit 653133b9c0
19 changed files with 54 additions and 32 deletions

View File

@ -239,7 +239,7 @@ void main()
vec3 sun_contrib = min(final_da, shadow) * sunlit;
#if !defined(AMBIENT_KILL)
color.rgb = amblit * 2.0;
color.rgb = amblit;
color.rgb *= ambient;
#endif

View File

@ -55,7 +55,6 @@ VARYING float altitude_blend_factor;
/// Soft clips the light with a gamma correction
vec3 scaleSoftClip(vec3 light);
vec3 linear_to_srgb(vec3 c);
vec4 cloudNoise(vec2 uv)
{
@ -121,10 +120,13 @@ void main()
color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient);
color.rgb= max(vec3(0), color.rgb);
color.rgb *= 2.0;
color.rgb = scaleSoftClip(color.rgb);
/// Gamma correct for WL (soft clip effect).
frag_data[0] = vec4(scaleSoftClip(color.rgb), alpha1);
frag_data[0] = vec4(color.rgb, alpha1);
frag_data[1] = vec4(0.0,0.0,0.0,0.0);
frag_data[2] = vec4(0,0,1,0);
frag_data[2] = vec4(0,0,0,1);
gl_FragDepth = 0.99995f;
}

View File

@ -326,7 +326,7 @@ void main()
vec3 sun_contrib = min(final_da, shadow) * sunlit;
#if !defined(AMBIENT_KILL)
color.rgb = amblit * 2.0;
color.rgb = amblit;
color.rgb *= ambient;
#endif

View File

@ -58,6 +58,7 @@ uniform mat4 inv_proj;
vec4 getPosition(vec2 pos_screen);
vec3 getNorm(vec2 pos_screen);
vec3 srgb_to_linear(vec3 c);
void main()
{
@ -77,6 +78,7 @@ void main()
vec4 spec = texture2DRect(specularRect, frag.xy);
vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb;
diff.rgb = srgb_to_linear(diff.rgb);
float noise = texture2D(noiseMap, frag.xy/128.0).b;
vec3 npos = normalize(-pos);

View File

@ -178,6 +178,8 @@ void main()
vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
diff_tex.rgb = srgb_to_linear(diff_tex.rgb);
vec3 dlit = vec3(0, 0, 0);
float noise = texture2D(noiseMap, frag.xy/128.0).b;

View File

@ -89,6 +89,7 @@ void main()
float noise = texture2D(noiseMap, frag.xy/128.0).b;
vec3 col = texture2DRect(diffuseRect, frag.xy).rgb;
float fa = falloff+1.0;
float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
dist_atten *= dist_atten;

View File

@ -41,6 +41,8 @@ uniform vec4 gamma;
/// Soft clips the light with a gamma correction
vec3 scaleSoftClip(vec3 light);
vec3 srgb_to_linear(vec3 c);
vec3 linear_to_srgb(vec3 c);
void main()
{
@ -51,10 +53,12 @@ void main()
vec4 color;
color = vary_HazeColor;
color *= 2.;
color.rgb *= 2.0f;
//color.rgb = scaleSoftClip(color.rgb);
//color.rgb = linear_to_srgb(color.rgb);
/// Gamma correct for WL (soft clip effect).
frag_data[0] = vec4(scaleSoftClip(color.rgb), 1.0);
frag_data[0] = vec4(color.rgb, 1.0);
frag_data[1] = vec4(0.0,0.0,0.0,0.0);
frag_data[2] = vec4(0.5,0.5,0.0,1.0); //1.0 in norm.w masks off fog

View File

@ -49,6 +49,7 @@ uniform float haze_density;
uniform float cloud_shadow;
uniform float density_multiplier;
uniform float distance_multiplier;
uniform float max_y;
uniform vec4 glow;
@ -88,6 +89,7 @@ void main()
vec4 light_atten;
float dens_mul = density_multiplier;
float dist_mul = distance_multiplier;
// Sunlight attenuation effect (hue and brightness) due to atmosphere
// this is used later for sunlight modulation at various altitudes
@ -109,7 +111,7 @@ void main()
// Transparency (-> temp1)
// ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati
// compiler gets confused.
temp1 = exp(-temp1 * temp2.z);
temp1 = exp(-temp1 * temp2.z * dist_mul);
// Compute haze glow
@ -153,7 +155,7 @@ void main()
// 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);
}

View File

@ -111,8 +111,8 @@ void main()
vec3 sun_contrib = final_da * sunlit;
#if !defined(AMBIENT_KILL)
color.rgb = amblit;
color.rgb *= ambient;
color.rgb = amblit * 2.0;
color.rgb *= ambient * 0.5;
#endif
vec3 post_ambient = color.rgb;

View File

@ -177,6 +177,8 @@ void main()
float da = dot(norm, lv);
vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
diff_tex.rgb = srgb_to_linear(diff_tex.rgb);
vec4 spec = texture2DRect(specularRect, frag.xy);
float noise = texture2D(noiseMap, frag.xy/128.0).b;

View File

@ -144,7 +144,6 @@ void main()
vec4 baseCol = texture2D(refTex, refvec4);
refcol = mix(baseCol*df2, refcol, dweight);
refcol.rgb = srgb_to_linear(refcol.rgb);
//get specular component
float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0);
@ -159,7 +158,7 @@ void main()
//mix with reflection
// Note we actually want to use just df1, but multiplying by 0.999999 gets around an nvidia compiler bug
color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.4 + 0.6);
color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.999999);
vec4 pos = vary_position;
@ -167,7 +166,7 @@ void main()
//color.rgb = atmosTransport(color.rgb);
color.rgb = scaleSoftClip(color.rgb);
color.a = spec * sunAngle2;
vec3 screenspacewavef = normalize((norm_mat*vec4(wavef, 1.0)).xyz);

View File

@ -150,11 +150,9 @@ void main()
//mix with reflection
// Note we actually want to use just df1, but multiplying by 0.999999 gets around and nvidia compiler bug
color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.4 + 0.6);
color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.9999999);
color.rgb += spec * specular;
//color.rgb = atmosTransport(color.rgb);
color.rgb = scaleSoftClip(color.rgb * 0.5);
color.a = spec * sunAngle2;
#if defined(WATER_EDGE)

View File

@ -35,7 +35,7 @@ vec4 calcLighting(vec3 pos, vec3 norm, vec4 color)
vec4 c = sumLights(pos, norm, color);
#if !defined(AMBIENT_KILL)
c.rgb += atmosAmbient() * color.rgb * getAmbientClamp();
c.rgb += atmosAmbient() * color.rgb * 0.5 * getAmbientClamp();
#endif
return c;

View File

@ -191,7 +191,8 @@ void main()
float da = dot(norm, lv);
vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
diff_tex.rgb = srgb_to_linear(diff_tex.rgb);
vec4 spec = texture2DRect(specularRect, frag.xy);
vec3 dlit = vec3(0, 0, 0);

View File

@ -88,7 +88,6 @@ vec3 halo22(float d)
/// Soft clips the light with a gamma correction
vec3 scaleSoftClip(vec3 light);
vec3 srgb_to_linear(vec3 c);
void main()
{
@ -198,7 +197,6 @@ void main()
color.rgb *= 2.;
color.rgb = scaleSoftClip(color.rgb);
color.rgb = srgb_to_linear(color.rgb);
/// Gamma correct for WL (soft clip effect).
frag_data[0] = vec4(color.rgb, 1.0);

View File

@ -91,8 +91,8 @@ void main()
float final_da = da;
final_da = clamp(final_da, 0.0, 1.0);
vec4 diffuse_linear = texture2DRect(diffuseRect, tc);
vec4 diffuse_srgb = vec4(linear_to_srgb(diffuse_linear.rgb), diffuse_linear.a);
vec4 diffuse_srgb = texture2DRect(diffuseRect, tc);
vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a);
// clamping to alpha value kills underwater shadows...
//scol = max(scol_ambocc.r, diffuse_linear.a);
@ -120,7 +120,7 @@ void main()
#if !defined(AMBIENT_KILL)
color.rgb = amblit * 2.0;
color.rgb *= ambient;
color.rgb *= ambient * 0.5;
#endif
vec3 post_ambient = color.rgb;
@ -131,7 +131,7 @@ vec3 post_ambient = color.rgb;
vec3 post_sunlight = color.rgb;
color.rgb *= diffuse_linear.rgb;
color.rgb *= diffuse_srgb.rgb;
vec3 post_diffuse = color.rgb;
@ -183,8 +183,10 @@ vec3 post_env = color.rgb;
if (norm.w < 1)
{
#if !defined(SUNLIGHT_KILL)
color = atmosFragLighting(color, additive, atten);
color = scaleSoftClipFrag(color);
#endif
}
vec3 post_atmo = color.rgb;
@ -216,6 +218,7 @@ vec3 post_atmo = color.rgb;
//color.rgb = vec3(final_da);
//color.rgb = vec3(ambient);
//color.rgb = vec3(scol);
//color.rgb = diffuse_linear.rgb;
frag_color.rgb = color.rgb;
frag_color.a = bloom;

View File

@ -123,11 +123,12 @@ void main()
// Combine
vec4 color;
color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient);
color *= 2.;
color.rgb *= 2.;
color.rgb = scaleSoftClip(color.rgb);
/// Gamma correct for WL (soft clip effect).
frag_data[0] = vec4(scaleSoftClip(color.rgb), alpha1);
frag_data[0] = vec4(color.rgb, alpha1);
frag_data[1] = vec4(0.0,0.0,0.0,0.0);
frag_data[2] = vec4(0,0,1,0);
frag_data[2] = vec4(0,0,0,1);
}

View File

@ -43,6 +43,7 @@
#include "pipeline.h"
#include "llsky.h"
#include "llvowlsky.h"
#include "llsettingsvo.h"
static LLStaticHashedString sCamPosLocal("camPosLocal");
static LLStaticHashedString sCustomAlpha("custom_alpha");
@ -181,6 +182,8 @@ void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 ca
sky_shader->bindTexture(LLShaderMgr::RAINBOW_MAP, rainbow_tex);
sky_shader->bindTexture(LLShaderMgr::HALO_MAP, halo_tex);
((LLSettingsVOSky*)psky.get())->updateShader(sky_shader);
F32 moisture_level = (float)psky->getSkyMoistureLevel();
F32 droplet_radius = (float)psky->getSkyDropletRadius();
F32 ice_level = (float)psky->getSkyIceLevel();
@ -397,6 +400,8 @@ void LLDrawPoolWLSky::renderSkyCloudsDeferred(const LLVector3& camPosLocal, F32
cloudshader->uniform1f(LLShaderMgr::CLOUD_VARIANCE, cloud_variance);
cloudshader->uniform1f(LLShaderMgr::SUN_MOON_GLOW_FACTOR, psky->getSunMoonGlowFactor());
((LLSettingsVOSky*)psky.get())->updateShader(cloudshader);
/// Render the skydome
renderDome(camPosLocal, camHeightLocal, cloudshader);

View File

@ -1744,6 +1744,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredLightProgram.mName = "Deferred Light Shader";
gDeferredLightProgram.mFeatures.isDeferred = true;
gDeferredLightProgram.mFeatures.hasShadows = true;
gDeferredLightProgram.mFeatures.hasSrgb = true;
gDeferredLightProgram.mShaderFiles.clear();
gDeferredLightProgram.mShaderFiles.push_back(make_pair("deferred/pointLightV.glsl", GL_VERTEX_SHADER_ARB));
@ -1778,6 +1779,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredMultiLightProgram[i].mName = llformat("Deferred MultiLight Shader %d", i);
gDeferredMultiLightProgram[i].mFeatures.isDeferred = true;
gDeferredMultiLightProgram[i].mFeatures.hasShadows = true;
gDeferredMultiLightProgram[i].mFeatures.hasSrgb = true;
gDeferredMultiLightProgram[i].clearPermutations();
gDeferredMultiLightProgram[i].mShaderFiles.clear();
@ -2693,7 +2695,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredWLSkyProgram.mShaderFiles.push_back(make_pair("deferred/skyV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredWLSkyProgram.mShaderFiles.push_back(make_pair("deferred/skyF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredWLSkyProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT];
gDeferredWLSkyProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
gDeferredWLSkyProgram.mShaderGroup = LLGLSLShader::SG_SKY;
success = gDeferredWLSkyProgram.createShader(NULL, NULL);
@ -2711,7 +2713,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT];
gDeferredWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
gDeferredWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY;
success = gDeferredWLCloudProgram.createShader(NULL, NULL);
llassert(success);
@ -4096,11 +4098,11 @@ BOOL LLViewerShaderMgr::loadShadersWindLight()
if (success)
{
gWLSkyProgram.mName = "Windlight Sky Shader";
//gWLSkyProgram.mFeatures.hasGamma = true;
gWLSkyProgram.mShaderFiles.clear();
gWLSkyProgram.mFeatures.calculatesAtmospherics = true;
gWLSkyProgram.mFeatures.hasTransport = true;
gWLSkyProgram.mFeatures.hasGamma = true;
gWLSkyProgram.mFeatures.hasSrgb = true;
gWLSkyProgram.mShaderFiles.push_back(make_pair("windlight/skyV.glsl", GL_VERTEX_SHADER_ARB));
gWLSkyProgram.mShaderFiles.push_back(make_pair("windlight/skyF.glsl", GL_FRAGMENT_SHADER_ARB));
gWLSkyProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT];