Shadows Cast by Custom-Node Raymarched Material

I’ve got a system to dynamically group primitive components into raymarched materials. It’s working well (and 5.1 dramatically improved iteration time!). I’m wanting to support shadows, and not quite sure where to dig in next. “hidden shadow” meshes could be an option, but I’m wondering if it can be solved more generically for weird raymarch shapes.

Made a small test scene with
1 static directional light (with lightmass bake) + 1 moveable directional light
lumen turned off
Masked + Colored Translucent planes producing the correct shadows
1 raymarched material in Translucent mode
1 raymarched material in Masked mode

I was expecting the Masked mode raymarch to cast a shadow. Does using the raymarch throw off the shadow passes from rendering?

Here are screenshots of the scene and material settings in question


The Masked Raymarch Material Settings:





Where would I start looking to get shadows going for these metaballs?

Edit: the raymarch is not a post process. It’s applied to oversized capsule meshes here

Thanks for any guidance

I would expect it to work with masked unless the raymarch loop is being skipped for shadow depths but that seems unlikely… (you aren’t using the shadowpass switch node right?)

If you keep all the settings the same and just unplug the raymarch loop, does the shadow appear? That would help narrow down the problem at least to the loop.

Have you tried with local lights? (point/spot/rect)

Edit: Actually I think I know the problem. I assume you’re probably using camera position for the ray origin which won’t work for shadow depths. It would need the lights position. You might be able to retrieve this in HLSL but I’m not sure how.

1 Like

Thanks for your input, @Arkiras! It helped me chunk down the debugging further, especially just unplugging the custom node ^_^’

Using the Camera Position node for the march vector actually works for the shadow pass!

It turned out to be a combination of “Opacity Mask Clip Value” setting on the masked material being too generous, the hlsl loops being a little too optimized, and at some point I had set the Project Settings > Shadow Map Method to the Beta Virtual Shadow Maps

1 Like

Oh dang that’s good to know :slight_smile:

Glad you tracked down the issue!