Merged in graham_linden/viewer-eep-fixes (pull request #243)

SL-10303, SL-10414, SL-10415, SL-10424, SL-10381
meow-7.2.2
Rider Linden 2019-01-29 18:25:20 +00:00
commit 51fe738aaf
12 changed files with 74 additions and 66 deletions

View File

@ -132,7 +132,7 @@ void main()
temp2.x = pow(temp2.x, glow.z);
// glow.z should be negative, so we're doing a sort of (1 / "angle") function
temp2.x *= sun_up_factor;
//temp2.x *= sun_up_factor;
// Add "minimum anti-solar illumination"
temp2.x += .25;

View File

@ -37,10 +37,11 @@ void calcAtmospherics(vec3 eye_pos);
void main()
{
//transform vertex
vec4 vert = vec4(position.xyz, 1.0);
vec3 offset = vec3(0, 0, 50);
vec4 vert = vec4(position.xyz - offset, 1.0);
vec4 pos = (modelview_matrix * vert);
gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
gl_Position = modelview_projection_matrix*vert;
calcAtmospherics(pos.xyz);

View File

@ -48,44 +48,28 @@ uniform float shadow_bias;
uniform float spot_shadow_bias;
uniform float spot_shadow_offset;
uniform float sun_up_factor;
uniform mat4 inv_proj;
uniform vec2 screen_res;
vec3 decode_normal(vec2 enc);
float pcfShadowLegacy(sampler2DShadow shadowMap, vec4 stc)
float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float bias_mul, vec2 pos_screen, vec3 light_dir)
{
stc.xyz /= stc.w;
stc.z += shadow_bias;
stc.x = floor(stc.x*shadow_res.x + fract(stc.y*shadow_res.y*12345))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here
float cs = shadow2D(shadowMap, stc.xyz).x;
float shadow = cs;
stc.xyz /= stc.w;
stc.z += max(0.5, light_dir.z) * shadow_bias * 8.0 * bias_mul;
stc.x = floor(stc.x*shadow_res.x + fract(stc.y*pos_screen.y*3.14159))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here
float cs = shadow2D(shadowMap, stc.xyz).x;
float shadow = cs * 4.0;
shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x;
shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x;
shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x;
shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x;
return shadow*0.2;
}
float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float bias_scale, vec2 pos_screen)
{
stc.xyz /= stc.w;
stc.z += shadow_bias * bias_scale;
stc.x = floor(stc.x*pos_screen.x + fract(stc.y*pos_screen.y*0.666666666))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here
float cs = shadow2D(shadowMap, stc.xyz).x;
float shadow = cs;
shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x;
shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x;
shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x;
shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x;
return shadow*0.2;
return shadow*0.125;
}
float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float bias_scale, vec2 pos_screen)
@ -111,10 +95,10 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen)
{
float dp_sun = max(0.0, dot(sun_dir.xyz, norm));
float dp_moon = max(0.0, dot(moon_dir.xyz, norm));
float dp_directional_light = max(dp_sun,dp_moon);
float dp_directional_light = (sun_up_factor > 0) ? dp_sun : dp_moon;
dp_directional_light = clamp(dp_directional_light, 0.0, 1.0);
vec3 light_dir = (dp_moon > dp_sun) ? moon_dir : sun_dir;
vec3 light_dir = (sun_up_factor > 0) ? sun_dir : moon_dir;
vec3 offset = light_dir * (1.0-dp_directional_light);
vec3 shadow_pos = pos.xyz + (offset * shadow_bias);
@ -141,7 +125,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen)
float w = 1.0;
w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
shadow += pcfShadowLegacy(shadowMap3, lpos)*w;
shadow += pcfShadow(shadowMap3, lpos, 0.25, pos_screen, light_dir)*w;
weight += w;
shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
}
@ -153,7 +137,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen)
float w = 1.0;
w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;
w -= max(near_split.z-spos.z, 0.0)/transition_domain.z;
shadow += pcfShadowLegacy(shadowMap2, lpos)*w;
shadow += pcfShadow(shadowMap2, lpos, 0.5, pos_screen, light_dir)*w;
weight += w;
}
@ -164,7 +148,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen)
float w = 1.0;
w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;
w -= max(near_split.y-spos.z, 0.0)/transition_domain.y;
shadow += pcfShadowLegacy(shadowMap1, lpos)*w;
shadow += pcfShadow(shadowMap1, lpos, 0.75, pos_screen, light_dir)*w;
weight += w;
}
@ -175,14 +159,15 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen)
float w = 1.0;
w -= max(near_split.x-spos.z, 0.0)/transition_domain.x;
shadow += pcfShadowLegacy(shadowMap0, lpos)*w;
shadow += pcfShadow(shadowMap0, lpos, 1.0, pos_screen, light_dir)*w;
weight += w;
}
shadow /= weight;
}
return min(dp_directional_light, shadow);
shadow = min(dp_directional_light, shadow);
return shadow;
}
float sampleSpotShadow(vec3 pos, vec3 norm, int index, vec2 pos_screen)
@ -201,11 +186,19 @@ float sampleSpotShadow(vec3 pos, vec3 norm, int index, vec2 pos_screen)
float weight = 0.0;
{
lpos = shadow_matrix[4 + index]*spos;
float w = 1.0;
w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
shadow += pcfSpotShadow((index == 0) ? shadowMap4 : shadowMap5, lpos, 0.8, spos.xy)*w;
if (index == 0)
{
lpos = shadow_matrix[4]*spos;
shadow += pcfSpotShadow(shadowMap4, lpos, 0.8, spos.xy)*w;
}
else
{
lpos = shadow_matrix[5]*spos;
shadow += pcfSpotShadow(shadowMap5, lpos, 0.8, spos.xy)*w;
}
weight += w;
shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
}

