Skip to content

Increase fps for most scenes to 40#25

Merged
SCratORS merged 12 commits intoSCratORS:mainfrom
Doctoror:increse-fps
Feb 11, 2024
Merged

Increase fps for most scenes to 40#25
SCratORS merged 12 commits intoSCratORS:mainfrom
Doctoror:increse-fps

Conversation

@Doctoror
Copy link
Copy Markdown
Contributor

@Doctoror Doctoror commented Feb 11, 2024

Increase FPS to 40 for all scenes except:

  • eyes
  • firework

FPS is increased by generating new matrixTransform and colorTransform frames by linear averaging between
existing frames. Example:

Let's say we had animation that starts with following matrixTransform frames:

[0f, 1f, 2f, 3f],
[2f, 3f, 4f, 5f]
[     ...      ]
[..last frame..]

Then, one more frame between each matrixTransform frames pairs is inserted:

[0f, 1f, 2f, 3f],
[1f, 2f, 3f, 4f],
[2f, 3f, 4f, 5f]
[     ...      ]
[..last frame..]

This way, we get 2x - 1 matrixTransforms and colorTransforms, which means that we can increase from
20 fps to 40 without increasing speed.

This same logic could be used to generate frames for 60 FPS, but I find that it was too heavy on render thread, it could not maintain 60 fps and dropped frames on emulators so I decided to stick with 40.

Now, every scene will have its own FPS setting.
Previously mentioned scenes will remain at 20.

For scenes that have textures, no new textures were generated, instead, animCounterSkip is used to skip animCounter increment every second frame. Looks good.

You can switch and review individual commits if you find this easier to review like this.
Some scene transforms were to large to compile, they were moved to assets.
File structure is explained in array reader class javadoc.

FPS is increased by generating new frames by linear averaging between
existing frames. Example:

Let's say we had animation that starts with following frames:
[0f, 1f, 2f, 3f],
[2f, 3f, 4f, 5f]
[     ...      ]
[..last frame..]

Then, one more frame between each frame pairs is inserted:
[0f, 1f, 2f, 3f],
[1f, 2f, 3f, 4f],
[2f, 3f, 4f, 5f]
[     ...      ]
[..last frame..]

This way, we get `2x - 1` frames, which means that we can increase from
20 fps to 40.

Now, every scene will have its own FPS setting.
Previous scenes will remain at 20 until all of them are improved.
@SCratORS SCratORS merged commit 5843819 into SCratORS:main Feb 11, 2024
@SCratORS
Copy link
Copy Markdown
Owner

it probably makes sense to transfer all transformation matrices to assets. But I do not know how to do it :-)

@Doctoror Doctoror deleted the increse-fps branch February 11, 2024 19:59
@Doctoror
Copy link
Copy Markdown
Contributor Author

I was thinking about that too. Not sure if it has any benefits. The apk size would probably be the same and the arrays will not be readable unless you read that binary file and println the contents.

I did not commit the script I used to generate the binaries but I can do it.
I run it as a unit test but I am not sure how to add unit tests for your project.

This project has unconventional paths for source sets.
Usually main source sets are in

[moduleName]/src/main/java
[moduleName]/src/main/res

and tests go to

[moduleName]/src/test/java

I don't know how your source sets are configured because you commited root folder inside root_dir instead of moving this dir under root project directory.

I can open a PR with conventional setup if you like.
This means all sources will be moved to new location, and it will be harder to look for git history of individual files from IDE.

@SCratORS
Copy link
Copy Markdown
Owner

I am not sure that I can correctly redo the directory structure in a git project.

@SCratORS
Copy link
Copy Markdown
Owner

perhaps it makes sense for me to give you access to the repository?

@Doctoror
Copy link
Copy Markdown
Contributor Author

Doctoror commented Feb 11, 2024

You don't need to give me access for this. I can open a pull request with new directory structure.
Let me try that.

@SCratORS
Copy link
Copy Markdown
Owner

Yes, of course

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants