Repository navigation
Effects: measure in pixels of the texture drawn, no textureSize needed - #1769
Merged
Merged
Conversation
Glow, outline, blur, drop shadow, chromatic aberration, pixelate and bloom
measure their widths, offsets and sizes in texels, and assumed a 256x256
texture (the screen for an outline or a bloom) unless given `textureSize`.
On any other texture they came out thinner or thicker than their docs say.
They now take the size of the texture they draw: the sprite's texture, the
render target of a camera's pass, a mesh's texture. The size is only
rewritten when it changes, so sprites from one texture still share a draw.
An explicit `textureSize`, `setTextureSize()` or `setUniform("uTextureSize")`
still wins, a clone keeps its original's behaviour, and a custom effect
declaring its own `uTextureSize` is never touched. No new API.
The Shader Effects example drops its hand-passed sizes (identical frames
on WebGL and WebGPU) and adds Shine, Squish, Color Matrix and Bloom.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SeWCkETjW35ZbXDRswV1hx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Glow, outline, blur, drop shadow, chromatic aberration, pixelate and bloom measure their widths, offsets and sizes in texels. Without a
textureSizethey assumed a 256×256 texture (the screen for an outline or a bloom), so on any other texture they came out thinner or thicker than their docs say ("in pixels" / "in texels"). Games worked around it by passing the texture size by hand.They now take the size of the texture they actually draw:
No new API. It's internal to
ShaderEffectand the batchers:textureSize,setTextureSize()orsetUniform("uTextureSize")still wins.ShaderEffectthat declares its ownuTextureSizeis never touched.What games see: widths now match the docs. A game that tuned its values around the old 256×256 guess will see them change; the changelog entry says so.
Example
The Shader Effects example:
Testing
New spec:
tests/effect-texture-size.spec.js(27 tests). It covers:15 deliberately broken versions of the code were all caught.
Mock fix:
webgpu_warm_keyshad a fake mesh texture lacking thegetTexture()every real mesh texture has.Full suite and lint: the full suite passes and
pnpm lintpasses.No regression in the demo: the Shader Effects demo was A/B'd against master's engine on a real GPU (WebGL and WebGPU), with 0 differing pixels.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SeWCkETjW35ZbXDRswV1hx