Download

Optimizing a triplanar material

So I’m doing a triplanar landscape material and wanted to optimize it, sort of like it has been done in this paper https://ubm-twvideo01.s3.amazonaws.com/o1/vault/GDC2014/Presentations/Gollent_Marcin_Landscape_Creation_and.pdf at page 34.
I got the tightening factor working in UE4 but I don’t know if it is affecting performance, because I don’t know how materials in UE4 fetch textures.
Do they fetch and calculate textures only for the portions of the mesh where they actually appear? (So anywhere where they aren’t completely masked out)
Or does this work in another way?
Right now I’m sampling 3 textures, one for each texture. I know I could also just sample one, but in that case I would not be able to have somewhat smooth transition zones between projections, it’d be a stark cutoff, which is not what I’m looking for.
Right now my nodes look like this


The bottom part generates the UVs for each projection and the top the masks.

So essentially I’d like to know if there is a more efficient way of doing this, how UE4 fetches textures, and lastly if using Virtual Textures would help in performance, I never looked into it but maybe it would help

with the regular nodes UE4 samples all your textures and then blends them. so it doesn’t matter if you tighten the blend area, it will still sample and blend everything.
you would need to use dynamic shader branching to actually have any effect on performance.
there’s an old thread where we discussed dynamic shader branching at length. as of today the state of dynamic shader branching is still the same as back then - constant folding might or might not give you a performance improvement, and true dynamic branching can only be achieved with Custom (HLSL) nodes