Add --opaque flag to screenshot for shaders that write alpha=0#2
Open
arghhhhh wants to merge 1 commit into
Open
Add --opaque flag to screenshot for shaders that write alpha=0#2arghhhhh wants to merge 1 commit into
arghhhhh wants to merge 1 commit into
Conversation
33ab64a to
efc643a
Compare
Many TD shaders write fragColor with alpha=0 (e.g. atmospheric/sky shaders that use the alpha channel for compositing flags, or simply omit it). The captured PNG is technically correct but most viewers composite RGBA over white when alpha=0, producing a blank image and hiding the actual RGB content. TD's own node-viewer thumbnail ignores alpha and shows RGB directly, so the disk capture doesn't match what the artist sees in the network. --opaque forces alpha=255 on every pixel of the returned PNG (Go-side, no handler changes), giving viewers and downstream tooling RGB that matches the in-network thumbnail. RGB channels are preserved as-is; no premultiplied-alpha unpacking. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
efc643a to
898d3f4
Compare
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.
Problem
Many TD shaders write
fragColorwithalpha = 0— atmospheric/sky shaders that use alpha as a compositing-flag, GLSL templates that simply omit the alpha component, etc. The captured PNG is technically correct (RGBA where A=0) but most image viewers composite RGBA over white when alpha=0, producing a blank-looking image and hiding the actual RGB content.This is especially confusing because TD's own node-viewer thumbnail ignores alpha and shows RGB directly — so the artist sees a perfectly-rendered sky in the network while the saved PNG looks completely white.
Concretely: I'm using
td-clito drive an LLM agent's visual feedback loop. The agent was repeatedly drawing wrong conclusions about a sky shader because everytd-cli screenshotcame back blank-white in its viewer, even though the shader was working fine. Sampling pixel values viatd-cli execconfirmed real RGB data with alpha=0.Fix
New
--opaqueflag onscreenshot:Implementation:
Test plan
go build ./cmd/td-cli/fragColor = vec4(scattering, 0.0)) — default capture renders white in viewers,--opaquereveals the real RGBscreenshot(no flag) produces byte-identical output to pre-patch--opaqueis a no-op for itNotes
Help text updated in
cmd/td-cli/main.go. Did not touchinternal/commands/init.go(the generated CLAUDE.md) — happy to add a line there if you'd prefer.🤖 Generated with Claude Code