Skip to content
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

Improve vertex color exporting significantly. #396

Closed
wants to merge 3 commits into from

Conversation

Hoikas
Copy link
Member

@Hoikas Hoikas commented Jan 15, 2024

This moves the piece-by-piece assembly of vertex colors from _export_geometry() into a one-stop-shop for getting the near final vertex colors as Blender knows them. Included in this is separating out the adjustment channels for wavesets - which are stuffed inside of vertex colors. It is now an error for a waveset to have a "col", "color", or "colour" vertex color layer. This is to prevent confusion. Wavesets now accept alpha (red), specularity (green), fresnel (blue), and edgelength (alpha) vertex color layers. The color values in these layers is averaged and output to the respective channels. Further, a default value for edgelength is now computed similar (but not exactly like) PlasmaMax's SetWaterColor() function. Artist input to the edgelength vertex color layer will modulate Korman's calculation.

CC @DoobesURU to verify nothing breaks and that waveset vertex alpha should now function as expected.

This is still a draft because I would like to do a pass over eliminating list comprehensions in the tight inner loop of _export_geometry(). Until Python 3.12, list comprehensions are actually implemented as function calls. I see 1 comprehension for every face and 1 comprehension for every vertex (!!!), which are major targets for performance optimization.

This moves the piece-by-piece assembly of vertex colors from
`_export_geometry()` into a one-stop-shop for getting the near final
vertex colors as Blender knows them. Included in this is separating out
the adjustment channels for wavesets - which are stuffed inside of
vertex colors. It is now an error for a waveset to have a "col",
"color", or "colour" vertex color layer. This is to prevent confusion.
Wavesets now accept alpha (red), specularity (green), fresnel (blue),
and edgelength (alpha) vertex color layers. The color values in these
layers is averaged and output to the respective channels. Further, a
default value for edgelength is now computed similar (but not exactly
like) PlasmaMax's `SetWaterColor()` function. Artist input to the
edgelength vertex color layer will modulate Korman's calculation.
This means that we gather up the UVs for every vertex in a temporary
tuple of tuples at the beginning of the export process. That's more
memory intensive, but it removes quite a bit of fiddling in the tighter
inner loops, so it's an overall win.
timeit indicates that this is a 43% improvement in performance.
@Hoikas Hoikas marked this pull request as ready for review January 15, 2024 18:17
@DoobesURU
Copy link
Contributor

At the moment, it appears to not only eat the textures, but we also have some sort of checker pattern on everything:
Desktop Screenshot 2024 01 15 - 18 58 18 26

@Hoikas
Copy link
Member Author

Hoikas commented Jan 16, 2024

Can you share a screenshot with the results before this PR?

@DoobesURU
Copy link
Contributor

Can you share a screenshot with the results before this PR?

Desktop Screenshot 2024 01 15 - 19 12 07 18
Should look like this.

@Hoikas Hoikas marked this pull request as draft January 16, 2024 00:17
@Hoikas
Copy link
Member Author

Hoikas commented Jan 16, 2024

This PR is almost completely wrong and needs to be revised significantly.

@Hoikas
Copy link
Member Author

Hoikas commented Jan 16, 2024

Closing in favor of rewriting the entire mesh converter, someday.

@Hoikas Hoikas closed this Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WaveSet Mesh Alpha Channel Wavesets don't appear to be utilizing alpha or passindex
2 participants