mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-26 18:21:04 +00:00
Improve shadow filters (#12195)
* Rewrite shadow filtering for the new distortion * Calculate penumbra radius using a single sample * Avoid peter-panning effect due to filtering of short shadows * Add adaptive filter quality for soft shadows * Avoid sharp shadows on surfaces without normals (e.g. plants) * Increase default and maximum soft shadow radius * Make line numbers in shader errors match the code
This commit is contained in:
parent
a4ef62f5b2
commit
dc45b85a54
9 changed files with 131 additions and 220 deletions
|
@ -489,6 +489,8 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
|
|||
// Do not enable filter on shadow texture to avoid visual artifacts
|
||||
// with colored shadows.
|
||||
// Filtering is done in shader code anyway
|
||||
layer.BilinearFilter = false;
|
||||
layer.AnisotropicFilter = false;
|
||||
layer.TrilinearFilter = false;
|
||||
}
|
||||
driver->setMaterial(material);
|
||||
|
|
|
@ -771,6 +771,8 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
|
|||
shaders_header << "#define SOFTSHADOWRADIUS " << shadow_soft_radius << "\n";
|
||||
}
|
||||
|
||||
shaders_header << "#line 0\n"; // reset the line counter for meaningful diagnostics
|
||||
|
||||
std::string common_header = shaders_header.str();
|
||||
|
||||
std::string vertex_shader = m_sourcecache.getOrLoad(name, "opengl_vertex.glsl");
|
||||
|
|
|
@ -670,6 +670,7 @@ std::string ShadowRenderer::readShaderFile(const std::string &path)
|
|||
std::string prefix;
|
||||
if (m_shadow_map_colored)
|
||||
prefix.append("#define COLORED_SHADOWS 1\n");
|
||||
prefix.append("#line 0\n");
|
||||
|
||||
std::string content;
|
||||
fs::ReadFile(path, content);
|
||||
|
|
|
@ -274,7 +274,7 @@ void set_default_settings()
|
|||
settings->setDefault("shadow_filters", "1");
|
||||
settings->setDefault("shadow_poisson_filter", "true");
|
||||
settings->setDefault("shadow_update_frames", "8");
|
||||
settings->setDefault("shadow_soft_radius", "1.0");
|
||||
settings->setDefault("shadow_soft_radius", "5.0");
|
||||
settings->setDefault("shadow_sky_body_orbit_tilt", "0.0");
|
||||
|
||||
// Input
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue