How do i make my distance field fake shadows work properly?

I made this material a while ago that fakes shadows on the floor, if the mesh is close enough.
This will be useful in certain cases for my isometric 2.5D game:


As you can see this shadow that is projected in the floor by the red cube is not the dynamic unreal shadow, it is a distance field shadow, the dynamic shadows are off:

Though it is kind of working, the mesh floor where i have the material seems to have this weird rectangular shape shadow in the borders (not to confuse with the one being emitted by the red cube, thats the one i want):

See this weird rectangular shade, it happens in the floor as i move the camera around and also when i move my floor up and down.
Is there a way to fix this?

Project and video:

T_DistFieldShadow.rar (1.7 MB)

1 Like

Did you turn off ‘affect distance fields’ on the floor mesh?

1 Like

Thanks that was what was missing, it fixed it.
And coincidentally it was you who taught me this technique like a year ago, i have it here written in my notes.
Thanks again.

1 Like

:smiley:

1 Like

Though it seems the Distance fields are not working the more you go to lower levels in the Z.
Is there a workaround that could fix this?
I messed around with the camera distance and that wasn’t related.
Made some searches that suggested to change the mesh Editor → Build Settings → Distance Field Resolution Scale, that didnt work.
Any tips?

1 Like

I haven’t had a chance to look properly, but my first guess would be the material.

Perhaps that constant you’re adding to world location? ( because you are changing the world location of the plane ).

1 Like

yup, found out a related solution of @3dRaven in another post, just adjust it to the distance of the camera and voilĂĄ:

1 Like