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

SL-10764, SL-10768. SL-10763
meow-7.2.2
Rider Linden 2019-03-20 16:10:10 +00:00
commit fa6e4137e3
12 changed files with 78 additions and 47 deletions

View File

@ -8558,6 +8558,28 @@
</array>
</map>
<key>RenderAlphaBatchFullbrights</key>
<map>
<key>Comment</key>
<string>Render fullbright alpha content more efficiently, but with possible visual differences from prev viewers.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>RenderAlphaBatchEmissives</key>
<map>
<key>Comment</key>
<string>Render emissive alpha content more efficiently, but with possible visual differences from prev viewers.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>RenderAnisotropic</key>
<map>
<key>Comment</key>

View File

@ -45,17 +45,6 @@ VARYING vec2 vary_texcoord0;
vec4 applyWaterFogView(vec3 pos, vec4 color);
#endif
vec3 fullbrightAtmosTransportDeferred(vec3 light)
{
return light;
}
vec3 fullbrightScaleSoftClipDeferred(vec3 light)
{
//soft clip effect:
return light;
}
#ifdef HAS_ALPHA_MASK
uniform float minimum_alpha;
#endif
@ -78,8 +67,6 @@ void main()
#endif
color.rgb *= vertex_color.rgb;
color.rgb = fullbrightAtmosTransportDeferred(color.rgb);
color.rgb = fullbrightScaleSoftClipDeferred(color.rgb);
#ifdef WATER_FOG
vec3 pos = vary_position;

View File

@ -72,10 +72,13 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
vec3 getNorm(vec2 pos_screen);
vec3 srgb_to_linear(vec3 cs);
vec3 linear_to_srgb(vec3 cl);
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret.rgb = srgb_to_linear(ret.rgb);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
@ -95,6 +98,7 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret.rgb = srgb_to_linear(ret.rgb);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
@ -112,6 +116,7 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret.rgb = srgb_to_linear(ret.rgb);
vec2 dist = tc-vec2(0.5);

View File

@ -52,7 +52,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
da *= spot*spot; // GL_SPOT_EXPONENT=2
//angular attenuation
da *= calcDirectionalLight(n, lv);
da *= calcDirectionalLight(n, -lv);
return da;
}

View File

@ -71,11 +71,19 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
vec3 srgb_to_linear(vec3 cs);
vec3 getNorm(vec2 pos_screen);
vec4 correctWithGamma(vec4 col)
{
return vec4(srgb_to_linear(col.rgb), col.a);
}
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret = correctWithGamma(ret);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
@ -95,6 +103,7 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret = correctWithGamma(ret);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
@ -211,16 +220,13 @@ void main()
dlit = color.rgb * plcol.rgb * plcol.a;
col = dlit*lit*diff_tex*shadow;
amb_da += (da*0.5) * proj_ambiance;
amb_da += (da*da*0.5 + 0.5) * proj_ambiance;
//amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance;
//amb_da = min(amb_da,shadow);
amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance;
}
//float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod);
amb_da += (da*da*0.5+0.5)*proj_ambiance;
amb_da += (da*da*0.5+0.5)*(1.0-shadow)*proj_ambiance;
amb_da *= dist_atten * noise;

View File

@ -71,11 +71,18 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
vec3 srgb_to_linear(vec3 cs);
vec3 getNorm(vec2 pos_screen);
vec4 correctWithGamma(vec4 col)
{
return vec4(srgb_to_linear(col.rgb), col.a);
}
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret = correctWithGamma(ret);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
@ -95,6 +102,7 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret = correctWithGamma(ret);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
@ -112,6 +120,7 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret = correctWithGamma(ret);
vec2 dist = tc-vec2(0.5);
@ -216,7 +225,7 @@ void main()
//float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod);
amb_da += (da*da*0.5+0.5)*proj_ambiance;
amb_da += (da*da*0.5+0.5)*(1.0-shadow)*proj_ambiance;
amb_da *= dist_atten * noise;

View File

@ -34,7 +34,7 @@ vec3 atmosGetDiffuseSunlightColor();
vec3 scaleDownLight(vec3 light);
uniform vec4 light_position[8];
uniform vec3 light_attenuation[8];
uniform vec4 light_attenuation[8];
uniform vec3 light_diffuse[8];
vec4 sumLightsSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol)

View File

@ -32,7 +32,7 @@ vec3 atmosGetDiffuseSunlightColor();
vec3 scaleDownLight(vec3 light);
uniform vec4 light_position[8];
uniform vec3 light_attenuation[8];
uniform vec4 light_attenuation[8];
uniform vec3 light_diffuse[8];
vec4 sumLightsSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol)

View File

