Performance of shaders?

Hey, I have a more general question. Which elements of a shader have a significant effect on the render performance of it?

What for example makes this shader http://www.unifycommunity.com/wiki/index.php?title=Texture_Only much more faster then this http://www.unifycommunity.com/wiki/index.php?title=TerrainFourLayerDiffuseFast ?

It’s obvious that the longer the shader gets the slower it performs but in many cases there are some special bottlenecks that are crucial for the performance of a system. How about shaders?

All elements have significant effect as each single operation you perform counts, as each operation is performed for each pixel or the texture.

In addition, texture lookups are “costly” (not in their costs to perform it but it takes 600-2000 cycles until the texture is in the gpus close cache to access from shader) and that lookup can cost performance especially on older (pre DX10 hardware on NVIDIA, unsure on where the change was on ATI) hardware.

Thats the reason the first one is much faster, it does not use 4 textures that have to be gotten first, it has a lot less operations to perform etc.

Thanks! I additionally have experienced that lighting is very costly too, especially when the shader has to deal with many triangles.

Certain operations like Pow, Log etc ie higher level math functions will cripple most shaders. You can make texture based lookup tables though. I’m no expert however.

Not sure what you mean by dealing with many triangles. That shouldn’t affect shader performance in the slightest - unless it is a vertex shader or a shader dealing with lighting calculations that use higher level math.