diff options
-rw-r--r-- | indra/llrender/llrender.h | 9 | ||||
-rw-r--r-- | indra/newview/app_settings/settings.xml | 11 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl | 31 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/environment/srgbF.glsl | 5 | ||||
-rw-r--r-- | indra/newview/llviewershadermgr.cpp | 37 | ||||
-rw-r--r-- | indra/newview/llviewershadermgr.h | 2 | ||||
-rw-r--r-- | indra/newview/pipeline.cpp | 31 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_adjust_environment.xml | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_viewer.xml | 33 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml | 2 |
10 files changed, 114 insertions, 49 deletions
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 909a1de2b3..98141d71f5 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -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 diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index b489e2eb77..2f1a2ef120 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -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> diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 82d7bb9835..31cad591be 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -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)); diff --git a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl index 35f2395ef1..3817633df0 100644 --- a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl @@ -128,8 +128,3 @@ vec3 legacy_adjust_fullbright(vec3 c) return c / exp_scale * 1.34; } - -vec3 legacy_adjust_post(vec3 c) -{ - return c; -} diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 63cc7ba623..8925cc2f9b 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -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) { diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 129802aca5..492e60b840 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -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; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4bb93d675e..2cb11fc077 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -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(); } diff --git a/indra/newview/skins/default/xui/en/floater_adjust_environment.xml b/indra/newview/skins/default/xui/en/floater_adjust_environment.xml index ca5c7fe264..aef923feb2 100644 --- a/indra/newview/skins/default/xui/en/floater_adjust_environment.xml +++ b/indra/newview/skins/default/xui/en/floater_adjust_environment.xml @@ -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" diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 4a92bdc601..3e07daa91b 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -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 @@ -1902,16 +1923,6 @@ function="World.EnvPreset" 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"> <menu_item_check.on_check diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml index 622c999254..e90e6caf84 100644 --- a/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml @@ -223,7 +223,7 @@ left_delta="-5" top_delta="25" width="80"> - Scene Gamma: + Brightness: </text> <slider decimal_digits="2" |