RandomMcSomethin / fallingleaves

MIT License
43 stars 20 forks source link

OptiFine changing color and textures of leaves #8

Open Fourmisain opened 3 years ago

Fourmisain commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

The ConnectedTexturesMod for Fabric has a very helpful description.

Apparently there are two different formats for Connected Textures:

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 commented 9 months ago

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"