MCRcortex / voxy

An LoD rendering mod for minecraft
https://modrinth.com/mod/voxy
156 stars 31 forks source link

Colormap breaks for textures with custom name #53

Open JustAlittleWolf opened 5 months ago

JustAlittleWolf commented 5 months ago

When using a texture with a custom name, the colormap doesn't get applied on LOD chunks.

fm1hB1F Voxy_Bug.zip

grass_block.json
{
    "variants": {
        "snowy=false": {
            "model": "block/grass_block_issue"
        },
        "snowy=true": {
            "model": "block/grass_block_noissue"
        }
    }
}
grass_block_noissue.json

{"parent":"block/grass_block","textures":{"top":"block/grass_block_top"}}
grass_block_issue.json

{"parent":"block/grass_block","textures":{"top":"block/grass_block_top_custom_texture_name"}}

The snowy blocks (purple line in image) have their colormap applied fine in the LOD chunks, however the grass block texture with a custom name does not get it's colormap rendered properly.

The used texture pack with only the required files for the bug to happen is attached as well.

This might be what causes https://github.com/MCRcortex/voxy/issues/32

JustAlittleWolf commented 5 months ago

Update: this only seems to happen when the texture has color itself, if you change the texture to be grayscale (like the grass textures that minecraft uses) this does not happen.

ebo2022 commented 5 months ago

I think either a similar problem or the same issue is happening with BetterEnd. Voxy doesn't seem to apply any coloration to the aurora crystals.

Can confirm this isn't a BetterEnd or BCLib-specific issue. I checked and BCLib just hooks into Fabric API's block color registry to register its color providers. Also, the block uses the regular blockstate/model system and no custom renderers or anything 2024-06-20_12 51 06 Vanilla chunks are on the left and Voxy LODs are on the right

KawaiiSelbst commented 4 months ago

I've been messing with the code for a couple of days now, and I'm trying to fix it. I have found the reason for this and I know how to fix it, but I do not yet know exactly how to do it in the code.

This is because there are quads in the fragment shader quads.frag checks whether the color is in grayscale or not before applying the color. If you remove this check, then the colormaps are superimposed as needed, except that the side blocks of grass are tinted not only on the upper part but also on the part with the dirt.

It seems that this is due to the fact that in the renderFaces method of ModelTextureBakery to a var

var model = MinecraftClient.getInstance()
                    .getBakedModelManager()
                    .getBlockModels()
                    .getModel(state);

in https://github.com/MCRcortex/voxy/blob/a9c079661d4cd2396b6a4986d6df7594a8a5d70d/src/main/java/me/cortex/voxy/client/core/model/ModelTextureBakery.java#L111

The texture gets in immediately with the overlay. You need to somehow get the base model and the grass_block_side_overlay texture separately, first put a color on it, and then bake it into the grass_block model, then you need to check abs(colour.r-colour.g) < 0.02f && abs(colour.g-colour.b) < 0.02f in https://github.com/MCRcortex/voxy/blob/a9c079661d4cd2396b6a4986d6df7594a8a5d70d/src/main/resources/assets/voxy/shaders/lod/gl46/quads.frag#L30 disappears by itself, because the block of grass in vanilla minecraft is the only texture with overlay