I see a lot of shader code on the internet where PI is simply defined as an approximate decimal near the top of the code. In general I try to let computers take care of doing math for me instead of approximating values with constants (i.e. (1./3.
) instead of 0.333
)
Pi seems like one of those things that would be easier to just use intrinsic functions like the radians()
for.
I've heard that creating and destroying variables can be expensive in shader world, and I'm curious what the tradeoffs might be for using radians(180)
inline in code instead of
#define PI 3.1415926538
at the top and then PI
inline.
Thanks!