IsFirstPerson buffer ignores Translucent Materials

Hi,

I’d like to inquire whether it is know that the IsFirstPerson mask ignores Translucent materials, and if it is if there is a fix.

Steps to Reproduce

  1. Create any shape (static mesh)
  2. Assign any translucent material
  3. Set static mesh to FirstPersonPrimitiveType: First Person
  4. Create any PostProcess material, sample “IsFirstPerson” buffer
  5. Apply Post Process material to any PPV
  6. See that mesh is absent from mask

Hi Jeremy,

this is a known limitation. The IsFirstPerson bit is stored in the gbuffer, so only opaque objects draw to it. This limitation is also mentioned in the online documentation:

The Scene Texture node can sample the GBuffer to tell whether a given pixel was drawn by a first person primitive that uses an opaque material.

Unfortunately there’s no straightforward solution to the issue. At best we could somehow take the union of the first person-ness of all translucent and the front-most opaque primitives overlapping a given pixel, but doing that is not very straightforward and will probably have performance cost in writing that bit as all translucent objects now also need to write to the GBuffer (in a way where non-FP primitives do not overwrite the bit if it was already set).

If you 100% need this feature, maybe you could implement it yourself by drawing your translucent FP objects into custom stencil and then sample both custom stencil and the IsFirstPerson bit? We can’t do that in a built-in way because the regular depth buffer stencil bits are already spoken for.

-Tim

Allright I see, thank you Tim

Last question: what about single layer water? The material does not render if the mesh is set to first person primitive type first person. I’m not talking about the isFirstPerson buffer, the material just does not appear in the main pass

Hi,

good catch! You seem to have run into a bug here. I did some investigation and it seems like this is happening because the depth-only vertex shader does not compile for water when used with FP (for complex reasons), so the water depth prepass doesn’t execute the draw and then the main water pass also doesn’t draw anything because it relies on the depth prepass having written to depth/stencil. I’ll try and get this fixed by the next release (should be fairly simple), thank you very much for bringing this to my attention!

Cheers,

Tim

No worries.

In the meantime, we’ll be using this very bug to switch to an opaque view when we switch between First Person mode and normal one