-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed-point trig approximations without tables #32
Comments
There are other approximations for sin/cos/tan I tried to work with in the past but wasn't able to finesse them enough to make them work for Doom without visual issues. Giving that another shot. |
See: http://www.coranac.com/2009/07/sines/
|
started with commit e5311d8 |
I have an approximation for finetangent, still finessing the conversion of it from floating point to fixed point, I need to work out how to scale/transform things |
Finetangent approximation with commit a1212bb floating-point for now, need to do more work on converting to fixed-point |
Doom uses lookup tables for fixed-point trig approximations.
I did an experiment in the past using cached vs uncached accesses for these and it performs the same which suggests to me if we can find a fast way to approximate in code, not using memory, it wont hurt anything and it might improve performance.
They are currently always accessed uncached in 64Doom. These accesses are hundreds of cycles.
Some of these may be able to be approximated in other ways.
I started by looking at the simplest case of tantoangle.
It can be fit with the following with acceptable results:
#define tantoangle(x) ((angle_t)((-47*((x)*(x))) + (359628*(x)) - 3150270))
3 multiplies, 1 add, 1 sub. Not hundreds of cycles.
Looking at the rest of the tables to see what can be done.
The text was updated successfully, but these errors were encountered: