- Home /
Why is alpha clipping in the Shader Graph way less performant than in a normal HDRP/Lit shader?
I have a test scene with a bunch of trees. If I use an HDRP/Lit shader with alpha clipping enabled for the leaves, it runs pretty decent. However, if I use a simple shader graph with alpha clipping, the performance tanks.
I'm getting 8.3ms/frame with the lit shader vs 11.1ms/frame with the shader graph shader with 100 trees. This is all in the editor, not a build.
Any idea what could be causing this performance difference and how to fix it? I want to give the leaves a custom shader graph, but the performance hit from the alpha clipping alone makes this not very viable for my scene. Here is a screenshot of my shader graph:
Answer by JJRivers · May 24, 2021 at 10:55 AM
With current default HDRP settings you should be seeing improved performance not degraded performance when using a single shader for all trees. I would presume the causes are in asset setup or project and material settings.
Pointers to research on: Do you have SRP Batcher on or off, are your materials setup accordingly to that choice (the default is on, setting is found in your HDRP asset debug mode). If its disabled you need to ensure your GPU instancing setting is on with the trees and use as few materials as possible, if its enabled your prefab/material setup has some shenanigans going on with them.
Answer by andrew-lukasik · May 24, 2021 at 02:16 PM
I suspect it's because alpha clipping
introduces per-pixel visibility testing requirement and overall increase in overdraw* where per-triangle
(or other geometry-based method) was enough for lit
.
* Overdraw. Because CPU won't test this per-pixel (prohibitively costly) and therefore will just flag all meshes in view frustum for rendering and leave this per-pixel culling drama for GPU to figure out.
Answer by ThePilgrim · May 25, 2021 at 12:46 PM
Thanks for the replies. I did later notice that the difference in performance is way more pronounced when using forward rendering. According to the profiler, one of the large differences in time came from the ForwardOpaqueRenderLoop.ScheduleDraw.
This bug seems to be fixed now as of HDRP version 11 https://issuetracker.unity3d.com/issues/a-most-simple-shader-graph-with-alpha-clipping-is-performing-worse-when-compared-to-the-hdrp-slash-lit-shader