Filter or exclude by custom material properties in toktx#1779
Open
FrostKiwi wants to merge 1 commit intodonmccurdy:mainfrom
Open
Filter or exclude by custom material properties in toktx#1779FrostKiwi wants to merge 1 commit intodonmccurdy:mainfrom
toktx#1779FrostKiwi wants to merge 1 commit intodonmccurdy:mainfrom
Conversation
Owner
|
Hi @FrostKiwi! The discussion in #1650 might be relevant, specifically adding a callback to the toktx() function... toktx({
filter: (texture) => checkSomeCondition(texture),
...
})... and compressing a texture only if the callback returns true. Most transforms use the pattern (regexp) option today, but I'm open to adding the filter (callback) option in more places when it makes sense. For an example, see: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR allows for to include or exclude textures from
toktxin thedocument.transformstep. It works specifically with blender custom properties (extrasin gltf lingo) and assumes them to be booleans.eg.:
I copied the code from
glTF-Transform/packages/functions/src/join.ts
Line 152 in f937abb
Motivation
Similar to the palletize function, I already pre-palletize in Blender and tag those materials for exclusion in texture compression and setting those to Nearest Neighbor, similar to function
pallete. But gltf-transformtoktxhas no way to check for custom properties, so right now I have to do some gymnastics with checking custom property with the JS API, then adding a Texture name & URI prefix only then to have thepatternRegEx do the exclusion.Right now I mark palletized materials:
to then prefix them with this cursed setup:
only to then exclude them from the processing
Either way, filtering by custom property seems like a natural extension to anything gltf processing related.
Issues
Imageis adata-block type, there exists no way in the Blender UI to set custom properties and setting it via the API doesn't work either, as the gltf exporter ignores it. Both things I'll try to look intotoktxalready has RegEx in the form ofpattern, so maybe that feature could be connected to custom property things, but I didn't come up with a good way and resorted toexcludeCustomTextureBoolandmatchCustomTextureBool