mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 19:41:20 +02:00
cleanup, fix shadow qml
This commit is contained in:
parent
0d9f639331
commit
72f52b069e
10 changed files with 101 additions and 154 deletions
|
@ -317,7 +317,7 @@ void ZoneEntityRenderer::updateKeySunFromEntity(const TypedEntityPointer& entity
|
||||||
sunLight->setIntensity(_keyLightProperties.getIntensity());
|
sunLight->setIntensity(_keyLightProperties.getIntensity());
|
||||||
sunLight->setDirection(_lastRotation * _keyLightProperties.getDirection());
|
sunLight->setDirection(_lastRotation * _keyLightProperties.getDirection());
|
||||||
sunLight->setCastShadows(_keyLightProperties.getCastShadows());
|
sunLight->setCastShadows(_keyLightProperties.getCastShadows());
|
||||||
sunLight->setShadowsBiasScale(_keyLightProperties.getShadowBias());
|
sunLight->setShadowBias(_keyLightProperties.getShadowBias());
|
||||||
sunLight->setShadowsMaxDistance(_keyLightProperties.getShadowMaxDistance());
|
sunLight->setShadowsMaxDistance(_keyLightProperties.getShadowMaxDistance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2754,7 +2754,7 @@ bool EntityItemProperties::getPropertyInfo(const QString& propertyName, EntityPr
|
||||||
ADD_GROUP_PROPERTY_TO_MAP(PROP_KEYLIGHT_DIRECTION, KeyLight, keylight, Direction, direction);
|
ADD_GROUP_PROPERTY_TO_MAP(PROP_KEYLIGHT_DIRECTION, KeyLight, keylight, Direction, direction);
|
||||||
ADD_GROUP_PROPERTY_TO_MAP(PROP_KEYLIGHT_CAST_SHADOW, KeyLight, keyLight, CastShadows, castShadows);
|
ADD_GROUP_PROPERTY_TO_MAP(PROP_KEYLIGHT_CAST_SHADOW, KeyLight, keyLight, CastShadows, castShadows);
|
||||||
ADD_GROUP_PROPERTY_TO_MAP_WITH_RANGE(PROP_KEYLIGHT_SHADOW_BIAS, KeyLight, keyLight, ShadowBias, shadowBias, 0.0f, 1.0f);
|
ADD_GROUP_PROPERTY_TO_MAP_WITH_RANGE(PROP_KEYLIGHT_SHADOW_BIAS, KeyLight, keyLight, ShadowBias, shadowBias, 0.0f, 1.0f);
|
||||||
ADD_GROUP_PROPERTY_TO_MAP_WITH_RANGE(PROP_KEYLIGHT_SHADOW_MAX_DISTANCE, KeyLight, keyLight, ShadowMaxDistance, shadowMaxDistance, 0.0f, 500.0f);
|
ADD_GROUP_PROPERTY_TO_MAP_WITH_RANGE(PROP_KEYLIGHT_SHADOW_MAX_DISTANCE, KeyLight, keyLight, ShadowMaxDistance, shadowMaxDistance, 1.0f, 250.0f);
|
||||||
}
|
}
|
||||||
{ // Ambient light
|
{ // Ambient light
|
||||||
ADD_GROUP_PROPERTY_TO_MAP(PROP_AMBIENT_LIGHT_INTENSITY, AmbientLight, ambientLight, Intensity, intensity);
|
ADD_GROUP_PROPERTY_TO_MAP(PROP_AMBIENT_LIGHT_INTENSITY, AmbientLight, ambientLight, Intensity, intensity);
|
||||||
|
|
|
@ -40,7 +40,7 @@ class ReadBitstreamToTreeParams;
|
||||||
* @property {number} shadowBias=0.5 - The bias of the shadows cast by the light. Use this to fine-tune your shadows to your scene
|
* @property {number} shadowBias=0.5 - The bias of the shadows cast by the light. Use this to fine-tune your shadows to your scene
|
||||||
* to prevent shadow acne and peter panning. In the range <code>0.0</code> – <code>1.0</code>.
|
* to prevent shadow acne and peter panning. In the range <code>0.0</code> – <code>1.0</code>.
|
||||||
* @property {number} shadowMaxDistance=40.0 - The max distance from your view at which shadows will be computed. Higher values will
|
* @property {number} shadowMaxDistance=40.0 - The max distance from your view at which shadows will be computed. Higher values will
|
||||||
* cover more of your scene, but with less precision. In the range <code>0.0</code> – <code>500.0</code>.
|
* cover more of your scene, but with less precision. In the range <code>1.0</code> – <code>250.0</code>.
|
||||||
*/
|
*/
|
||||||
class KeyLightPropertyGroup : public PropertyGroup {
|
class KeyLightPropertyGroup : public PropertyGroup {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -81,20 +81,12 @@ float Light::getShadowsMaxDistance() const {
|
||||||
return _shadowsMaxDistance;
|
return _shadowsMaxDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Light::setShadowsBiasScale(const float scale) {
|
void Light::setShadowBias(float bias) {
|
||||||
_shadowsBiasScale = std::max(0.0f, scale);
|
_shadowBias = bias;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Light::getShadowsBiasScale() const {
|
float Light::getShadowBias() const {
|
||||||
return _shadowsBiasScale;
|
return _shadowBias;
|
||||||
}
|
|
||||||
|
|
||||||
void Light::setBiasInput(float bias) {
|
|
||||||
_biasInput = bias;
|
|
||||||
}
|
|
||||||
|
|
||||||
float Light::getBiasInput() const {
|
|
||||||
return _biasInput;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Light::setColor(const Color& color) {
|
void Light::setColor(const Color& color) {
|
||||||
|
|
|
@ -109,11 +109,8 @@ public:
|
||||||
void setShadowsMaxDistance(const float maxDistance);
|
void setShadowsMaxDistance(const float maxDistance);
|
||||||
float getShadowsMaxDistance() const;
|
float getShadowsMaxDistance() const;
|
||||||
|
|
||||||
void setShadowsBiasScale(const float scale);
|
void setShadowBias(float bias);
|
||||||
float getShadowsBiasScale() const;
|
float getShadowBias() const;
|
||||||
|
|
||||||
void setBiasInput(float bias);
|
|
||||||
float getBiasInput() const;
|
|
||||||
|
|
||||||
void setOrientation(const Quat& orientation);
|
void setOrientation(const Quat& orientation);
|
||||||
const glm::quat& getOrientation() const { return _transform.getRotation(); }
|
const glm::quat& getOrientation() const { return _transform.getRotation(); }
|
||||||
|
@ -201,9 +198,8 @@ protected:
|
||||||
Type _type { SUN };
|
Type _type { SUN };
|
||||||
float _spotCos { -1.0f }; // stored here to be able to reset the spot angle when turning the type spot on/off
|
float _spotCos { -1.0f }; // stored here to be able to reset the spot angle when turning the type spot on/off
|
||||||
|
|
||||||
float _shadowsMaxDistance{ 40.0f };
|
float _shadowsMaxDistance { 40.0f };
|
||||||
float _shadowsBiasScale{ 1.0f };
|
float _shadowBias { 0.5f }; // 0.23f will roughly give the default constant and slope values
|
||||||
float _biasInput{ 0.5f }; // 0.23f will roughly give the default constant and slope values
|
|
||||||
bool _castShadows{ false };
|
bool _castShadows{ false };
|
||||||
|
|
||||||
void updateLightRadius();
|
void updateLightRadius();
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
// but are readjusted afterwards
|
// but are readjusted afterwards
|
||||||
#define SHADOW_FRUSTUM_NEAR 1.0f
|
#define SHADOW_FRUSTUM_NEAR 1.0f
|
||||||
#define SHADOW_FRUSTUM_FAR 500.0f
|
#define SHADOW_FRUSTUM_FAR 500.0f
|
||||||
static const unsigned int SHADOW_CASCADE_COUNT{ 4 };
|
|
||||||
|
|
||||||
using namespace render;
|
using namespace render;
|
||||||
|
|
||||||
|
@ -316,76 +315,42 @@ RenderShadowSetup::RenderShadowSetup() :
|
||||||
_shadowFrameCache = std::make_shared<LightStage::ShadowFrame>();
|
_shadowFrameCache = std::make_shared<LightStage::ShadowFrame>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderShadowSetup::configure(const Config& configuration) {
|
void RenderShadowSetup::configure(const Config& config) {
|
||||||
distanceTriggeredByConfig = _globalMaxDistance != configuration.globalMaxDistance;
|
constantBias0 = config.constantBias0;
|
||||||
biasTriggeredByConfig = _biasInput != configuration.biasInput;
|
constantBias1 = config.constantBias1;
|
||||||
|
constantBias2 = config.constantBias2;
|
||||||
// go back to using the config's default bias values if a change to any of those is triggered
|
constantBias3 = config.constantBias3;
|
||||||
if (constant0 != configuration.constantBias0 || slope0 != configuration.slopeBias0 ||
|
slopeBias0 = config.slopeBias0;
|
||||||
constant1 != configuration.constantBias1 || slope1 != configuration.slopeBias1 ||
|
slopeBias1 = config.slopeBias1;
|
||||||
constant2 != configuration.constantBias2 || slope2 != configuration.slopeBias2 ||
|
slopeBias2 = config.slopeBias2;
|
||||||
constant3 != configuration.constantBias3 || slope3 != configuration.slopeBias3) {
|
slopeBias3 = config.slopeBias3;
|
||||||
constant0 = configuration.constantBias0;
|
biasInput = config.biasInput;
|
||||||
slope0 = configuration.slopeBias0;
|
maxDistance = config.maxDistance;
|
||||||
constant1 = configuration.constantBias1;
|
|
||||||
slope1 = configuration.slopeBias1;
|
|
||||||
constant2 = configuration.constantBias2;
|
|
||||||
slope2 = configuration.slopeBias2;
|
|
||||||
constant3 = configuration.constantBias3;
|
|
||||||
slope3 = configuration.slopeBias3;
|
|
||||||
changeInDefaultConfigValues = true;
|
|
||||||
distanceTriggeredByConfig = false;
|
|
||||||
biasTriggeredByConfig = false;
|
|
||||||
|
|
||||||
setConstantBias(0, constant0);
|
|
||||||
setSlopeBias(0, slope0);
|
|
||||||
|
|
||||||
#if SHADOW_CASCADE_MAX_COUNT > 1
|
|
||||||
setConstantBias(1, constant1);
|
|
||||||
setConstantBias(2, constant2);
|
|
||||||
setConstantBias(3, constant3);
|
|
||||||
|
|
||||||
setSlopeBias(1, slope1);
|
|
||||||
setSlopeBias(2, slope2);
|
|
||||||
setSlopeBias(3, slope3);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// modify bias using single input and work in calculateBias()
|
|
||||||
if (distanceTriggeredByConfig) {
|
|
||||||
changeInDefaultConfigValues = false;
|
|
||||||
_globalMaxDistance = configuration.globalMaxDistance;
|
|
||||||
calculateBiases();
|
|
||||||
}
|
|
||||||
if (biasTriggeredByConfig) {
|
|
||||||
changeInDefaultConfigValues = false;
|
|
||||||
_biasInput = configuration.biasInput;
|
|
||||||
calculateBiases();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderShadowSetup::calculateBiases() {
|
void RenderShadowSetup::calculateBiases(float biasInput) {
|
||||||
// slope scaling values derived from ratio between original constantBias and slopeBias pairs
|
// slope scaling values derived from ratio between original constantBias and slopeBias pairs
|
||||||
const std::array<float, 4> SLOPE_SCALES = {{ 2.7f, 3.0f, 3.7f, 3.5f }};
|
const std::array<float, SHADOW_CASCADE_MAX_COUNT> SLOPE_SCALES = {{ 2.7f, 3.0f, 3.7f, 3.5f }};
|
||||||
const float CONVERT_BIAS = 100.0f;
|
const float CONVERT_BIAS = 100.0f;
|
||||||
const float MIN_SCALE_DIVISOR = 0.5f;
|
const float MIN_SCALE_DIVISOR = 0.5f;
|
||||||
|
|
||||||
// the bias is relative to resolution
|
// the bias is relative to resolution
|
||||||
// to remain consistent with the constant and slope bias values, the biasInput
|
// to remain consistent with the constant and slope bias values, the biasInput
|
||||||
// value is in the 0.0 - 1.0 range but needs to be scaled up for further calculations
|
// value is in the 0.0 - 1.0 range but needs to be scaled up for further calculations
|
||||||
|
// TODO: expose variable resolution
|
||||||
|
int resolution = LightStage::Shadow::MAP_SIZE;
|
||||||
|
const int DEFAULT_RESOLUTION = LightStage::Shadow::MAP_SIZE;
|
||||||
float inverseResolution = 1.0f / (float)resolution;
|
float inverseResolution = 1.0f / (float)resolution;
|
||||||
int resolutionScale = DEFAULT_RESOLUTION * inverseResolution;
|
int resolutionScale = DEFAULT_RESOLUTION * inverseResolution;
|
||||||
float convertedBias = _biasInput * (CONVERT_BIAS / resolutionScale);
|
float convertedBias = biasInput * (CONVERT_BIAS / resolutionScale);
|
||||||
std::array<float, 4> localConstants;
|
|
||||||
std::array<float, 4> localSlopes;
|
|
||||||
float scaleFactor = 1.0f;
|
float scaleFactor = 1.0f;
|
||||||
|
|
||||||
for (int i = 0; i < SHADOW_CASCADE_MAX_COUNT; i++) {
|
for (int i = 0; i < SHADOW_CASCADE_MAX_COUNT; i++) {
|
||||||
scaleFactor = convertedBias * (cacasdeDistances[0] / glm::max(MIN_SCALE_DIVISOR, cacasdeDistances[i + 4])) * inverseResolution;
|
scaleFactor = convertedBias * (cacasdeDistances[0] / glm::max(MIN_SCALE_DIVISOR, cacasdeDistances[i + SHADOW_CASCADE_MAX_COUNT])) * inverseResolution;
|
||||||
localConstants[i] = cacasdeDistances[i] * scaleFactor;
|
float constantBias = cacasdeDistances[i] * scaleFactor;
|
||||||
localSlopes[i] = cacasdeDistances[i] * scaleFactor * SLOPE_SCALES[i];
|
float slopeBias = cacasdeDistances[i] * scaleFactor * SLOPE_SCALES[i];
|
||||||
setConstantBias(i, localConstants[i]);
|
setConstantBias(i, constantBias);
|
||||||
setSlopeBias(i, localSlopes[i]);
|
setSlopeBias(i, slopeBias);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,43 +390,47 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, c
|
||||||
output.edit2() = _cameraFrustum;
|
output.edit2() = _cameraFrustum;
|
||||||
|
|
||||||
if (!_globalShadowObject) {
|
if (!_globalShadowObject) {
|
||||||
_globalShadowObject = std::make_shared<LightStage::Shadow>(currentKeyLight, SHADOW_CASCADE_COUNT);
|
_globalShadowObject = std::make_shared<LightStage::Shadow>(currentKeyLight, SHADOW_CASCADE_MAX_COUNT);
|
||||||
}
|
}
|
||||||
resolution = _globalShadowObject->MAP_SIZE;
|
|
||||||
_globalShadowObject->setLight(currentKeyLight);
|
_globalShadowObject->setLight(currentKeyLight);
|
||||||
_globalShadowObject->setKeylightFrustum(args->getViewFrustum(), SHADOW_FRUSTUM_NEAR, SHADOW_FRUSTUM_FAR);
|
_globalShadowObject->setKeylightFrustum(args->getViewFrustum(), SHADOW_FRUSTUM_NEAR, SHADOW_FRUSTUM_FAR);
|
||||||
// if the max distance isn't altered externally, grab the value from the light
|
|
||||||
if (!distanceTriggeredByConfig && !biasTriggeredByConfig) {
|
|
||||||
_globalMaxDistance = currentKeyLight->getShadowsMaxDistance();
|
|
||||||
}
|
|
||||||
_globalShadowObject->setMaxDistance(_globalMaxDistance);
|
|
||||||
|
|
||||||
auto& firstCascade = _globalShadowObject->getCascade(0);
|
|
||||||
auto& firstCascadeFrustum = firstCascade.getFrustum();
|
|
||||||
unsigned int cascadeIndex;
|
|
||||||
|
|
||||||
for (cascadeIndex = 0; cascadeIndex < _globalShadowObject->getCascadeCount(); ++cascadeIndex) {
|
// Update our biases and maxDistance from the light or config
|
||||||
|
_globalShadowObject->setMaxDistance(maxDistance > 0.0f ? maxDistance : currentKeyLight->getShadowsMaxDistance());
|
||||||
|
|
||||||
|
for (unsigned int cascadeIndex = 0; cascadeIndex < _globalShadowObject->getCascadeCount(); ++cascadeIndex) {
|
||||||
cacasdeDistances[cascadeIndex] = _globalShadowObject->getCascade(cascadeIndex).getMaxDistance();
|
cacasdeDistances[cascadeIndex] = _globalShadowObject->getCascade(cascadeIndex).getMaxDistance();
|
||||||
cacasdeDistances[cascadeIndex + 4] = _globalShadowObject->getCascade(cascadeIndex).getMinDistance();
|
cacasdeDistances[cascadeIndex + SHADOW_CASCADE_MAX_COUNT] = _globalShadowObject->getCascade(cascadeIndex).getMinDistance();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!biasTriggeredByConfig && !distanceTriggeredByConfig && !changeInDefaultConfigValues) {
|
calculateBiases(biasInput > 0.0f ? biasInput : currentKeyLight->getShadowBias());
|
||||||
setBiasInput(currentKeyLight->getBiasInput());
|
|
||||||
calculateBiases();
|
std::array<float, SHADOW_CASCADE_MAX_COUNT> constantBiases = { constantBias0, constantBias1, constantBias2, constantBias3 };
|
||||||
|
std::array<float, SHADOW_CASCADE_MAX_COUNT> slopeBiases = { slopeBias0, slopeBias1, slopeBias2, slopeBias3 };
|
||||||
|
for (unsigned int cascadeIndex = 0; cascadeIndex < _globalShadowObject->getCascadeCount(); ++cascadeIndex) {
|
||||||
|
float constantBias = constantBiases[cascadeIndex];
|
||||||
|
if (constantBias > 0.0f) {
|
||||||
|
setConstantBias(cascadeIndex, constantBias);
|
||||||
|
}
|
||||||
|
float slopeBias = slopeBiases[cascadeIndex];
|
||||||
|
if (slopeBias > 0.0f) {
|
||||||
|
setSlopeBias(cascadeIndex, slopeBias);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust each cascade frustum
|
// Adjust each cascade frustum
|
||||||
const auto biasScale = currentKeyLight->getShadowsBiasScale();
|
for (unsigned int cascadeIndex = 0; cascadeIndex < _globalShadowObject->getCascadeCount(); ++cascadeIndex) {
|
||||||
for (cascadeIndex = 0; cascadeIndex < _globalShadowObject->getCascadeCount(); ++cascadeIndex) {
|
|
||||||
auto& bias = _bias[cascadeIndex];
|
auto& bias = _bias[cascadeIndex];
|
||||||
_globalShadowObject->setKeylightCascadeFrustum(cascadeIndex, args->getViewFrustum(),
|
_globalShadowObject->setKeylightCascadeFrustum(cascadeIndex, args->getViewFrustum(),
|
||||||
SHADOW_FRUSTUM_NEAR, SHADOW_FRUSTUM_FAR,
|
SHADOW_FRUSTUM_NEAR, SHADOW_FRUSTUM_FAR,
|
||||||
bias._constant, bias._slope * biasScale);
|
bias._constant, bias._slope);
|
||||||
}
|
}
|
||||||
|
|
||||||
_shadowFrameCache->pushShadow(_globalShadowObject);
|
_shadowFrameCache->pushShadow(_globalShadowObject);
|
||||||
|
|
||||||
// Now adjust coarse frustum bounds
|
// Now adjust coarse frustum bounds
|
||||||
|
auto& firstCascade = _globalShadowObject->getCascade(0);
|
||||||
|
auto& firstCascadeFrustum = firstCascade.getFrustum();
|
||||||
auto frustumPosition = firstCascadeFrustum->getPosition();
|
auto frustumPosition = firstCascadeFrustum->getPosition();
|
||||||
auto farTopLeft = firstCascadeFrustum->getFarTopLeft() - frustumPosition;
|
auto farTopLeft = firstCascadeFrustum->getFarTopLeft() - frustumPosition;
|
||||||
auto farBottomRight = firstCascadeFrustum->getFarBottomRight() - frustumPosition;
|
auto farBottomRight = firstCascadeFrustum->getFarBottomRight() - frustumPosition;
|
||||||
|
@ -473,7 +442,7 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, c
|
||||||
auto near = firstCascadeFrustum->getNearClip();
|
auto near = firstCascadeFrustum->getNearClip();
|
||||||
auto far = firstCascadeFrustum->getFarClip();
|
auto far = firstCascadeFrustum->getFarClip();
|
||||||
|
|
||||||
for (cascadeIndex = 1; cascadeIndex < _globalShadowObject->getCascadeCount(); ++cascadeIndex) {
|
for (unsigned int cascadeIndex = 1; cascadeIndex < _globalShadowObject->getCascadeCount(); ++cascadeIndex) {
|
||||||
auto& cascadeFrustum = _globalShadowObject->getCascade(cascadeIndex).getFrustum();
|
auto& cascadeFrustum = _globalShadowObject->getCascade(cascadeIndex).getFrustum();
|
||||||
|
|
||||||
farTopLeft = cascadeFrustum->getFarTopLeft() - frustumPosition;
|
farTopLeft = cascadeFrustum->getFarTopLeft() - frustumPosition;
|
||||||
|
|
|
@ -75,34 +75,31 @@ public:
|
||||||
CullFunctor _cullFunctor;
|
CullFunctor _cullFunctor;
|
||||||
};
|
};
|
||||||
|
|
||||||
const float DEFAULT_BIAS_INPUT = 0.5f;
|
|
||||||
const float DEFAULT_MAX_DISTANCE = 40.0f;
|
|
||||||
|
|
||||||
class RenderShadowSetupConfig : public render::Job::Config {
|
class RenderShadowSetupConfig : public render::Job::Config {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(float constantBias0 MEMBER constantBias0 NOTIFY dirty)
|
Q_PROPERTY(float constantBias0 MEMBER constantBias0 NOTIFY dirty)
|
||||||
Q_PROPERTY(float constantBias1 MEMBER constantBias1 NOTIFY dirty)
|
Q_PROPERTY(float constantBias1 MEMBER constantBias1 NOTIFY dirty)
|
||||||
Q_PROPERTY(float constantBias2 MEMBER constantBias2 NOTIFY dirty)
|
Q_PROPERTY(float constantBias2 MEMBER constantBias2 NOTIFY dirty)
|
||||||
Q_PROPERTY(float constantBias3 MEMBER constantBias3 NOTIFY dirty)
|
Q_PROPERTY(float constantBias3 MEMBER constantBias3 NOTIFY dirty)
|
||||||
Q_PROPERTY(float slopeBias0 MEMBER slopeBias0 NOTIFY dirty)
|
Q_PROPERTY(float slopeBias0 MEMBER slopeBias0 NOTIFY dirty)
|
||||||
Q_PROPERTY(float slopeBias1 MEMBER slopeBias1 NOTIFY dirty)
|
Q_PROPERTY(float slopeBias1 MEMBER slopeBias1 NOTIFY dirty)
|
||||||
Q_PROPERTY(float slopeBias2 MEMBER slopeBias2 NOTIFY dirty)
|
Q_PROPERTY(float slopeBias2 MEMBER slopeBias2 NOTIFY dirty)
|
||||||
Q_PROPERTY(float slopeBias3 MEMBER slopeBias3 NOTIFY dirty)
|
Q_PROPERTY(float slopeBias3 MEMBER slopeBias3 NOTIFY dirty)
|
||||||
Q_PROPERTY(float biasInput MEMBER biasInput NOTIFY dirty)
|
Q_PROPERTY(float biasInput MEMBER biasInput NOTIFY dirty)
|
||||||
Q_PROPERTY(float globalMaxDistance MEMBER globalMaxDistance NOTIFY dirty)
|
Q_PROPERTY(float maxDistance MEMBER maxDistance NOTIFY dirty)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
float biasInput{ DEFAULT_BIAS_INPUT };
|
// Set to > 0 to experiment with these values
|
||||||
float globalMaxDistance{ DEFAULT_MAX_DISTANCE };
|
float constantBias0 { 0.0f };
|
||||||
|
float constantBias1 { 0.0f };
|
||||||
float constantBias0{ 0.15f };
|
float constantBias2 { 0.0f };
|
||||||
float constantBias1{ 0.15f };
|
float constantBias3 { 0.0f };
|
||||||
float constantBias2{ 0.175f };
|
float slopeBias0 { 0.0f };
|
||||||
float constantBias3{ 0.2f };
|
float slopeBias1 { 0.0f };
|
||||||
float slopeBias0{ 0.4f };
|
float slopeBias2 { 0.0f };
|
||||||
float slopeBias1{ 0.45f };
|
float slopeBias3 { 0.0f };
|
||||||
float slopeBias2{ 0.65f };
|
float biasInput { 0.0f };
|
||||||
float slopeBias3{ 0.7f };
|
float maxDistance { 0.0f };
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dirty();
|
void dirty();
|
||||||
|
@ -116,7 +113,7 @@ public:
|
||||||
using JobModel = render::Job::ModelIO<RenderShadowSetup, Input, Output, Config>;
|
using JobModel = render::Job::ModelIO<RenderShadowSetup, Input, Output, Config>;
|
||||||
|
|
||||||
RenderShadowSetup();
|
RenderShadowSetup();
|
||||||
void configure(const Config& configuration);
|
void configure(const Config& config);
|
||||||
void run(const render::RenderContextPointer& renderContext, const Input& input, Output& output);
|
void run(const render::RenderContextPointer& renderContext, const Input& input, Output& output);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -130,29 +127,22 @@ private:
|
||||||
LightStage::ShadowFrame::Object _globalShadowObject;
|
LightStage::ShadowFrame::Object _globalShadowObject;
|
||||||
LightStage::ShadowFramePointer _shadowFrameCache;
|
LightStage::ShadowFramePointer _shadowFrameCache;
|
||||||
|
|
||||||
const int DEFAULT_RESOLUTION = 1024;
|
// Values from config
|
||||||
float _biasInput{ DEFAULT_BIAS_INPUT };
|
float constantBias0;
|
||||||
float _globalMaxDistance{ DEFAULT_MAX_DISTANCE };
|
float constantBias1;
|
||||||
int resolution{ DEFAULT_RESOLUTION };
|
float constantBias2;
|
||||||
|
float constantBias3;
|
||||||
// initialize with values from RenderShadowSetupConfig
|
float slopeBias0;
|
||||||
float constant0{ 0.15f };
|
float slopeBias1;
|
||||||
float constant1{ 0.15f };
|
float slopeBias2;
|
||||||
float constant2{ 0.175f };
|
float slopeBias3;
|
||||||
float constant3{ 0.2f };
|
float biasInput;
|
||||||
float slope0{ 0.4f };
|
float maxDistance;
|
||||||
float slope1{ 0.45f };
|
|
||||||
float slope2{ 0.65f };
|
|
||||||
float slope3{ 0.7f };
|
|
||||||
bool changeInDefaultConfigValues{ false };
|
|
||||||
bool distanceTriggeredByConfig{ false };
|
|
||||||
bool biasTriggeredByConfig{ false };
|
|
||||||
std::array<float, 8> cacasdeDistances; // 4 max then 4 min distances
|
std::array<float, 8> cacasdeDistances; // 4 max then 4 min distances
|
||||||
|
|
||||||
void setConstantBias(int cascadeIndex, float value);
|
void setConstantBias(int cascadeIndex, float value);
|
||||||
void setSlopeBias(int cascadeIndex, float value);
|
void setSlopeBias(int cascadeIndex, float value);
|
||||||
void setBiasInput(float input) { _biasInput = input; }
|
void calculateBiases(float biasInput);
|
||||||
void calculateBiases();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class RenderShadowCascadeSetup {
|
class RenderShadowCascadeSetup {
|
||||||
|
|
|
@ -117,17 +117,17 @@ Rectangle {
|
||||||
max: 1.0
|
max: 1.0
|
||||||
min: 0.0
|
min: 0.0
|
||||||
height: 38
|
height: 38
|
||||||
width:250
|
width: 250
|
||||||
}
|
}
|
||||||
ConfigSlider {
|
ConfigSlider {
|
||||||
label: qsTr("Shadow Max Distance")
|
label: qsTr("Shadow Max Distance")
|
||||||
integral: false
|
integral: false
|
||||||
config: shadowConfig
|
config: shadowConfig
|
||||||
property: "globalMaxDistance"
|
property: "maxDistance"
|
||||||
max: 100.0
|
max: 250.0
|
||||||
min: 1.0
|
min: 0.0
|
||||||
height: 38
|
height: 38
|
||||||
width:250
|
width: 250
|
||||||
}
|
}
|
||||||
Repeater {
|
Repeater {
|
||||||
model: [
|
model: [
|
||||||
|
@ -156,17 +156,17 @@ Rectangle {
|
||||||
integral: false
|
integral: false
|
||||||
config: shadowConfig
|
config: shadowConfig
|
||||||
property: "constantBias"+modelData
|
property: "constantBias"+modelData
|
||||||
max: 1.0
|
max: 3.0
|
||||||
min: 0.0
|
min: 0.0
|
||||||
height: 38
|
height: 38
|
||||||
width:250
|
width: 250
|
||||||
}
|
}
|
||||||
ConfigSlider {
|
ConfigSlider {
|
||||||
label: qsTr("Slope bias")
|
label: qsTr("Slope bias")
|
||||||
integral: false
|
integral: false
|
||||||
config: shadowConfig
|
config: shadowConfig
|
||||||
property: "slopeBias"+modelData
|
property: "slopeBias"+modelData
|
||||||
max: 1.0
|
max: 3.0
|
||||||
min: 0.0
|
min: 0.0
|
||||||
height: 38
|
height: 38
|
||||||
width: 250
|
width: 250
|
||||||
|
|
|
@ -319,7 +319,7 @@ const GROUPS = [
|
||||||
label: "Shadow Max Distance",
|
label: "Shadow Max Distance",
|
||||||
type: "number-draggable",
|
type: "number-draggable",
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 500,
|
max: 250,
|
||||||
step: 0.1,
|
step: 0.1,
|
||||||
decimals: 2,
|
decimals: 2,
|
||||||
propertyID: "keyLight.shadowMaxDistance",
|
propertyID: "keyLight.shadowMaxDistance",
|
||||||
|
|
|
@ -319,7 +319,7 @@ const GROUPS = [
|
||||||
label: "Shadow Max Distance",
|
label: "Shadow Max Distance",
|
||||||
type: "number-draggable",
|
type: "number-draggable",
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 500,
|
max: 250,
|
||||||
step: 0.1,
|
step: 0.1,
|
||||||
decimals: 2,
|
decimals: 2,
|
||||||
propertyID: "keyLight.shadowMaxDistance",
|
propertyID: "keyLight.shadowMaxDistance",
|
||||||
|
|
Loading…
Reference in a new issue