Download

Do unused or zeroed maps on shaders have any cost?

I’m looking into setting up a universal highlight on a material that can be enabled or disabled as necessary. Because the development platform is Quest 2, I’m avoiding post processing depth features at all costs.

The “Fully Rough” setting implies that there’s a difference between setting a value to 0 and disabling it entirely. I would assume there could even be another detection level for maps that have nothing plugged into them, as the engine could safely assume it will never be needed.

In my case, I’m curious if there’s a cost to a shader with an emissive feature turned down to zero. A basic highlight would include fresnel and panning calculations, maybe more complex features as I design it out, which I wouldn’t want to be running on every possible object when the highlight is off. The best way to ensure it can affect any asset in the project is to implement it on the master material which stacks up when applied to vast swathes of the materials I’m using. If I ramp a value back down to 0 through a blueprint, do those features still run only to be multiplied by zero at the end or does Unreal know to skip the calculations?

I’m still a little rough on dynamic material instances. I assume since booleans are static that I would need to have a duplicate material compiled for every single object if I wanted to “switch” them on and off by assigning a dynamic material.

Alternatively, is there a better approach to dynamically highlighting an object through its material (while running on a VR potato)?

If emissive is unused or a constant 0 then you save 1 instruction. If it is a parameter and it is 0 then it looks like you still pay the cost (according to the material instruction count) even though it is doing nothing.

Interestingly, ‘Fully Rough’ and setting a constant roughness of 1 have the same instruction count, leading me to believe the setting may be redundant.

I would say the most performant option is probably doing a material swap. Unreal’s water system faced a similar(ish) problem where they wanted different effects for oceans/lakes/rivers, that all needed to be seamlessly connected. In order to avoid paying the cost of all of them at once, instead they have dedicated materials at the transition points to act as blends so that they’re only paying the cost of multiple materials at a small point.

Take this with a grain of salt, I’m not a tech artist or a graphics engineer.