Is there a way to skip or otherwise mitigate the performance cost of a shader's tessellation stage when tessellation isn't necessary?
I'm using a tessellation stage in my surface shader, added with the optional tessellate surface parameter like so:
#pragma surface surf Standard tessellate:tessFunc
However, I only need to actually tessellate every once in a while. I was hoping to mitigate the cost of the tessellation stage by simply returning 1 if a tessellation keyword is disabled:
float4 tessFunc(appdata v0, appdata v1, appdata v2)
{
#ifdef _SHOULD_TESSELLATE
// Tessellation code here
#else
// return 1;
#endif
}
Even in the case where the function simply returns 1, the presence of this stage adds enough render overhead to make it impractical to use on a large scale (i.e. every object) if I'm not getting anything out of it.
I've tried using a replacement shader that contains copies of every RenderType with tessellation added, but using a replacement shader produces inconsistencies in the shadowcaster pass for my objects.
As far as I know, it's not possible to conditionally set surface parameters, even optional ones. But is there any way to not eat the cost of a tessellation stage that isn't doing anything?
Your answer
Follow this Question
Related Questions
Optimizing Shader Compiler for HDRP 0 Answers
Best way for a Snow Path Like 0 Answers
How does Unity render passes? 0 Answers
_Time in Image Effects 0 Answers
Troubles with game optimization for mobile and overall workflow in Unity 1 Answer