Improved transitions (#642)

* Improved transitions

Code quality improvements.
Shape transitions now all scale down to 0 instead of 16 (mario and bowser).
Ease in was added which leads to far smoother transitions.
HD_TRANSITIONS define added, makes use of the tex edge render mode to deliver smooth transition textures.
lerpf was added to math utils.

* Cleaner textures, rounding only during vertex creation

* Another attempt

* cozies naming suggestion

* Improvements and suggestions

SHARP_TRANSITION_TEXTURES is now off by default (I still think the textures for it could be improved).
lerpf, to_smoothstop, smoothstart, smoothstop and smoothstep have all been added.
make_vertex has been inlined.
make_simple_vertex has been added (colourless vertex).
Transition colors (and canon colors) are now defined using primative colour instead of setting individual vertices color´s.
Transition´s now use smoothstep (ease-in-out) instead of ease out only.
Naming has been improved.

* Proper function inling and removal of GBI_FLOATS variant of make_vertex and make_simple_vertex

* More requested changes

* Accidental final new line removal fixed

* Comment about pop in fix.

* Comment fix

The issue with writing comments for stuff is when you want to change code later on.
This commit is contained in:
Lilaa3 authored and GitHub committed 2023-08-29 08:57:32 -05:00
1 parent 1e0498ba68
commit 5e9f8c7ee0
13 files changed
+369 -239

No files matched your search

+26
View File
@@ -598,4 +598,30 @@ ALWAYS_INLINE f32 remap(f32 x, f32 fromA, f32 toA, f32 fromB, f32 toB) {
return (x - fromA) / (toA - fromA) * (toB - fromB) + fromB;
}
ALWAYS_INLINE f32 lerpf(f32 from, f32 to, f32 amount) {
return (from + (to - from) * amount);
}
ALWAYS_INLINE f32 to_smoothstop(f32 x) {
f32 sq = sqr(1.0f - x);
return 1.0f - sq;
}
// Commonly known as ease-in
ALWAYS_INLINE f32 smoothstart(f32 from, f32 to, f32 amount) {
return lerpf(from, to, sqr(amount));
}
// Commonly known as ease-out
ALWAYS_INLINE f32 smoothstop(f32 from, f32 to, f32 amount) {
return lerpf(from, to, to_smoothstop(amount));
}
// Commonly known as ease-in-out
ALWAYS_INLINE f32 smoothstep(f32 from, f32 to, f32 amount) {
amount = sqr(amount) * (3.0f - 2.0f * amount);
return lerpf(from, to, amount);
}
#endif // MATH_UTIL_H