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

OptiFine changing color and textures of leaves #8

Open
Fourmisain opened this issue Jan 5, 2021 · 6 comments
Open

OptiFine changing color and textures of leaves #8

Fourmisain opened this issue Jan 5, 2021 · 6 comments

Comments

@Fourmisain
Copy link
Collaborator

toomanyleaves
This image shows an issue with certain resource packs using OptiFine (A Little Taste of Jerm V2.5 on picture).
OptiFine can render leaves with different textures depending on the biome.
The actual block color (from getBlockColors()) or texture (from getSprite()) does not seem change.

This probably means the only way to fix this is by reproducing how OptiFine remaps textures.

Maybe looking at Colormatic can help

Colormatic supports loading resource packs with Optifine custom colors files as-is.
Features include: Biome colormaps for water, foliage, underwater, underlava, sky, and fog (...)

though it does not say anything about textures and the colors might not be an issue at all.

@Fourmisain
Copy link
Collaborator Author

littlebitofprogess
Got it to work specifically for the birch leaves from A Little Taste of Jerm V2.5.
Still needs a way to list all custom texture mappings and texture caching also needs to change.

@Fourmisain
Copy link
Collaborator Author

Fourmisain commented Jan 22, 2021

Looking at the documentation, this is ridiculously complex.

There are multiple matching rules: matchTiles, matchBlocks and matching through the filename as a fallback.

Multiple .properties file can refer to the same block/tile and they will be processed in alphabetical order by filename.

There are shorthands, e.g. writing oak_leaves instead of minecraft:oak_leaves, writing 1-4 for tiles 1 2 3 4.
matchBlocks can have attached properties (e.g. minecraft:oak_stairs:facing=east,west:half=bottom).
tiles, which specifies the replacement tiles, has 7 different formats just because.

Of course we only need to support a subset of this (full block texture replacements), but it also needs to not fail on all other cases.

@Fourmisain
Copy link
Collaborator Author

The ctm branch is feeling pretty mature now.
It can detect when OptiFine's Connected Textures are enabled/disabled and it correctly maps biome+block id to the remapped texture - at least for A Little Taste of Jerm V2.5 where I tested Birch Leaves in Jungle biome.

There's still a lot of open questions and it needs more testing on different resource packs.

@Fourmisain
Copy link
Collaborator Author

It's not just Connected Textures, Custom Colors affect leaf colors as well.

The Swamp Colors option also changes the given color if turned off - though that seems to only be an optimization, so no need to support it.

@Fourmisain Fourmisain changed the title OptiFine changing textures of leaves OptiFine changing color and textures of leaves Jan 27, 2021
@Fourmisain
Copy link
Collaborator Author

The ConnectedTexturesMod for Fabric has a very helpful description.

Apparently there are two different formats for Connected Textures:

  • The OptiFine/MCPatcher format (where "CTM" stands for Connected Texture Map/Mapping)
  • The ConnectedTexturesMod format

ConnectedTexturesMod for Fabric is obviously for the latter; for the first, there's Connected Block Textures.

As mentioned previously, there's also Colormatic for OptiFine/MCPatcher's Custom Colors.

I'm not sure if any of those 3 mods are compatible with the way we detect colors (TODO: test), but if they are and it's just OptiFine that's incompatible, it's probably not worth supporting it, seeing all the effort that's being done to replace every aspect of OptiFine.

The mods are all GPL licensed, so it's not as easy as getting inspired by their code, but maybe there is/will be an API we could use.

@Fourmisain
Copy link
Collaborator Author

Fourmisain commented Dec 11, 2023

Ported the old code with some adjustments onto the ctm2 branch and made a test release.

BetterVanillaBuilding seems like a good pack to test on.

Maybe shipping the code and fixing the errors that pop up will turn it into something usable.
Though probably not over the holidays.

edit: 2nd test release fixing the handling of ids like "DarkForest"

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

No branches or pull requests

1 participant