inverseSqrt
Provides an efficient math function to calculate the inverse square root (1/sqrt(x)) of a number, with its most critical application being vector normalization.
Core Advantages
Its core advantage is performance, as it maps directly to the highly optimized `inversesqrt()` instruction on GPU hardware, which is faster than a `div(1, sqrt(x))` combination, while also making the code more concise and its intent clearer.
Common Uses
Calculating the multiplication factor for vector normalization, its primary use case.
Creating non-linear distance falloff effects, such as a 1/distance curve.
Generating radial gradients or shockwaves with a very bright center and rapid falloff.
In procedural geometry deformation, creating "gravity" or "black hole" stretching effects.
How to adjust
Adjust the value of its input node. As the input value approaches 0, the output value increases dramatically, creating effects like a bright central glow or a "burst". As the input value increases, the output rapidly decreases and then gently approaches 0.
Code Examples
1// Calculate the factor needed for normalization
2const invLength = inverseSqrt( myVector.dot( myVector ) );
3
4// Efficiently normalize the vector
5const normalizedVector = myVector.mul( invLength );