View File

@ -36,13 +36,14 @@ VARYING vec2 vary_texcoord0;
void main()
{
//transform vertex
vec4 vert = vec4(position.xyz, 1.0);
vec4 pos = (modelview_matrix * vert);
//transform vertex
vec3 offset = vec3(0, 0, 50);
vec4 vert = vec4(position.xyz - offset, 1.0);
vec4 pos = (modelview_matrix * vert);
gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
calcAtmospherics(pos.xyz);
gl_Position = modelview_projection_matrix*vert;
vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
calcAtmospherics(pos.xyz);
}

View File

@ -38,7 +38,8 @@ void calcAtmospherics(vec3 eye_pos);
void main()
{
//transform vertex
vec4 vert = vec4(position.xyz, 1.0);
vec3 offset = vec3(0, 0, 50);
vec4 vert = vec4(position.xyz - offset, 1.0);
vec4 pos = modelview_projection_matrix*vert;
sun_fade = smoothstep(0.3, 1.0, (position.z + 50) / 512.0f);

View File

@ -153,7 +153,7 @@ void main()
// Add "minimum anti-solar illumination"
temp2.x += .25;
temp2.x *= sun_up_factor;
//temp2.x *= sun_up_factor;
// Haze color above cloud
vec4 color = ( blue_horizon * blue_weight * (sunlight + ambient)

View File

@ -119,7 +119,7 @@ void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit,
//add "minimum anti-solar illumination"
temp2.x += .25;
temp2.x *= sun_up_factor;
//temp2.x *= sun_up_factor;
//increase ambient when there are more clouds
vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5;

View File

@ -131,7 +131,7 @@ void main()
temp2.x = pow(temp2.x, glow.z);
// glow.z should be negative, so we're doing a sort of (1 / "angle") function
temp2.x *= sun_up_factor;
//temp2.x *= sun_up_factor;
// Add "minimum anti-solar illumination"
temp2.x += .25;

View File

@ -119,7 +119,7 @@ void main()
temp2.x = pow(temp2.x, glow.z);
// glow.z should be negative, so we're doing a sort of (1 / "angle") function
temp2.x *= sun_up_factor;
//temp2.x *= sun_up_factor;
// Add "minimum anti-solar illumination"
temp2.x += .25;

View File

@ -145,6 +145,18 @@ S32 LLDrawPoolTerrain::getDetailMode()
return sDetailMode;
}
void LLDrawPoolTerrain::boostTerrainDetailTextures()
{
// Hack! Get the region that this draw pool is rendering from!
LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion();
LLVLComposition *compp = regionp->getComposition();
for (S32 i = 0; i < 4; i++)
{
compp->mDetailTextures[i]->setBoostLevel(LLGLTexture::BOOST_TERRAIN);
compp->mDetailTextures[i]->addTextureStats(1024.f*1024.f); // assume large pixel area
}
}
void LLDrawPoolTerrain::render(S32 pass)
{
LL_RECORD_BLOCK_TIME(FTM_RENDER_TERRAIN);
@ -154,14 +166,7 @@ void LLDrawPoolTerrain::render(S32 pass)
return;
}
// Hack! Get the region that this draw pool is rendering from!
LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion();
LLVLComposition *compp = regionp->getComposition();
for (S32 i = 0; i < 4; i++)
{
compp->mDetailTextures[i]->setBoostLevel(LLGLTexture::BOOST_TERRAIN);
compp->mDetailTextures[i]->addTextureStats(1024.f*1024.f); // assume large pixel area
}
boostTerrainDetailTextures();
LLOverrideFaceColor override(this, 1.f, 1.f, 1.f, 1.f);
@ -236,6 +241,8 @@ void LLDrawPoolTerrain::renderDeferred(S32 pass)
return;
}
boostTerrainDetailTextures();
renderFullShader();
// Special-case for land ownership feedback

View File

@ -78,6 +78,8 @@ public:
static F32 sDetailScale; // meters per texture
protected:
void boostTerrainDetailTextures();
void renderSimple();
void renderOwnership();

View File

@ -9459,12 +9459,14 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
water_clip = -1;
}
S32 occlusion = LLPipeline::sUseOcclusion;
LLPipeline::sUseOcclusion = 0;
if (!LLViewerCamera::getInstance()->cameraUnderWater())
{ //generate planar reflection map
//disable occlusion culling for reflection map for now
S32 occlusion = LLPipeline::sUseOcclusion;
LLPipeline::sUseOcclusion = 0;
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
glClearColor(0,0,0,0);
@ -9603,8 +9605,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
gGL.matrixMode(LLRender::MM_MODELVIEW);
gGL.popMatrix();
mWaterRef.flush();
set_current_modelview(current);
LLPipeline::sUseOcclusion = occlusion;
set_current_modelview(current);
}
camera.setOrigin(camera_in.getOrigin());
@ -9708,6 +9709,8 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
}
last_update = LLDrawPoolWater::sNeedsReflectionUpdate && LLDrawPoolWater::sNeedsDistortionUpdate;
LLPipeline::sUseOcclusion = occlusion;
LLPipeline::sUnderWaterRender = false;
LLPipeline::sReflectionRender = false;