Ambient luminance threshold setting

pull/593/head
glassmancody.info 4 years ago
parent 690995988b
commit cc31e1eea1

@ -195,6 +195,7 @@ namespace MWRender
, mWorkQueue(workQueue)
, mUnrefQueue(new SceneUtil::UnrefQueue)
, mNavigator(navigator)
, mMinimumAmbientLuminance(0.f)
, mNightEyeFactor(0.f)
, mFieldOfViewOverridden(false)
, mFieldOfViewOverride(0.f)
@ -223,6 +224,9 @@ namespace MWRender
resourceSystem->getSceneManager()->getShaderManager().setLightingMethod(sceneRoot->getLightingMethod());
resourceSystem->getSceneManager()->setLightingMethod(sceneRoot->getLightingMethod());
if (sceneRoot->getLightingMethod() != SceneUtil::LightingMethod::FFP)
mMinimumAmbientLuminance = std::clamp(Settings::Manager::getFloat("minimum interior brightness", "Shaders"), 0.f, 1.f);
sceneRoot->setLightingMask(Mask_Lighting);
mSceneRoot = sceneRoot;
sceneRoot->setStartLight(1);
@ -1072,7 +1076,25 @@ namespace MWRender
osg::Vec4f color = mAmbientColor;
if (mNightEyeFactor > 0.f)
{
color += osg::Vec4f(0.7, 0.7, 0.7, 0.0) * mNightEyeFactor;
}
// optionally brighten up ambient interiors when using a non-FFP emulated lighting method
else if (mResourceSystem->getSceneManager()->getLightingMethod() != SceneUtil::LightingMethod::FFP)
{
static constexpr float pR = 0.2126;
static constexpr float pG = 0.7152;
static constexpr float pB = 0.0722;
// we already work in linear RGB so no conversions are needed for the luminosity function
float relativeLuminance = pR*color.r() + pG*color.g() + pB*color.b();
if (relativeLuminance < mMinimumAmbientLuminance)
{
// brighten ambient so it reaches the minimum threshold but no more, we want to mess with content data as least we can
float targetBrightnessIncreaseFactor = mMinimumAmbientLuminance / relativeLuminance;
color *= targetBrightnessIncreaseFactor;
}
}
mStateUpdater->setAmbientColor(color);
}

@ -296,6 +296,7 @@ namespace MWRender
osg::ref_ptr<StateUpdater> mStateUpdater;
osg::Vec4f mAmbientColor;
float mMinimumAmbientLuminance;
float mNightEyeFactor;
float mNearClip;

@ -238,6 +238,25 @@ lighting` is on.
This setting has no effect if :ref:`lighting method` is 'legacy'.
minimum interior brightness
------------------------
:Type: float
:Range: 0.0-1.0
:Default: 0.1
Sets the minimum interior ambient brightness for interior cells when
:ref:`lighting method` is not 'legacy'. A consequence of the new lighting system
is that interiors will sometimes be darker since light sources now have sensible
fall-offs. A couple solutions are to either add more lights or increase their
radii to compensate, but these require content changes. For best results it is
recommended to set this to 0.0 to retain the colors that level designers
intended. If brighter interiors are wanted, however, this setting should be
increased. Note, it is advised to keep this number small (< 0.1) to avoid the
aforementioned changes in visuals.
This setting has no effect if :ref:`lighting method` is 'legacy'.
antialias alpha test
---------------------------------------

@ -465,10 +465,15 @@ maximum light distance = 8192
# Fraction of the maximum distance at which lights begin to gradually fade away.
light fade start = 0.85
# Set maximum number of lights per object.
# Set maximum number of lights per object.
# When 'lighting method' is set to 'legacy', this setting will have no effect.
max lights = 8
# Sets minimum ambient brightness of interior cells. Levels below this threshold will have their
# ambient values adjusted to balance the darker interiors.
# When 'lighting method' is set to 'legacy', this setting will have no effect.
minimum interior brightness = 0.1
# Convert the alpha test (cutout/punchthrough alpha) to alpha-to-coverage.
# This allows MSAA to work with alpha-tested meshes, producing better-looking edges without pixelation.
# When MSAA is off, this setting will have no visible effect, but might have a performance cost.

Loading…
Cancel
Save