Masked material vs Opaque+PixelDepthOffset

Hi !
I had performance problem because of overdraw my grass and I had an idea:
Use an Opaque material instead of Masked and use a really big value in “Pixel Depth Offset”.
The shader complexity is reduced by A LOT and the “mask effect” is still here.
Because that’s grass there will be something behind (like a ground) so there wont be any artefact due to the offset itself (this is less sure for things like trees).
It has been tested on Windows, OSX and linux without any problems in editor or in packaged.

What I’m less sure (and why I’m posting here) is I don’t know if there will be more attracts or limitation that I didn’t expect.

Here is my shader complexity in “Masked”:

Here is my shader complexity in “Opaque+PixelDepthOffset”:

Here is how I setup my material in “Masked”:

And Finally here is how I switched to “Opaque+PixelDepthOffset”:

There is 0 changes on the final image but if you want some render I can include some.
If there is no expected problems I think it would be great if unreal rewrite the masked more with “PixelDepthOffset = MaxDepth + 1” or something like, it will make a opaque materials pretty cheap. I can display millions of grass blade procedurally generated using noise on a 2015 MBP and still stay beyond 22FPS in editor with all settings to “cinematic” in a fully populated scene !

I’m afraid to disappoint you, but besides confusing shader complexity accumulator, your trick accomplishes nothing.

I’ve thought about this at some point but I was never sure of the effectiveness it would have.
By moving the opacity to the PixelDepthOffset you’re just moving the calculations elsewhere so in theory the stuff that is processed should be the same. Initially I’d suspect that the ShaderComplexity viewmode just doesn’t take into account the cost of what happens with PDO.
however if this truly somehow gives better performance I’d start suspecting something fishy in the Masked mode

your shadercomplexity screenshots already serve as a good comparison. could you post a performance comparison screenshot please? (same camera angle, lit viewmode, and show stat fps and stat unit)

I actually get some differences in performance but the result is highly random and inconsistent. I tested in 2 very different scene:
I can’t show the first one (NDA stuff…) but I get 58ms in masked vs 191ms opaque+pixel depth offset (so PixelDepthOffset was actually slower)
in the second scene I get 167 in masked and 150 in opaque+pixelDepthOffset (so masked was slower).

The second Scene:
a2a60a4524aa399edda84ba1a0efef7abde25c46.jpeg
(all those perf tests are made from OSX on a R9 M370X)

On a Rx470 and windows the result are more consistant (and “stat GPU” work…)
The first scene:
Opaque:
35 FPS - 29ms
BasePass - 14ms
Masked:
36 FPS - 28ms
BasePass - 13.7ms

So I think there is a problems with “opacity mask” and/or “pixel Depth Offset” and/or framerate inconsistency on OSX.
Actually I made launched this thread because I was VERY surprised about what happen and I wanted to understand.
I’m gonna try on linux soon and edit this post. But I’m gonna make a bug report about that Shader Complexity in Opaque mode anyway (which just give me a fully green image on OSX anyway…)

Note: all test are on “packaged” and “development”

Your performance difference can be explained by depth prepass.

So there is actually a difference but not significant. Do you have more information on how Pixel Depth Offset and/or Masked material interact with depth prepass in unreal ? (there isn’t much documentation about this it seems and if that can help my work on performance…)