Skip to content

perf(runner): pre-light water textures to drop the per-pixel colormap - #22

Merged
tannevaled merged 1 commit into
mainfrom
water-prelit
Jul 6, 2026
Merged

perf(runner): pre-light water textures to drop the per-pixel colormap#22
tannevaled merged 1 commit into
mainfrom
water-prelit

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Water/lava/slime (*) surfaces render at a fixed light level (0) with only a UV warp — the texture itself never changes. So pre-light each source texture once through the colormap (cm.LightIndex(0, texel)), cache it by source Pic, and draw the turbulent fill with cm=nil, skipping the per-pixel colormap lookup.

  • Bit-identical (same cm[0][texel]); verified in-browser (lq_e0m1) — water renders unchanged.
  • Turbulent-fill benchmark: pre-lit path is ~7% faster (519µs vs 557µs on a ~250k-px water quad).

A modest win — the colormap is one of ~10 per-pixel ops; the dominant turbulent cost is the intrinsic sin-LUT warp — but it's free and zero-risk (no render-package change, no visual change). Confirms per-pixel water is near-exhausted like the lightmapped fill; the remaining big lever is overdraw reduction.

🤖 Generated with Claude Code

Water/lava/slime ('*') surfaces render at a fixed light level (0) with only a
UV warp -- the texture itself never changes. So pre-light each source texture
once through the colormap (cm.LightIndex(0, texel)), cache it by source Pic,
and draw the turbulent fill with cm=nil, which skips the per-pixel colormap
lookup. The baked image is bit-identical (same cm[0][texel]); verified
in-browser (lq_e0m1), the water renders unchanged.

Adds a turbulent-fill benchmark showing the pre-lit path is ~7% faster on a
~250k-px water quad (519us vs 557us). It is a modest win -- the colormap is
one of ~10 per-pixel ops; the dominant cost is the intrinsic sin-LUT warp --
but it is free and zero-risk (no render-package change, no visual change).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit bc139e4 into main Jul 6, 2026
7 checks passed
@tannevaled
tannevaled deleted the water-prelit branch July 6, 2026 09:25
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