embeddedt / embeddium

An open-source client performance mod for Minecraft (based on Sodium 0.5.8) prioritizing reliability & mod compatibility
https://legacy.curseforge.com/minecraft/mc-mods/embeddium
GNU Lesser General Public License v3.0
189 stars 65 forks source link

Altered UV breaks texture alignment #147

Closed leagris closed 8 months ago

leagris commented 8 months ago

Bug Description

On some blocks, UV mapping is modified/stretched and it breaks alignment like here:

Normal rendering without Embeddium, UV mapping is not modified and texture correctly align across blocks: image

With Embeddium, UV mapping stretches the texture, and now textures is not aligned across blocks: image

Reproduction Steps

Place multiple connected Pipez pipes and see the west side of it has UV distortion that prevent correct matching of the texture across pipe blocks.

Log File

irrelevant

embeddedt commented 8 months ago

Please attach the log file, it contains important information (like the size of the texture atlas, which is relevant here). Also, what MC version does this occur on?

The issue is probably caused by Sodium using 16-bit texture coordinates. I can increase the precision of the texture coordinates in Embeddium's non-compact vertex format but I want to be sure it will fix the issue first.

On Mon., Dec. 18, 2023, 5:05 p.m. Léa Gris, @.***> wrote:

Bug Description

On some blocks, UV mapping is modified/stretched and it breaks alignment like here:

Normal rendering without Embeddium, UV mapping is not modified and texture correctly align across blocks: image.png (view on web) https://github.com/embeddedt/embeddium/assets/1111474/bcac76ef-0bbe-46ba-87e8-9569120f6f11

With Embeddium, UV mapping stretches the texture, and now textures is not aligned across blocks: image.png (view on web) https://github.com/embeddedt/embeddium/assets/1111474/704ded03-6ecc-458e-b565-b8543a186718 Reproduction Steps

Place multiple connected Pipez pipes and see the west side of it has UV distortion that prevent correct matching of the texture across pipe blocks. Log File

irrelevant

— Reply to this email directly, view it on GitHub https://github.com/embeddedt/embeddium/issues/147, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKHTVADWALIYENVZDCHPJCTYKC43XAVCNFSM6AAAAABA2GKTSWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA2DONJTHE4TCMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

leagris commented 8 months ago

Please attach the log file, it contains important information (like the

Here it is: https://mclo.gs/WuqmjT7

I think it may be a side-effect of shrinking the UV slightly shorter than the icon to prevent blurring-in transparent pixels at edge of quads when quad coordinates are shorter than the rendering cuboid boundaries. This indeed get ride of transparent thin artifacts at edges, but it has the side-effect of stretching the texture. I think altering the UV mapping of block models would be better default to off and turned-on on a per modid basis in some config file. Some AE2 blocks also have this very same issue (Crafting CPU, Crafting Storage at least have this same problem with distorted UV-mapping when embeddium/rubydium is installed.

embeddedt commented 8 months ago

I think it may be a side-effect of shrinking the UV slightly shorter than the icon to prevent blurring-in transparent pixels at edge of quads when quad coordinates are shorter than the rendering cuboid boundaries.

This definitely sounds like it won't work correctly with reduced texture precision. I'll try to reproduce it locally and see what I can do.

I think altering the UV mapping of block models would be better default to off and turned-on on a per modid basis in some config file.

It cannot be done on a per-mod basis, as it's a side effect of using a compressed vertex format that takes up less memory (and therefore does not have the precision to store the UV shrinkage). There are many advantages to using that format, so I don't plan to disable it by default. However I can certainly make sure that these types of textures are drawn correctly when users explicitly disable it in video settings.

embeddedt commented 8 months ago

Does https://nightly.link/embeddedt/embeddium/workflows/build-snapshot/20.1%2Fforge/Embeddium.zip fix this if you disable "Compact Vertex Format" in video settings?

leagris commented 8 months ago

Does https://nightly.link/embeddedt/embeddium/workflows/build-snapshot/20.1%2Fforge/Embeddium.zip fix this if you disable "Compact Vertex Format" in video settings?

Yes it does fix the issue, perfect !

embeddium-options.json

{
    "performance": {
        "use_compact_vertex_format": false,
    }
}

Perfect! image

leagris commented 8 months ago

As soon as re-adding oculus-mc1.20.1-1.6.13 it breaks again; Possibly oculus would need support for this.

embeddedt commented 8 months ago

Iris & Oculus are hardcoded to only support the compact vertex format. I can't do anything about that from my end, unfortunately.

embeddedt commented 8 months ago

An issue was discovered in how Sodium encodes textures for the compact vertex format, and that is what causes this bug when it's enabled. I've backported the fix for the next release, but it requires an Oculus update to not break when shaders are enabled.

embeddedt commented 8 months ago

Issue is fixed for both vertex formats as of 0.2.14, so it will work correctly with Oculus installed once Oculus makes another release (I provided the necessary patch to them).