Download

Performance - code-path vs execution-path, way to replicate switch behavior or switch on alpha?

So, in some testing, I can see how StaticSwitch can be used to acutually make execution-paths much shorter cheaper, but having trouble making it work with a non-bool…

I have a very expensive landscape material that I switch between and a simple 3vector basecolor. Using the switch node I can see in the pixel-shader-bar-thingie (alt-8) that it’s MUCH cheaper when I engage the switch, as I would expect at runtime.

HOWEVER, I can’t seem to tie this into something spitting out an alpha or the like, say a distance fade where I can stop using detail texturing after a certain distance.

IF statement’s don’t seem to be able to pass bool’s nor can I recast to another type in a material shader (or can I?). Is there a way I can leverage the cost-savings of the switch, but have it pivot off a non-bool value? Is there an alternative method to do this?

BlendMateriaAttributes, LERP and other functions don’t seem to work like the switch (expected) so I am wondering if there is a way to put something into a material that I can use to make execution-paths shorter in certain cases vs using different materials/LODs.

Does not work that way, unfortunately.

Bummah! Given what I am trying to accomplish are there any tricks to make execution shorter, branch or otherwise things of that nature?