@ -32,7 +32,7 @@ vec3 atmosAffectDirectionalLight(float lightIntensity);
uniform vec4 light_position[8];
uniform vec3 light_direction[8];
uniform vec3 light_attenuation[8];
uniform vec4 light_attenuation[8];
uniform vec3 light_diffuse[8];
vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight)

View File

@ -49,10 +49,6 @@
#include "llspatialpartition.h"
#include "llglcommonfunc.h"
// These optimizations can and will induce lighting, texturing, and/or GL state bugs
#define BATCH_FULLBRIGHTS 0
#define BATCH_EMISSIVES 0
BOOL LLDrawPoolAlpha::sShowDebugAlpha = FALSE;
static BOOL deferred_render = FALSE;
@ -392,7 +388,7 @@ bool LLDrawPoolAlpha::TexSetup(LLDrawInfo* draw, bool use_shaders, bool use_mate
bool tex_setup = false;
if (use_shaders && use_material && current_shader)
if (deferred_render && use_material && current_shader)
{
LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_DEFERRED_TEX_BINDS);
if (draw->mNormalMap)
@ -612,6 +608,8 @@ void LLDrawPoolAlpha::renderEmissives(U32 mask, std::vector<LLDrawInfo*>& emissi
void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass)
{
BOOL batch_fullbrights = gSavedSettings.getBOOL("RenderAlphaBatchFullbrights");
BOOL batch_emissives = gSavedSettings.getBOOL("RenderAlphaBatchEmissives");
BOOL initialized_lighting = FALSE;
BOOL light_enabled = TRUE;
@ -671,13 +669,11 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass)
}
}
#if BATCH_FULLBRIGHTS
if (params.mFullbright)
if (params.mFullbright && batch_fullbrights)
{
fullbrights.push_back(&params);
continue;
}
#endif
LLRenderPass::applyModelMatrix(params);
@ -770,7 +766,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass)
F32 brightness = 1.0f;
// We have a material. Supply the appropriate data here.
if (use_shaders && mat && LLPipeline::sRenderDeferred)
if (use_shaders && mat && deferred_render)
{
spec_color = params.mSpecColor;
env_intensity = params.mEnvIntensity;
@ -789,7 +785,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass)
params.mGroup->rebuildMesh();
}
bool tex_setup = TexSetup(&params, use_shaders, mat != nullptr, current_shader);
bool tex_setup = TexSetup(&params, use_shaders, use_shaders && (mat != nullptr), current_shader);
{
LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_PUSH);
@ -806,17 +802,21 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass)
}
}
// If this alpha mesh has glow, then draw it a second time to add the destination-alpha (=glow). Interleaving these state-changing calls could be expensive, but glow must be drawn Z-sorted with alpha.
// If this alpha mesh has glow, then draw it a second time to add the destination-alpha (=glow). Interleaving these state-changing calls is expensive, but glow must be drawn Z-sorted with alpha.
if (current_shader &&
draw_glow_for_this_partition &&
params.mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_EMISSIVE))
{
LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_EMISSIVE);
#if BATCH_EMISSIVES
emissives.push_back(&params);
#else
drawEmissiveInline(mask, &params);
#endif
if (batch_emissives)
{
emissives.push_back(&params);
}
else
{
drawEmissiveInline(mask, &params);
}
}
if (tex_setup)
@ -828,15 +828,17 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass)
}
}
#if BATCH_FULLBRIGHTS
if (batch_fullbrights)
{
light_enabled = false;
renderFullbrights(mask, fullbrights);
#endif
}
#if BATCH_EMISSIVES
if (batch_emissives)
{
light_enabled = true;
renderEmissives(mask, emissives);
#endif
}
if (current_shader)
{

View File

@ -271,9 +271,9 @@ void LLDrawPoolWater::render(S32 pass)
glDisable(GL_TEXTURE_GEN_S); //texture unit 1
glDisable(GL_TEXTURE_GEN_T); //texture unit 1
gGL.getTexUnit(1)->activate();
gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
gGL.getTexUnit(1)->disable();
gGL.getTexUnit(2)->activate();
gGL.getTexUnit(2)->unbind(LLTexUnit::TT_TEXTURE);
gGL.getTexUnit(2)->disable();
glDisable(GL_TEXTURE_GEN_S); //texture unit 1
glDisable(GL_TEXTURE_GEN_T); //texture unit 1

View File

@ -6346,7 +6346,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
light_state->setSpotExponent(0.f);
light_state->setSpotCutoff(180.f);
// we use specular.w = 1.0 as a cheap hack for the shaders to know that this is omnidirectional rather than a spotlight
// we use specular.z = 1.0 as a cheap hack for the shaders to know that this is omnidirectional rather than a spotlight
const LLColor4 specular(0.f, 0.f, 1.f, 0.f);
light_state->setSpecular(specular);
}