DRTVWR-559 Add "No Post" mode and refactor "Scene Gamma" into "Brightness" for adjusting legacy gamma when probe ambiance is 0 and dynamic exposure when probe ambiance is not zero.
parent
879ca2f6a0
commit
88adfdcee4
|
|
@ -545,12 +545,7 @@ glh::matrix4f gl_ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top,
|
|||
glh::matrix4f gl_perspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar);
|
||||
glh::matrix4f gl_lookat(LLVector3 eye, LLVector3 center, LLVector3 up);
|
||||
|
||||
#if LL_RELEASE_FOR_DOWNLOAD
|
||||
#define LL_SHADER_LOADING_WARNS(...) LL_WARNS_ONCE("ShaderLoading")
|
||||
#define LL_SHADER_UNIFORM_ERRS(...) LL_WARNS_ONCE("Shader")
|
||||
#else
|
||||
#define LL_SHADER_LOADING_WARNS(...) LL_WARNS()
|
||||
#define LL_SHADER_UNIFORM_ERRS(...) LL_ERRS("Shader")
|
||||
#endif
|
||||
#define LL_SHADER_LOADING_WARNS(...) LL_WARNS()
|
||||
#define LL_SHADER_UNIFORM_ERRS(...) LL_ERRS("Shader")
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9197,6 +9197,17 @@
|
|||
<key>Value</key>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
<key>RenderDisablePostProcessing</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Disable tone mapping and exposure correction when build floater is open (for artists developing materials)</string>
|
||||
<key>Persist</key>
|
||||
<integer>0</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
<key>RenderMaxOpenGLVersion</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
|
|
|
|||
|
|
@ -104,20 +104,20 @@ vec3 toneMapACES_Hill(vec3 color)
|
|||
uniform float exposure;
|
||||
uniform float gamma;
|
||||
|
||||
vec3 legacy_adjust_post(vec3 c);
|
||||
|
||||
vec3 toneMap(vec3 color, float gs)
|
||||
vec3 toneMap(vec3 color)
|
||||
{
|
||||
#ifndef NO_POST
|
||||
float exp_scale = texture(exposureMap, vec2(0.5,0.5)).r;
|
||||
|
||||
color *= exposure * exp_scale * gs;
|
||||
color *= exposure * exp_scale;
|
||||
|
||||
color = toneMapACES_Hill(color);
|
||||
#else
|
||||
color *= 0.6;
|
||||
#endif
|
||||
|
||||
color = linear_to_srgb(color);
|
||||
|
||||
color = legacy_adjust_post(color);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
|
|
@ -170,22 +170,19 @@ vec3 legacyGamma(vec3 color)
|
|||
return color;
|
||||
}
|
||||
|
||||
float legacyGammaApprox()
|
||||
{
|
||||
//TODO -- figure out how to plumb this in as a uniform
|
||||
float c = 0.5;
|
||||
float gc = 1.0-pow(c, gamma);
|
||||
|
||||
return gc/c * gamma;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
//this is the one of the rare spots where diffuseRect contains linear color values (not sRGB)
|
||||
vec4 diff = texture2D(diffuseRect, vary_fragcoord);
|
||||
|
||||
diff.rgb = toneMap(diff.rgb, legacyGammaApprox());
|
||||
|
||||
diff.rgb = toneMap(diff.rgb);
|
||||
|
||||
#if LEGACY_GAMMA
|
||||
#ifndef NO_POST
|
||||
diff.rgb = legacyGamma(diff.rgb);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
vec2 tc = vary_fragcoord.xy*screen_res*4.0;
|
||||
vec3 seed = (diff.rgb+vec3(1.0))*vec3(tc.xy, tc.x+tc.y);
|
||||
vec3 nz = vec3(noise(seed.rg), noise(seed.gb), noise(seed.rb));
|
||||
|
|
|
|||
|
|
@ -128,8 +128,3 @@ vec3 legacy_adjust_fullbright(vec3 c)
|
|||
return c / exp_scale * 1.34;
|
||||
}
|
||||
|
||||
|
||||
vec3 legacy_adjust_post(vec3 c)
|
||||
{
|
||||
return c;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,6 +188,8 @@ LLGLSLShader gDeferredPostProgram;
|
|||
LLGLSLShader gDeferredCoFProgram;
|
||||
LLGLSLShader gDeferredDoFCombineProgram;
|
||||
LLGLSLShader gDeferredPostGammaCorrectProgram;
|
||||
LLGLSLShader gNoPostGammaCorrectProgram;
|
||||
LLGLSLShader gLegacyPostGammaCorrectProgram;
|
||||
LLGLSLShader gExposureProgram;
|
||||
LLGLSLShader gLuminanceProgram;
|
||||
LLGLSLShader gFXAAProgram;
|
||||
|
|
@ -295,6 +297,8 @@ LLViewerShaderMgr::LLViewerShaderMgr() :
|
|||
mShaderList.push_back(&gHUDPBRAlphaProgram);
|
||||
mShaderList.push_back(&gDeferredSkinnedPBRAlphaProgram);
|
||||
mShaderList.push_back(&gDeferredPostGammaCorrectProgram); // for gamma
|
||||
mShaderList.push_back(&gNoPostGammaCorrectProgram);
|
||||
mShaderList.push_back(&gLegacyPostGammaCorrectProgram);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1010,6 +1014,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
|
|||
gExposureProgram.unload();
|
||||
gLuminanceProgram.unload();
|
||||
gDeferredPostGammaCorrectProgram.unload();
|
||||
gNoPostGammaCorrectProgram.unload();
|
||||
gLegacyPostGammaCorrectProgram.unload();
|
||||
gFXAAProgram.unload();
|
||||
gDeferredWLSkyProgram.unload();
|
||||
gDeferredWLCloudProgram.unload();
|
||||
|
|
@ -2537,6 +2543,37 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
|
|||
success = gDeferredPostGammaCorrectProgram.createShader(NULL, NULL);
|
||||
llassert(success);
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
gNoPostGammaCorrectProgram.mName = "No Post Gamma Correction Post Process";
|
||||
gNoPostGammaCorrectProgram.mFeatures.hasSrgb = true;
|
||||
gNoPostGammaCorrectProgram.mFeatures.isDeferred = true;
|
||||
gNoPostGammaCorrectProgram.mShaderFiles.clear();
|
||||
gNoPostGammaCorrectProgram.clearPermutations();
|
||||
gNoPostGammaCorrectProgram.addPermutation("NO_POST", "1");
|
||||
gNoPostGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER));
|
||||
gNoPostGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredGammaCorrect.glsl", GL_FRAGMENT_SHADER));
|
||||
gNoPostGammaCorrectProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
|
||||
success = gNoPostGammaCorrectProgram.createShader(NULL, NULL);
|
||||
llassert(success);
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
gLegacyPostGammaCorrectProgram.mName = "Legacy Gamma Correction Post Process";
|
||||
gLegacyPostGammaCorrectProgram.mFeatures.hasSrgb = true;
|
||||
gLegacyPostGammaCorrectProgram.mFeatures.isDeferred = true;
|
||||
gLegacyPostGammaCorrectProgram.mShaderFiles.clear();
|
||||
gLegacyPostGammaCorrectProgram.clearPermutations();
|
||||
gLegacyPostGammaCorrectProgram.addPermutation("LEGACY_GAMMA", "1");
|
||||
gLegacyPostGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER));
|
||||
gLegacyPostGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredGammaCorrect.glsl", GL_FRAGMENT_SHADER));
|
||||
gLegacyPostGammaCorrectProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
|
||||
success = gLegacyPostGammaCorrectProgram.createShader(NULL, NULL);
|
||||
llassert(success);
|
||||
}
|
||||
|
||||
|
||||
if (success && gGLManager.mGLVersion > 3.9f)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -235,6 +235,8 @@ extern LLGLSLShader gDeferredDoFCombineProgram;
|
|||
extern LLGLSLShader gFXAAProgram;
|
||||
extern LLGLSLShader gDeferredPostNoDoFProgram;
|
||||
extern LLGLSLShader gDeferredPostGammaCorrectProgram;
|
||||
extern LLGLSLShader gNoPostGammaCorrectProgram;
|
||||
extern LLGLSLShader gLegacyPostGammaCorrectProgram;
|
||||
extern LLGLSLShader gExposureProgram;
|
||||
extern LLGLSLShader gLuminanceProgram;
|
||||
extern LLGLSLShader gDeferredAvatarShadowProgram;
|
||||
|
|
|
|||
|
|
@ -7007,9 +7007,19 @@ void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst) {
|
|||
static LLCachedControl<F32> dynamic_exposure_min(gSavedSettings, "RenderDynamicExposureMin", 0.125f);
|
||||
static LLCachedControl<F32> dynamic_exposure_max(gSavedSettings, "RenderDynamicExposureMax", 1.3f);
|
||||
|
||||
F32 exposure_max = dynamic_exposure_max;
|
||||
LLSettingsSky::ptr_t sky = LLEnvironment::instance().getCurrentSky();
|
||||
|
||||
if (sky->getReflectionProbeAmbiance() > 0.f)
|
||||
{ //not a legacy sky, use gamma as a boost to max exposure
|
||||
exposure_max = llmax(exposure_max - 1.f, 0.f);
|
||||
exposure_max *= sky->getGamma();
|
||||
exposure_max += 1.f;
|
||||
}
|
||||
|
||||
gExposureProgram.uniform1f(dt, gFrameIntervalSeconds);
|
||||
gExposureProgram.uniform2f(noiseVec, ll_frand() * 2.0 - 1.0, ll_frand() * 2.0 - 1.0);
|
||||
gExposureProgram.uniform3f(dynamic_exposure_params, dynamic_exposure_coefficient, dynamic_exposure_min, dynamic_exposure_max);
|
||||
gExposureProgram.uniform3f(dynamic_exposure_params, dynamic_exposure_coefficient, dynamic_exposure_min, exposure_max);
|
||||
|
||||
mScreenTriangleVB->setBuffer();
|
||||
mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
|
||||
|
|
@ -7026,18 +7036,25 @@ void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst) {
|
|||
{
|
||||
LL_PROFILE_GPU_ZONE("gamma correct");
|
||||
|
||||
static LLCachedControl<bool> no_post(gSavedSettings, "RenderDisablePostProcessing", false);
|
||||
|
||||
LLGLDepthTest depth(GL_FALSE, GL_FALSE);
|
||||
|
||||
// Apply gamma correction to the frame here.
|
||||
gDeferredPostGammaCorrectProgram.bind();
|
||||
|
||||
LLGLSLShader& shader = no_post && gFloaterTools->isAvailable() ? gNoPostGammaCorrectProgram : // no post (no gamma, no exposure, no tonemapping)
|
||||
LLEnvironment::instance().getCurrentSky()->getReflectionProbeAmbiance() == 0.f ? gLegacyPostGammaCorrectProgram :
|
||||
gDeferredPostGammaCorrectProgram;
|
||||
|
||||
shader.bind();
|
||||
|
||||
S32 channel = 0;
|
||||
|
||||
gDeferredPostGammaCorrectProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, false, LLTexUnit::TFO_POINT);
|
||||
shader.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, false, LLTexUnit::TFO_POINT);
|
||||
|
||||
gDeferredPostGammaCorrectProgram.bindTexture(LLShaderMgr::EXPOSURE_MAP, &mExposureMap);
|
||||
shader.bindTexture(LLShaderMgr::EXPOSURE_MAP, &mExposureMap);
|
||||
|
||||
gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, src->getWidth(), src->getHeight());
|
||||
shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, src->getWidth(), src->getHeight());
|
||||
|
||||
static LLCachedControl<F32> exposure(gSavedSettings, "RenderExposure", 1.f);
|
||||
|
||||
|
|
@ -7045,13 +7062,13 @@ void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst) {
|
|||
|
||||
static LLStaticHashedString s_exposure("exposure");
|
||||
|
||||
gDeferredPostGammaCorrectProgram.uniform1f(s_exposure, e);
|
||||
shader.uniform1f(s_exposure, e);
|
||||
|
||||
mScreenTriangleVB->setBuffer();
|
||||
mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
|
||||
|
||||
gGL.getTexUnit(channel)->unbind(src->getUsage());
|
||||
gDeferredPostGammaCorrectProgram.unbind();
|
||||
shader.unbind();
|
||||
}
|
||||
dst->flush();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@
|
|||
layout="topleft"
|
||||
left_delta="-5"
|
||||
top_pad="15"
|
||||
width="80">Scene Gamma:</text>
|
||||
width="80">Brightness:</text>
|
||||
<slider decimal_digits="2"
|
||||
follows="left|top"
|
||||
height="16"
|
||||
|
|
|
|||
|
|
@ -1492,7 +1492,28 @@ function="World.EnvPreset"
|
|||
function="ToggleControl"
|
||||
parameter="ShowSelectionBeam" />
|
||||
</menu_item_check>
|
||||
|
||||
<menu_item_check
|
||||
label="Highlight Transparent"
|
||||
name="Highlight Transparent"
|
||||
shortcut="control|alt|T"
|
||||
use_mac_ctrl="true">
|
||||
<menu_item_check.on_check
|
||||
function="View.CheckHighlightTransparent" />
|
||||
<menu_item_check.on_click
|
||||
function="View.HighlightTransparent" />
|
||||
</menu_item_check>
|
||||
<menu_item_separator/>
|
||||
|
||||
<menu_item_check
|
||||
label="No Post"
|
||||
name="No Post">
|
||||
<menu_item_check.on_check
|
||||
control="RenderDisablePostProcessing" />
|
||||
<menu_item_check.on_click
|
||||
function="ToggleControl"
|
||||
parameter="RenderDisablePostProcessing" />
|
||||
</menu_item_check>
|
||||
|
||||
<menu_item_separator/>
|
||||
|
||||
<menu_item_check
|
||||
|
|
@ -1901,16 +1922,6 @@ function="World.EnvPreset"
|
|||
function="ToggleControl"
|
||||
parameter="HideSelectedObjects" />
|
||||
</menu_item_check>
|
||||
<menu_item_check
|
||||
label="Highlight Transparent"
|
||||
name="Highlight Transparent"
|
||||
shortcut="control|alt|T"
|
||||
use_mac_ctrl="true">
|
||||
<menu_item_check.on_check
|
||||
function="View.CheckHighlightTransparent" />
|
||||
<menu_item_check.on_click
|
||||
function="View.HighlightTransparent" />
|
||||
</menu_item_check>
|
||||
<menu_item_check
|
||||
label="Show Mouselook Crosshairs"
|
||||
name="ShowCrosshairs">
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@
|
|||
left_delta="-5"
|
||||
top_delta="25"
|
||||
width="80">
|
||||
Scene Gamma:
|
||||
Brightness:
|
||||
</text>
|
||||
<slider
|
||||
decimal_digits="2"
|
||||
|
|
|
|||
Loading…
Reference in New Issue