SceneDepth applied to spotlight to fake shadows is "pealing" up on the edges

A bit of context: I’m using a spotlight that has shadows turned off, so that I can create a sphere around the origin of the spotlight that will set the intensity to 0 so that when it has a super tight zoom and would be “outside” of its housing, it will retain the same diameter coming out of the housing.


This works great but shadows needs to be off otherwise the housing will just block the spotlight when its outside. So the spotlight doesn’t shadow anything at all.

In comes the SceneCaptureComponent, this is grabbing the scene depth from the perspective of the spotlight, I am then applying this to the same sphere intensity clipping function that’s cutting the beam outside of the housing in the back.

This starts to look really promising, it casts shadows and looks pretty good… however, its starts to “peal” up around the edges of the spotlight



I am completely lost on where to start with fixing this, it’s almost like I need a gradient that just pushes the edges down a bit. I would like to leave that option last as it seems like a lot of guessing and would rather have a solid fix for this.

The depth map is the distance to the camera plane, not the distance to the camera position, you need the camera transform of the scene capture: Projecting a Texture in Worldspace | Tutorial

Also make sure your scene capture is has “depth only” enabled, otherwise this is stupidly expensive.

Its so close, however, it has the same effect as the method I was using previously


I think I found the issue, however I don’t know how to fix it.
I believe that the issue stems from the scene depth capture I am using. It looks like it only captures the Z depth (not sure if that’s the right terminology) and not the ray distance (also not sure of that’s the right terminology). So if you take a scene capture and point it directly at a flat surface, it will output an even value, that’s working its a flat surface, right? Yes-ish but what it fails to do is give the distance based on the focal length, what I would expect of the output of a flat depth capture is a gradient where the center of the capture is the shortest distance and then gradually having a longer distance the further from the center it is.