Force Masked Materials to fully block lighting

Hi everybody. I have a question about masked materials and their shadow casting behaviour.
Is it possible to set up a material, that is rendered using a regular clipping mask (= masked material) that still casts shadows as if the material was fully opaque with no masking active.

This might be a bit silly as for years people wanted the exact opposite and now that we have fancy masked shadows I would like to do it the other way again:p

As a bit of a situation sketch:
Say I am making a top down game and I have an environment that is mainly exterior and a little house that I can enter.

As I enter the house I can’t see my player because I’m using a fixed camera height. So I use a masked material for the roof and some additional trickery to make the roof vanish in a clean and perhaps stylized fashion.

What will happen by default is the enterior will receive the lighting from the exterior directional light as the mask starts clipping away. And we don’t want that in this case.
This is really cool and awesome but in this case we would want the roof mesh to still block the light. Keeping the inside shielded from the exterior light.

So is there a way to make this work via the material setup or any possibility to add an always block light flag to the material properties? A way to create light blocking volumes?
Or is this not doable with a mask material due to the rendering/lighting pipeline?

I have looked for a solution in UE4 but ao far no luck.

This is just one example that would have use of this but I’m sure that this would be of great use for other things as well. For example to be able to create unique gameplay mechanics, visual illusions and so forth.

All thoughts and ideas welcome.
Thanks :slight_smile:

Hi Brechtos,

There isn’t an option to do this with a masked material due to the rendering pipeline and deferred rendering, however you are able to do this with a hidden mesh that can act as the shadow caster.

You can simply setup up a basic mesh, it doesn’t have to be as detailed as the roof or any other mesh you may need.
Set the flag in the mesh details panel for “Actor Hidden In Game” to true.
Under the lighting tab, set the flag to true for “Cast Hidden Shadow.”

This will work with Dynamic/Stationary/Static Lighting depending on your needs.

With static lighting, you will not need to set the flag for “Cast Hidden Shadow” though.

I hope this helps.

Tim

Thx Tim!
Was the next solution to try to set up on my list but was unaware about the cast hidden shadow thing. Silly me.

Problem solved :slight_smile: