Question about inner workings of shadow mapping

Hello,

I am creating a C++ port of three.js (find it at https://github.com/bergstr11/three.cpp) and have arrived at the point where the first example renders with lighting and partial shadowing. This is the example where a plane is shown together with a cube and a sphere. Both cube and sphere show shadowed sides, but the shadow is not cast onto the plane.

As I understand it, the coloring/shading of the cube and sphere is done through a depth render buffer, while the shadow cast onto the plane uses a texture. All this seams to be setup correctly. receiveShadow is set for the plane, and I can see the generated shader source for the plane material showing the USE_SHADOWMAP macros and all. Maybe someone here can guide me a little to track down the issue. I must admit that I am not really an expert at OpenGL, this is learning by coding…

thank you,
Christian

Since I just posted pretty much exactly the same suggestion here - have you tried using a box with zero height instead of a plane? That tends to work better for shadows.

thanks for the suggestion. However, I don’t want to find a workaround or alternative solution, as I am trying to get the fundamental primciples established with my C++ port. There must be something rather tiny I am missing, as everything else works, and the code has been ported mostly 1:1. My hope is that someone who understands the inner workings of Three.js’s shadowing implementation could quickly point me to the issue.

never mind, it works now. However, the shadow is very “coarse-grained”, which is also what I see when running the same example on Three.js proper. I suspect this has to do with my 4K monitor and the shadow computation algorithm employed…