Optimize Material Performance

Hello together,

i try to figure out how to improve my landscape material, performance wise. Since i use some WorldAlignedBlends I thought i could switch to a cheaper version. As a result i came up with this function:

Add 2 → 1; Subtract 1 → 2; Multiply 3 → 1; Clamp 1 → 0; Saturate 0 → 1 (is cheaper than clamp?); Switch 1 → 0

Old material 8 math expressions, new material 5 math expressions, but i have 1 more base pass shader instruction?

I’d really appriciate if someone could enlighten me.

Shader instructions are not 1 for 1 per expression node. Some expression nodes have more and some have less (basically, some nodes are more heavy than others). If you want to lower your instructions, lowering nodes can help, but you should also concentrate on using nodes that inherently have less instructions.

One way you could optimize, if you don’t mind not having anything reflective, is to check “fully rough” on the material details panel. That usually lowers the instructions a bit. I’m not sure if it works on landscapes or not, but I don’t see why it wouldn’t.

I exchange an Add with an Subtract (wich should be similar?) and remove 2 Multiplies, and my result is worse.

Is there any rule how math should be build? Something like First add/subtract, then Multi/divide.

I’m not sure why it would increase then. I just know that shader instructions to nodes are not 1 to 1.

Maybe it also depends on what is being multiplied? Are you by any chance multiplying a 3 vector when it was previously multiplying scalars? I’m not sure if that would increase instructions or not, but that’s all I can think of.

Hm. Well i think you could be right with that 3 vector. I chained the math expressions, compared to the original where some stuff is calculated outside the main chain.

Never thought about this so far. Thanks for your time.