Skip to content

Shader and Material stuff for "Material editor 2099" #1

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

Merged

Conversation

Exter-N
Copy link
Contributor

@Exter-N Exter-N commented Aug 24, 2023

⚠️ Due to some of the refactors, this PR is not backwards-compatible.

Shader Packages

  • Rework the Items field into a Selectors dictionary to more closely match how the game handles it ;
  • Add various stuff to manipulate shader selectors (which are calculated by Σ keys[m][n] * Pow(31, m + n)) ;
  • Add a flag that allows determining after construction whether the shaders were disassembled.

Materials

Color Sets

  • Fix the tile set assignment formula (though, due to rounding in the shader, it won't change anything in practice) ;
  • Refactor ApplyDyeTemplate ;
  • Add functions to turn the structures into Span<Half> ;
  • Add logic to generate a ColorSet and/or a ColorDyeSet with sensible defaults from scratch ;
  • Improve parsing (in some cases, the parser could mistake a file with color sets without rows but with lots of samplers and/or constants for a file with color sets with rows).

Miscellaneous

  • Add functions to retrieve various structures from the material (constants, samplers, keys, color (dye) sets), generating them as needed ;
  • Add a clone function that creates a deep copy of the loaded file, completely detached from the original ;
  • Add a garbage collection function that finds and removes all unused and no-op elements from the file.
  • Note: The "Clone + GC + Write" pattern is used in "Material editor 2099" to support a paradigm where, when the user switches shaders, the editor retains all the data for the previous shader in case the user changes their mind, or switches to a 3rd shader that uses some data the 1st used but not the 2nd, and discards everything superfluous on saving.

@Ottermandias Ottermandias merged commit 07c001c into Ottermandias:main Aug 25, 2023
@Exter-N Exter-N deleted the feature/material-editor-2099 branch August 25, 2023 14:30
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