Exclude shadow caster from shadow-receiver mesh

Hi everyone!

I am faced with a problem that I can`t solve. I try to find way to exclude shadow caster from one receiver mesh but save it on another receiver mesh.

I create small demo picture to my situation was clear

By the true i found a way to do effect like this (I created light that was cloned from source light and excluded all meshes in scene and include only obj1 and then create second shadow for it). But i dont think that it is best way because i must create second shadow, and it is not good in performance plane.

As you found out, I think creating another light and another shadow generator for this light is the only way to do what you want.

For completeness, it’s possible to do it but it’s somewhat an advanced task.

You would need to update the shadow map generation code/shader to create a separate texture T that would tell which object has written a value in the shadow map. So, each time pixel (x,y) is written in the shadow map, write the object id (or something unique to the mesh) into T at location (x,y). However, if the mesh that writes to the shadow map is your object 2 (the one that should not cast shadow on the plane) and T has already a non empty value at (x,y), don’t overwrite, keep the existing value (not sure this step will be easy to do…). Alternatively, if object 2 is handled before the other objects when creating the shadow map, you don’t need this latter step.

Then, when drawing the meshes, use texture T to know if you should apply the shadow computation: for the ground, if value = id of object 2, don’t apply shadow computation.

1 Like

Thanks for reply! I’ll think about it.