1
\$\begingroup\$

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?

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\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 '18 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 '18 at 15:28

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.