Texture splatting - usually - is done by vertex painting, where each channel R-G-B-A is assigned as a different texture weight.

enter image description here

Due to the way shaders are executed, doesn't it mean that the fragment shaders will ALWAYS sample 4+ textures even if the weights are (1,0,0,0) or (0,1,0,0)?

Lets say some parts of the terrain are almost exclusively grass and the other part of the terrain is exclusively dirt, which means the times when more than one texture sample is necessary is very, very rare - on the transitions, but regardless 4 textures are sampled?

Or do GPUs perform some sort of optimization to minimize the impact of this?


1 Answer 1


Yes it does sample all textures all the time.

It boils down to the cost of sampling compared to the cost of the conditional statement in the shader. At how many samples does the condition start the be beneficial might vary, depending on hardware and such.

  • \$\begingroup\$ There was an interesting talk on the Witcher 3's terrain rendering, where the developers found that a little branching to do only one or two samples instead of full triplanar mapping where possible turned out to be a worthwhile trade in their case. \$\endgroup\$
    – DMGregory
    Jul 15, 2018 at 15:09
  • \$\begingroup\$ makes sense, imagine 3 times more sampling of X textures on a modern PBR shading system :) \$\endgroup\$
    – Brice V.
    Jul 15, 2018 at 15:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .