Exclude Objects from SSR Reflection

Hi everyone, We want to exclude certain objects from being visible in an SSR Reflection. For example we want to have our Hero Object to have SSR and reflect everything except the Background, so we need to exclude the Background from SSR.
The only thing I can think of are Custom Depth Stencil and recombine Foreground/Heroobject and Background in a Postprocess Material after Tonemapping ?
Any ideas if this could work or if there is an easier way ?
Best Dominic

usually excluding objects from SSR is not possible, because it’s a screen-space effect and there is no information “behind” the object that you want to skip
however excluding the background can actually be achieved. the SSR shader code performs traces in screen space using the depth buffer to then sample the result of the previous frame.
manually modifying the SSR hlsl code, you can limit the screen-space traces to a maximum depth which will be interpreted as a failed trace. and like other failed traces (i.e. the screen borders) the shader will fall back to displaying the skylight’s reflection cube.
so in short, yes you can do it. but you need to modify the SSR hlsl code

Hi Thanks for the info.
I guess this will need an custom Engine to be able to change the SSR hlsl code ?

You can edit the shaders in the launcher version too.

@Manoel.Neto Oh really, have you any links or buzz words to search for ?

Then go into the UE4 engine\shaders folder and hack around.

Is there a way to overwirte the SSR Shader on a Project basis ?

No, shaders are included as part of the engine version, not the project.

Is it possible to overwrite Shaders completley in a Project ?

So i found that you have to add to the if condition in line 159, 217, 248 and 273 a check for the raylength, but i couldnt find the variable holding the RayCast length for this pixel.

anyone can help me out here ?

So this is giving me some results:


 
 BRANCH if( HitUVzTime.w < 1 && HitUVzTime.z > 0.02 ) 

But I don’t understand why we test for greater than … isn’t HitUVzTime.z the ray length, so it should be smaller than a certain length ?
And it of course takes the whole raylenghts from the Viewport and not from the Reflection surface. We want to archive that every reflection ray of our reflective surface longer than 10cm is not giving any SSRs. Is this even possible ?

Now this would be a neat trick for say a game with Vampires or something :stuck_out_tongue: