We are experimenting with First Person Rendering in our project where we currently do not have any world space representation of our character, so reflections should not show anything - however, we’re seeing in our project, and in the First Person Shooter template - that the primitive marked as First Person for it’s First Person Primitive type partially shows up in reflections.
It looks like the tris that are visible in screen space are being used in the reflection.
Is this a known issue, is there a configuration step ive missed, or a way to work around this?
What you’re seeing are indeed screen space reflections (either through Lumen or actual SSR). This is a known issue/limitation, so you didn’t miss any configuration switch. If it’s a big issue and you’re able to modify engine source code, you could change the screen space tracing shader to reject hits on first person pixels. First person pixels can be identified by a bit in the gbuffer when static lighting is disabled in the project settings. We didn’t implement this because it would increase the cost of all screen traces for a feature (first person rendering) that should otherwise be fairly self contained and not impact general performance of the rest of the renderer. Let me know if you’re interested in this solution and I can dig a bit deeper to give you some more details on how to implement this.
Great! So depending on whether you’re using Substrate or the legacy GBuffer path, there’s two different ways of telling whether a pixel is first person:
and the legacy GBuffer uses IsFirstPerson(FGBufferData)
Be aware that this functionality is guarded behind HasFirstPersonGBufferBit() (on the CPU) and HAS_FIRST_PERSON_GBUFFER_BIT (on the GPU), which is only true if:
It’s not a mobile platform
AND it’s not forward shaded
AND static lighting is DISABLED (Project Settings -> Rendering -> Allow Static Lighting = off)
Now depending on whether you’re seeing the issue in Lumen reflections or old school SSR reflections, you’d need to patch up the respective shader:
For Lumen, you’ll want to look at Engine\Shaders\Private\Lumen\LumenReflectionTracing.usf in ReflectionTraceScreenTexturesCS, right after TraceScreen() and that hair strands logic and before the if (bHit) branch and insert a block of code like this:
If you’re running with classic SSR, you’d need to insert a similar block of code in Engine\Shaders\Private\SSRT\SSRTReflections.usf around line 310 (in my version of the codebase) for glossy/multi ray reflections and in line 389 for single ray reflections. You might need to use GetGBufferData(HitUVz.xy) here instead of GetGBufferDataFromSceneTextures(HitUVz.xy) and you might also need to pull in the substrate headers if they’re not already included: include “/Engine/Private/Substrate/Substrate.ush”