Skip to content

Fix transparent primitives drawing nothing, and translucent drawing coming out darker - #312

Open
Causeless wants to merge 4 commits into
developmentfrom
fix-primitive-transparency
Open

Causeless wants to merge 4 commits into
developmentfrom
fix-primitive-transparency

Conversation

@Causeless

@Causeless Causeless commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two fixes for translucent drawing on the GPU renderer.

PrimitiveMan:DrawPrimitives(transValue, primitivesTable) drew nothing. The Transparency blend mode passed its blend amounts straight into the rteColor uniform. That included the alpha amount it ignores, which this overload always sets to 0. Every transparent primitive came out fully transparent, so stock callers like Decision Day's region boxes, the Scanner ping and the Automover controller's info box never showed. Transparency now draws at full colour with alpha = 1 − the average RGB amount, rounded to steps of 5 as before. The other blend modes are unchanged.

The other blend modes used their amounts backwards. Each amount went straight into the colour, so Screen, Multiply, Invert and the rest drew nothing at 0 and their full effect at 100. That is the reverse of the documented behaviour and of 6.2.2. The RGB amounts also scaled the colour, where 6.2.2 ignored them for these modes, and Screen ignored the alpha amount altogether. They now use only the alpha amount, as documented: 0 is the full effect and 100 is invisible, rounded to steps of 5. Invert and Dissolve take it as their alpha. The other blend equations take the colour premultiplied by it, which mixes the effect into the background by that much.

Translucent drawing came out darker than it should. Alpha blending lowers the backbuffer's alpha under anything translucent. Two copies of the frame then blended by that alpha onto a cleared buffer:

  • the post-processing copy, which disables blending but was only drawn after blending was turned back on for the glows;
  • in split-screen, the copy of each player screen into the backbuffer.

A half-transparent primitive came out 25% too dark, and darker still in split-screen. Both copies now draw without blending. Opaque pixels are unchanged, and translucent ones are a plain mix.

Testing

Screenshots from Decision Day in a muted test copy:

  • First row is on development, the rocket primitive shows nothing
  • Second row is after the drawing nothing was fixed
  • Third row was after the translucent darkening was fixed
image

Causeless and others added 3 commits October 25, 2026 19:59
The Transparency blend mode put its blend amounts straight into the
rteColor uniform, including the alpha amount it ignores, which is always
0 from DrawPrimitives(transValue, ...). Every transparent primitive came
out fully transparent, so stock callers like Decision Day's region boxes,
the Scanner ping and the Automover controller's info box never showed.

Use the RGB amounts as the alpha instead, rounded to the blend step as
the software renderer did, so 0 is opaque and 100 is invisible.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Alpha blending also lowers the backbuffer's alpha wherever something
translucent is drawn. Two copies of the frame then blended by that alpha
onto a cleared buffer, which darkened those pixels: by 25% for a
half-transparent primitive, and twice over in split-screen.

- The post-processing copy disabled blending, but its quad was only
  drawn after blending was enabled again for the glows. Flush it while
  blending is still off.
- The split-screen copy of each player screen into the backbuffer now
  draws without blending too.

Opaque pixels are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The GPU renderer put each blend amount straight into the color uniform,
so the modes other than Transparency drew nothing at 0 and their full
effect at 100, the reverse of the documented behavior and of 6.2.2. The
RGB amounts also scaled the color, where 6.2.2 ignored them for these
modes, and Screen ignored the alpha amount altogether.

Use only the alpha amount, 0 being the full effect and 100 invisible,
rounded to the blend step. Invert and Dissolve are alpha blended and take
it as the alpha. The other blend equations take the color premultiplied
by it, which mixes the effect into the background by that much.

Difference still draws the primitive minus the background rather than
their difference, so it doesn't fade out; that's a separate issue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread CHANGELOG.md Resolved
All three bugs came from the GPU renderer, which was written after 6.2.2,
so none of them is a change from the last release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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