Skip to content

Fix glass block translucency: use CPU uniforms and auto-detect block.png layout - #467

Merged
ford442 merged 1 commit into
mainfrom
cursor/fix-glass-translucency-9725
Aug 1, 2026
Merged

Fix glass block translucency: use CPU uniforms and auto-detect block.png layout#467
ford442 merged 1 commit into
mainfrom
cursor/fix-glass-translucency-9725

Conversation

@ford442

@ford442 ford442 commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Problem

test.1ink.us/tetris-webgpu blocks looked much less translucent than go.1ink.us/tetris — not because of PHP, htaccess, or UTF-16 encoding.

Root causes

  1. Shader ignored CPU glass tuningfragmentMain.wgsl hardcoded glassMin=0.82 / glassMax=0.97 while viewMaterials.ts writes artist-tunable values (default ~0.30–0.78) into FragmentUniforms.reserved2. Glass centers stayed ~82–97% opaque, so the video portal barely showed through.

  2. Different deployed assetsgo.1ink.us serves a 768×768 block.png (~1 MB) loaded as a single tile. test.1ink.us serves the 2816×1536 atlas (~6.5 MB) with subregion extraction. Same Apache COOP/COEP headers on both hosts; PNGs are served as binary image/png.

  3. Wrong crop if atlas coords used on a single tile — subregion defaults target the middle tile of the 2816 atlas. Applying them to a 768 image crops a corner sliver and breaks metal/glass mask baking.

Fix

  • Read glassMin, glassMax, and Fresnel power from fUniforms.reserved2 in the authored sampling path.
  • applyBlockTextureConfigForImageDimensions() picks atlas vs full-image crop based on image size before tile extraction.

Testing

  • npm test — 213 passed
Open in Web Open in Cursor 

Summary by CodeRabbit

  • New Features

    • Improved block texture handling for both large and small images, including automatic sizing and sampling adjustments.
    • Enhanced glass rendering with configurable opacity and Fresnel effects.
  • Bug Fixes

    • Improved texture configuration selection based on the loaded image dimensions.

…png layout

The authored block shader hardcoded glass opacity to 0.82-0.97, ignoring
FragmentUniforms.reserved2 written by viewMaterials (intended 0.30-0.78).
Restore reading glassMin/glassMax/Fresnel power from uniforms so video can
show through the crystal center like the go.1ink.us reference.

Also auto-select atlas vs single-tile crop when block.png dimensions differ
(2816×1536 atlas vs 768×768 single tile) so wrong subregion coords do not
crop a corner sliver and break metal/glass masks.

Co-authored-by: Noah Cohn <noahc42@gmail.com>
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b67b1d08-d333-4b85-b801-b5a4a3814f91

📥 Commits

Reviewing files that changed from the base of the PR and between b6f1af0 and 8969ecc.

📒 Files selected for processing (3)
  • src/webgpu/blockTexture.ts
  • src/webgpu/shaders/wgsl/block/fragmentMain.wgsl
  • src/webgpu/viewPipelines.ts

📝 Walkthrough

Walkthrough

The change adds image-dimension-based block texture configuration during image loading and updates authored glass opacity to use configurable Fresnel parameters from shader uniforms.

Changes

Block rendering updates

Layer / File(s) Summary
Dimension-based texture configuration
src/webgpu/blockTexture.ts, src/webgpu/viewPipelines.ts
Images at least 2000 pixels on their maximum dimension use the default atlas configuration. Smaller images use single-tile sampling, full-image bounds, warmth detection, and adjusted metal thresholds.
Configurable authored glass opacity
src/webgpu/shaders/wgsl/block/fragmentMain.wgsl
The shader reads opacity bounds and Fresnel power from fUniforms.reserved2, clamps the power, and applies it to the edge Fresnel term.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: claude

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/fix-glass-translucency-9725

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ford442
ford442 marked this pull request as ready for review August 1, 2026 20:11
@ford442
ford442 merged commit c1b7ee6 into main Aug 1, 2026
3 checks passed
@ford442
ford442 deleted the cursor/fix-glass-translucency-9725 branch August 1, 2026 20:12
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.

2 participants