From e36b2226b9c6c69ac0c9033c8c0d8e9897e57b4b Mon Sep 17 00:00:00 2001 From: x2048 Date: Sun, 17 Sep 2023 21:42:14 +0200 Subject: [PATCH] Skip face culling in shadows for double-sided materials (e.g. plantlike) (#13500) * Skip face culling in shadows for double-sided materials (e.g. plantlike) * Keep previous face culling for transparent surfaces e.g. water --- src/client/clientmap.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/client/clientmap.cpp b/src/client/clientmap.cpp index 838d74c03..b831724b3 100644 --- a/src/client/clientmap.cpp +++ b/src/client/clientmap.cpp @@ -1198,8 +1198,14 @@ void ClientMap::renderMapShadows(video::IVideoDriver *driver, // override some material properties video::SMaterial local_material = buf->getMaterial(); local_material.MaterialType = material.MaterialType; - local_material.BackfaceCulling = material.BackfaceCulling; - local_material.FrontfaceCulling = material.FrontfaceCulling; + // do not override culling if the original material renders both back + // and front faces in solid mode (e.g. plantlike) + // Transparent plants would still render shadows only from one side, + // but this conflicts with water which occurs much more frequently + if (is_transparent_pass || local_material.BackfaceCulling || local_material.FrontfaceCulling) { + local_material.BackfaceCulling = material.BackfaceCulling; + local_material.FrontfaceCulling = material.FrontfaceCulling; + } local_material.BlendOperation = material.BlendOperation; local_material.Lighting = false; driver->setMaterial(local_material);