Implement fast approximate trig methods #5014
TechnoPorg
started this conversation in
Engine Core
Replies: 1 comment
-
See discussion in godotengine/godot#32015. The consensus is that those approximations aren't worth it on modern CPUs, especially for game logic which isn't that performance-critical. (If it is, you can use C# or GDExtension.) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In many common game engine tasks, notably rendering and physics, trigonometric functions are used extensively. However, they can be quite slow to calculate, compared to other mathematical operations.
I suspect that in a number of cases, such as for rendering tasks that only affect one frame, perfect accuracy is not necessary for these functions. I propose that new functions be implemented in Godot that calculate about the right output, much more quickly. This would be similar to the use of the fast inverse square root technique, which isn't perfect, but is good enough that it doesn't have a negative impact on the function of the engine, while providing a nice performance boost.
I haven't done extensive research into the use or performance of standard trig functions, but if they have hardware implementations, it would likely be quite difficult to outperform that in any significant way. This idea may also just not be well suited to Godot, but I feel that it's worth considering.
I'm not entirely sure what the best technique would be for implementing a fast approximate trig method. Perhaps sampling from a simple type of mathematical curve that can be pretty closed fitted to the output of a trig function, like a Bezier, would work, or computing just the first few terms of the Taylor series for sine and cosine.
Beta Was this translation helpful? Give feedback.
All reactions