ok i got one to work and in the process of getting rid of unnecessarily expensive math operations (atan2 and asin) i accidentally seem to have come up with an almost exact replica of asin for the range 0 to 1 >_>
https://www.desmos.
@lisyarus i dunno! i started with `lerp(x, pi/2, pow(x, 8))` but the distortion wasn't strong enough near the edges cause the curve wasn't steep enough
then i remembered that there's a circle ease where the graph, well, looks distinctly like a circle, including a very steep angle at the end
so i decided to switch `pow(x,8)` with that term and sure enough, if i made it even steeper by raising it to the 2nd power it was almost identical
@lisyarus Not at my computer to try it out, but why isn't a simple Taylor expansion (which skips the sqrt in exchange for a few multiplications) enough? 🤔
@lisyarus @j_bertolotti I was thinking that the c factor could be computed with Taylor. Given that the actual best results are achieved with 1.95 and not 2, I was wondering how that would affect it.
@lisyarus For an arcsin you only need it to be good in the (-1,1) interval, and for a smooth analytic function Taylor converges pretty quickly. Again, might not be optimal, but it would have been my first attempt. @eniko
@lisyarus @j_bertolotti idk if this is at all relevant but my first attempt was lerp(x, pi/2, x^8) and no matter how big i made the exponent i couldnt get it steep enough to make the edges of the spherize filter look appropriately sharp
@lisyarus @j_bertolotti in @eniko's formula there's a linear interpolation by c^2 with c = 1 - sqrt(1 - x^2) and even better results are achieved with c^1.95, so I was wondering what happens with c^2 replaced by its Taylor expansion to order 8. Or given that it should only have even terms (so order 8 would be 4 terms) maybe even up to 6 or 7 terms
BTW as I'm now feeling better, I toyed around with the exponent to c and apparently the lowest error is found with exponent 1.9296 but yeah having to resort to the power function is URGH
Questo sito utilizza cookie per riconosce gli utenti loggati e quelli che tornano a visitare. Proseguendo la navigazione su questo sito, accetti l'utilizzo di questi cookie.
Nikita Lisitsa
in reply to Eniko Fox • • •Eniko Fox
in reply to Nikita Lisitsa • • •@lisyarus this thread
mastodon.gamedev.place/@eniko/…
Eniko Fox (@eniko@mastodon.gamedev.place)
Eniko Fox (Gamedev Mastodon)Nikita Lisitsa
in reply to Eniko Fox • • •Eniko Fox
in reply to Nikita Lisitsa • • •@lisyarus i dunno! i started with `lerp(x, pi/2, pow(x, 8))` but the distortion wasn't strong enough near the edges cause the curve wasn't steep enough
then i remembered that there's a circle ease where the graph, well, looks distinctly like a circle, including a very steep angle at the end
so i decided to switch `pow(x,8)` with that term and sure enough, if i made it even steeper by raising it to the 2nd power it was almost identical
j_bertolotti
in reply to Nikita Lisitsa • • •Nikita Lisitsa
in reply to j_bertolotti • • •Oblomov
in reply to Nikita Lisitsa • • •j_bertolotti
in reply to Nikita Lisitsa • • •For an arcsin you only need it to be good in the (-1,1) interval, and for a smooth analytic function Taylor converges pretty quickly. Again, might not be optimal, but it would have been my first attempt.
@eniko
Nikita Lisitsa
in reply to j_bertolotti • • •@j_bertolotti It will still struggle towards the end of the range. Here's the expansion up to x^11: desmos.com/calculator/1bai5gku…
Tbh my first idea would be to least-squares fit a polynomial
Arcsin taylor
DesmosEniko Fox
in reply to Nikita Lisitsa • • •Oblomov
in reply to Nikita Lisitsa • • •Nikita Lisitsa
in reply to Oblomov • • •Oblomov
in reply to Nikita Lisitsa • • •Diego Roversi
in reply to Oblomov • •Taylor expansion will be problematic at -1 or 1, because the derivative goes to infinity.
Even if you get a good approximation in value, discontinuities in first order derivative are usually visually appalling on screen.
Nikita Lisitsa likes this.
Oblomov
in reply to Diego Roversi • • •@diegor @j_bertolotti @lisyarus
oh damn, good point. And that's actually also probably the reason why @eniko's works so well for the asin (the derivative of asin being rsqr(1-x^2))
Oblomov
in reply to Oblomov • • •Eniko Fox
in reply to Oblomov • • •Oblomov
in reply to Eniko Fox • • •@diegor @j_bertolotti @lisyarus
It's more accurate basically everywhere 8-D
Greg Egan
in reply to Nikita Lisitsa • • •@lisyarus
Very nice!
And if you change π/2 to sgn(x) π/2 you get an equally good fit for all negative x values as well.
Eniko Fox
in reply to Greg Egan • • •