When I was writing shaders by hand, there were plenty of cases where I would use Distance Squared, instead of Distance, due to the perceived performance benefits. If possible, I would square the value I was comparing the distance to, and use Distance Squared, to avoid needing to take the square root of the distance. But I notice there’s no existing node for doing Distance Squared in Shader Graph. (I could square the Distance node’s output, but there’s no performance benefit to that.)
So, I know I can easily make a subgraph to compute Distance Squared. But given how simple it is, and how it’s not just part of Shader Graph already, it made me wonder if there was some good reason why using Distance Squared isn’t all I imagine it to be.
Also, I wonder if my own hand-made subgraph for this will be as performant as the built-in Distance node. I just don’t know if the built-in nodes have any kind of optimization that makes them faster than what I can produce using a subgraph?
So,in short: Why is there no Distance Squared node? Is it not needed, from a performance perspective? Is this implementation going to be faster than just using the built-in Distance node?