Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions indra/llrender/llshadermgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,7 @@ void LLShaderMgr::initAttribsAndUniforms()

mReservedUniforms.push_back("minimum_alpha");
mReservedUniforms.push_back("emissive_brightness");
mReservedUniforms.push_back("alpha_gamma");

// Deferred
mReservedUniforms.push_back("shadow_matrix");
Expand Down
1 change: 1 addition & 0 deletions indra/llrender/llshadermgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class LLShaderMgr

MINIMUM_ALPHA, // "minimum_alpha"
EMISSIVE_BRIGHTNESS, // "emissive_brightness"
ALPHA_GAMMA, // "alpha_gamma"

DEFERRED_SHADOW_MATRIX, // "shadow_matrix"
DEFERRED_ENV_MAT, // "env_mat"
Expand Down
11 changes: 11 additions & 0 deletions indra/newview/app_settings/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7478,6 +7478,17 @@
<key>Value</key>
<integer>0</integer>
</map>
<key>RenderLegacyAlphaGamma</key>
<map>
<key>Comment</key>
<string>Gamma correction factor (clamped between 1.0 and 2.2) used to render non-PBR faces with alpha blend. 1.0 to disable.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>1.8</real>
</map>
<key>RenderLocalLightCount</key>
<map>
<key>Comment</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ uniform mat3 env_mat;
uniform vec3 sun_dir;
uniform vec3 moon_dir;
uniform int classic_mode;
uniform float alpha_gamma;

#ifdef USE_DIFFUSE_TEX
uniform sampler2D diffuseMap;
Expand Down Expand Up @@ -215,7 +216,7 @@ void main()
}

color.rgb = diffuse_srgb.rgb;
color.a = final_alpha;
color.a = pow(final_alpha, alpha_gamma);

#else // FOR_IMPOSTOR

Expand Down Expand Up @@ -263,7 +264,7 @@ void main()

vec4 color = vec4(0.0);

color.a = final_alpha;
color.a = pow(final_alpha, alpha_gamma);

color.rgb = irradiance;
if (classic_mode > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
uniform float emissive_brightness; // fullbright flag, 1.0 == fullbright, 0.0 otherwise
uniform int sun_up_factor;
uniform int classic_mode;
uniform float alpha_gamma;

vec4 applySkyAndWaterFog(vec3 pos, vec3 additive, vec3 atten, vec4 color);
vec3 scaleSoftClipFragLinear(vec3 l);
Expand Down Expand Up @@ -420,7 +421,7 @@ void main()

glare *= 1.0-emissive;
glare = min(glare, 1.0);
float al = max(diffcol.a, glare) * vertex_color.a;
float al = pow(max(diffcol.a, glare) * vertex_color.a, alpha_gamma);
float final_scale = 1;
if (classic_mode > 0)
final_scale = 1.1;
Expand Down
7 changes: 7 additions & 0 deletions indra/newview/lldrawpoolalpha.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,11 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged)
above_water = !above_water;
}

// Gamma correction factor for alpha faces without PBR material, in PBR
// rendering mode. HB
static LLCachedControl<F32> legacy_gamma(gSavedSettings,
"RenderLegacyAlphaGamma");
F32 alpha_gamma = llclamp((F32)legacy_gamma, 1.f, 2.2f);

for (LLCullResult::sg_iterator i = begin; i != end; ++i)
{
Expand Down Expand Up @@ -760,6 +765,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged)
current_shader->uniform4f(LLShaderMgr::SPECULAR_COLOR, spec_color.mV[VRED], spec_color.mV[VGREEN], spec_color.mV[VBLUE], spec_color.mV[VALPHA]);
current_shader->uniform1f(LLShaderMgr::ENVIRONMENT_INTENSITY, env_intensity);
current_shader->uniform1f(LLShaderMgr::EMISSIVE_BRIGHTNESS, brightness);
// Fix for alpha gamma on non-PBR (legacy) faces. HB
current_shader->uniform1f(LLShaderMgr::ALPHA_GAMMA, params.mHasPBR ? 1.f : alpha_gamma);
}
}

Expand Down
2 changes: 2 additions & 0 deletions indra/newview/llspatialpartition.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ class LLDrawInfo final : public LLRefCount
U8 mShiny = 0;
bool mFullbright = false;
bool mHasGlow = false;
// Set to 'true' when a PBR material is actually used to render this face. HB
bool mHasPBR = false;

struct CompareTexture
{
Expand Down
6 changes: 4 additions & 2 deletions indra/newview/llvovolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5372,10 +5372,9 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,

U8 index = facep->getTextureIndex();

bool has_pbr = false;
LLMaterial* mat = nullptr;

LLUUID mat_id;

auto* gltf_mat = (LLFetchedGLTFMaterial*)te->getGLTFRenderMaterial();
llassert(gltf_mat == nullptr || dynamic_cast<LLFetchedGLTFMaterial*>(te->getGLTFRenderMaterial()) != nullptr);
if (gltf_mat != nullptr)
Expand All @@ -5384,6 +5383,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
if (!facep->hasMedia() || (tex && tex->getType() != LLViewerTexture::MEDIA_TEXTURE))
{ // no media texture, face texture will be unused
tex = nullptr;
has_pbr = true;
}
}
else
Expand Down Expand Up @@ -5447,6 +5447,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
info->mCount + facep->getIndicesCount() <= (U32) gGLManager.mGLMaxIndexRange &&
#endif
info->mMaterialID == mat_id &&
info->mHasPBR == has_pbr &&
info->mFullbright == fullbright &&
info->mBump == bump &&
(!mat || (info->mShiny == shiny)) && // need to break batches when a material is shared, but legacy settings are different
Expand Down Expand Up @@ -5501,6 +5502,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
draw_info->mShaderMask = shader_mask;
draw_info->mAvatar = facep->mAvatar;
draw_info->mSkinInfo = facep->mSkinInfo;
draw_info->mHasPBR = has_pbr;

if (gltf_mat)
{
Expand Down
Loading