mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:23:53 +00:00
Ambient luminance threshold setting
This commit is contained in:
parent
690995988b
commit
cc31e1eea1
4 changed files with 48 additions and 1 deletions
|
@ -195,6 +195,7 @@ namespace MWRender
|
||||||
, mWorkQueue(workQueue)
|
, mWorkQueue(workQueue)
|
||||||
, mUnrefQueue(new SceneUtil::UnrefQueue)
|
, mUnrefQueue(new SceneUtil::UnrefQueue)
|
||||||
, mNavigator(navigator)
|
, mNavigator(navigator)
|
||||||
|
, mMinimumAmbientLuminance(0.f)
|
||||||
, mNightEyeFactor(0.f)
|
, mNightEyeFactor(0.f)
|
||||||
, mFieldOfViewOverridden(false)
|
, mFieldOfViewOverridden(false)
|
||||||
, mFieldOfViewOverride(0.f)
|
, mFieldOfViewOverride(0.f)
|
||||||
|
@ -223,6 +224,9 @@ namespace MWRender
|
||||||
resourceSystem->getSceneManager()->getShaderManager().setLightingMethod(sceneRoot->getLightingMethod());
|
resourceSystem->getSceneManager()->getShaderManager().setLightingMethod(sceneRoot->getLightingMethod());
|
||||||
resourceSystem->getSceneManager()->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);
|
sceneRoot->setLightingMask(Mask_Lighting);
|
||||||
mSceneRoot = sceneRoot;
|
mSceneRoot = sceneRoot;
|
||||||
sceneRoot->setStartLight(1);
|
sceneRoot->setStartLight(1);
|
||||||
|
@ -1072,7 +1076,25 @@ namespace MWRender
|
||||||
osg::Vec4f color = mAmbientColor;
|
osg::Vec4f color = mAmbientColor;
|
||||||
|
|
||||||
if (mNightEyeFactor > 0.f)
|
if (mNightEyeFactor > 0.f)
|
||||||
|
{
|
||||||
color += osg::Vec4f(0.7, 0.7, 0.7, 0.0) * mNightEyeFactor;
|
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);
|
mStateUpdater->setAmbientColor(color);
|
||||||
}
|
}
|
||||||
|
|
|
@ -296,6 +296,7 @@ namespace MWRender
|
||||||
osg::ref_ptr<StateUpdater> mStateUpdater;
|
osg::ref_ptr<StateUpdater> mStateUpdater;
|
||||||
|
|
||||||
osg::Vec4f mAmbientColor;
|
osg::Vec4f mAmbientColor;
|
||||||
|
float mMinimumAmbientLuminance;
|
||||||
float mNightEyeFactor;
|
float mNightEyeFactor;
|
||||||
|
|
||||||
float mNearClip;
|
float mNearClip;
|
||||||
|
|
|
@ -238,6 +238,25 @@ lighting` is on.
|
||||||
|
|
||||||
This setting has no effect if :ref:`lighting method` is 'legacy'.
|
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
|
antialias alpha test
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -469,6 +469,11 @@ light fade start = 0.85
|
||||||
# When 'lighting method' is set to 'legacy', this setting will have no effect.
|
# When 'lighting method' is set to 'legacy', this setting will have no effect.
|
||||||
max lights = 8
|
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.
|
# 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.
|
# 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.
|
# When MSAA is off, this setting will have no visible effect, but might have a performance cost.
|
||||||
|
|
Loading…
Reference in a new issue