mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 20:44:14 +02:00
Trying a different way of determining the cascade threshold distances.
This commit is contained in:
parent
391902f79b
commit
0b4484a153
4 changed files with 10 additions and 2 deletions
|
@ -2298,6 +2298,9 @@ void Application::updateShadowMap() {
|
|||
for (size_t j = 0; j < sizeof(points) / sizeof(points[0]); j++) {
|
||||
radius = qMax(radius, glm::distance(points[j], center));
|
||||
}
|
||||
if (i < 3) {
|
||||
_shadowDistances[i] = -glm::distance(_viewFrustum.getPosition(), center) - radius;
|
||||
}
|
||||
center = inverseRotation * center;
|
||||
|
||||
// to reduce texture "shimmer," move in texel increments
|
||||
|
|
|
@ -266,6 +266,8 @@ public:
|
|||
void getModelViewMatrix(glm::dmat4* modelViewMatrix);
|
||||
void getProjectionMatrix(glm::dmat4* projectionMatrix);
|
||||
|
||||
const glm::vec3& getShadowDistances() const { return _shadowDistances; }
|
||||
|
||||
/// Computes the off-axis frustum parameters for the view frustum, taking mirroring into account.
|
||||
void computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
|
||||
float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const;
|
||||
|
@ -493,6 +495,7 @@ private:
|
|||
|
||||
static const int CASCADED_SHADOW_MATRIX_COUNT = 4;
|
||||
glm::mat4 _shadowMatrices[CASCADED_SHADOW_MATRIX_COUNT];
|
||||
glm::vec3 _shadowDistances;
|
||||
|
||||
Environment _environment;
|
||||
|
||||
|
|
|
@ -528,8 +528,7 @@ void VoxelSystem::initVoxelMemory() {
|
|||
|
||||
_cascadedShadowMapProgram.bind();
|
||||
_cascadedShadowMapProgram.setUniformValue("shadowMap", 0);
|
||||
_cascadedShadowMapProgram.setUniformValue("shadowDistances", -SHADOW_MATRIX_DISTANCES[1],
|
||||
-SHADOW_MATRIX_DISTANCES[2], -SHADOW_MATRIX_DISTANCES[3]);
|
||||
_shadowDistancesLocation = _cascadedShadowMapProgram.uniformLocation("shadowDistances");
|
||||
_cascadedShadowMapProgram.release();
|
||||
}
|
||||
}
|
||||
|
@ -1179,6 +1178,7 @@ glm::vec3 VoxelSystem::computeVoxelVertex(const glm::vec3& startVertex, float vo
|
|||
ProgramObject VoxelSystem::_perlinModulateProgram;
|
||||
ProgramObject VoxelSystem::_shadowMapProgram;
|
||||
ProgramObject VoxelSystem::_cascadedShadowMapProgram;
|
||||
int VoxelSystem::_shadowDistancesLocation;
|
||||
|
||||
void VoxelSystem::init() {
|
||||
if (_initialized) {
|
||||
|
@ -1502,6 +1502,7 @@ void VoxelSystem::applyScaleAndBindProgram(bool texture) {
|
|||
if (Menu::getInstance()->getShadowsEnabled()) {
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::CascadedShadows)) {
|
||||
_cascadedShadowMapProgram.bind();
|
||||
_cascadedShadowMapProgram.setUniform(_shadowDistancesLocation, Application::getInstance()->getShadowDistances());
|
||||
} else {
|
||||
_shadowMapProgram.bind();
|
||||
}
|
||||
|
|
|
@ -234,6 +234,7 @@ private:
|
|||
static ProgramObject _perlinModulateProgram;
|
||||
static ProgramObject _shadowMapProgram;
|
||||
static ProgramObject _cascadedShadowMapProgram;
|
||||
static int _shadowDistancesLocation;
|
||||
|
||||
int _hookID;
|
||||
std::vector<glBufferIndex> _freeIndexes;
|
||||
|
|
Loading…
Reference in a new issue