Salta al contenuto principale

in reply to Nikita Lisitsa

@lisyarus this thread

mastodon.gamedev.place/@eniko/…

in reply to Eniko Fox

Ohhhh. Nice approximation though! I wonder if there's something deep behind it or it's just a coincidence
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

in reply to Nikita Lisitsa

@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? 🤔
in reply to j_bertolotti

@j_bertolotti Taylor is typically only good around expansion point, but this approximation is good across the whole range
in reply to Nikita Lisitsa

@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.
in reply to Nikita Lisitsa

@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
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

in reply to Nikita Lisitsa

@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
in reply to Nikita Lisitsa

@lisyarus @j_bertolotti can you do the same but only for the c^2 part? (I would do it myself but currently impossibilitated)
in reply to Nikita Lisitsa

@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
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.

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))

in reply to Oblomov

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
Questa voce è stata modificata (5 ore fa)
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.

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.