Skip to content

Fix grass block sides appearing white with custom resource packs (fixes #203, #373) - #704

Open
anton-sjoberg wants to merge 4 commits into
MCRcortex:263from
anton-sjoberg:263
Open

anton-sjoberg wants to merge 4 commits into
MCRcortex:263from
anton-sjoberg:263

Conversation

@anton-sjoberg

@anton-sjoberg anton-sjoberg commented Sep 30, 2026 •

Copy link
Copy Markdown

Summary of Changes

Fixes #203
Fixes #373

This PR resolves issues where grass block side faces render white or display white/light-colored bands when using custom resource packs (e.g., Whimscape, Faithful) or at distant LOD mip levels.

Problem & Root Cause

Previously, quads.frag attempted to detect tinted grass overlay pixels using a heuristic grayscale test:
glsl if (abs(tintTest.r - tintTest.g) < 0.02f && abs(tintTest.g - tintTest.b) < 0.02f) { doTint = true; }
This heuristic suffered from multiple failure modes:

  1. Custom Resource Packs: Many packs (such as Whimscape, Faithful, or packs with subtle saturation/pebbles in dirt) do not use pure grayscale values for the grass overlay or dirt background, causing the heuristic to fail and leaving grass sides un-tinted (white).
  2. Mipmapping & Downsampling: Downsampling blends tinted overlay pixels with dirt pixels, producing non-gray intermediate RGB values and resulting in visible white bands along grass edges at LOD distances.
  3. Shader Performance: An extra texture fetch ( extureLod(blockModelAtlas, texturePos, 0)) was performed per fragment in quads.frag.

Solution

  1. Ground-Truth Tint Masking:
    • In ModelFactory.java, the exact grass overlay mask is captured during texture baking (partialTintMask).
    • For partial-tint faces, the alpha channel of the baked texture encodes the exact tint coverage (alpha = 255 for tinted grass fringe, alpha = 0 for untinted dirt).
    • Marked
      eedsAlphaDiscard = false for partial-tint faces so dirt pixels are never discarded.
  2. Mipmap Generation (MipGen.java):
    • During downsampling, the alpha channel smoothly transitions to represent fractional tint coverage.
    • solidify() is bypassed for partial-tint faces to ensure dirt RGB colors are preserved across all mip levels without color bleeding.
  3. Shader Modernization (quads.frag):
    • In both standard and Iris-patched shader paths, partial tinting now performs a smooth mix using the alpha channel:
      glsl colour.rgb *= mix(vec3(1.0), tintRGB, colour.a);
    • Guarded alpha discard so partial-tint quads are not prematurely discarded ( intingState() != 1u).
    • Removed the secondary texture fetch, reducing shader texture bandwidth.

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

Successfully merging this pull request may close these issues.

1 participant