Download

Creating a World-Space Cylinder Mask in a material to simulate shadowing.

Just wondering if anybody has done this before I start working on it - I need a way to create a Cylinder Mask in World-Space, similar to the way the Sphere Mask node works. I want to take the world position of a pixel, check if it’s in world space and drive a few Lerp nodes accordingly.

I essentially need to use it to fake the dynamic Shadow from a huge object, (when a Satellite object is in the shadow of a (very large) sphere at world origin, it can darken it’s material accordingly). Doing this in a similarly to how the sphere mask works will allow me to create a cylinder volume with a soft edge that I can use as as mask, so the transition won’t be solid.

Additionally, since the earth / planet object is essentially a static sphere and the sun direction never moves, the cylinder location / orientation in world space won’t ever change.

Currently we’re using dynamic shadows, but the cost of the pre-shadow is enormous since the Earth/planet takes up a vast majority of the screen space meaning half of the scene is rendered in the pre-shadow pass. This should be a nice way to fake dynamic shadows from such a huge object for mobile :slight_smile:

So, if anybody already knows the math behind this and wants to save me the trouble, feel free :slight_smile:

EDIT: Found one on answerhub. Thanks RyanB as usual :wink:

https://answers.unrealengine.com/questions/218181/making-a-cylindrical-mask-instead-of-sphere.html