1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Implement shadow offsets for the new SM distortion function (#12191)

* Move shadow position calculation to vertex shaders
* Animate entire scene before rendering shadows to prevent lagging of shadows
* Remove unnecessary use of PolygonOffsetFactor
* Apply normal offset to both nodes and objects
* Rename getPerspectiveFactor -> applyPerspectiveDistortion
* Remove perspective distortion from fragment shaders
This commit is contained in:
x2048 2022-04-14 22:49:30 +02:00 committed by GitHub
parent 9aabd911eb
commit a5d29fa1d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 184 additions and 122 deletions

View file

@ -143,7 +143,7 @@ size_t ShadowRenderer::getDirectionalLightCount() const
f32 ShadowRenderer::getMaxShadowFar() const
{
if (!m_light_list.empty()) {
float zMax = m_light_list[0].getMaxFarValue();
float zMax = m_light_list[0].getFarValue();
return zMax;
}
return 0.0f;
@ -418,10 +418,6 @@ void ShadowRenderer::renderShadowMap(video::ITexture *target,
material.BackfaceCulling = false;
material.FrontfaceCulling = true;
material.PolygonOffsetFactor = 4.0f;
material.PolygonOffsetDirection = video::EPO_BACK;
//material.PolygonOffsetDepthBias = 1.0f/4.0f;
//material.PolygonOffsetSlopeScale = -1.f;
if (m_shadow_map_colored && pass != scene::ESNRP_SOLID) {
material.MaterialType = (video::E_MATERIAL_TYPE) depth_shader_trans;
@ -431,9 +427,6 @@ void ShadowRenderer::renderShadowMap(video::ITexture *target,
material.BlendOperation = video::EBO_MIN;
}
// FIXME: I don't think this is needed here
map_node->OnAnimate(m_device->getTimer()->getTime());
m_driver->setTransform(video::ETS_WORLD,
map_node->getAbsoluteTransformation());
@ -479,10 +472,6 @@ void ShadowRenderer::renderShadowObjects(
current_mat.BackfaceCulling = true;
current_mat.FrontfaceCulling = false;
current_mat.PolygonOffsetFactor = 1.0f/2048.0f;
current_mat.PolygonOffsetDirection = video::EPO_BACK;
//current_mat.PolygonOffsetDepthBias = 1.0 * 2.8e-6;
//current_mat.PolygonOffsetSlopeScale = -1.f;
}
m_driver->setTransform(video::ETS_WORLD,