GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Put external lightmap atlases on the BSP lightmap contract by themuffinator · Pull Request #3 · themuffinator/FnQL

Conversation

@themuffinator

@themuffinator themuffinator commented Aug 6, 2026

Copy link
Copy Markdown
Owner

What

External lightmap atlases (maps/<mapname>/lm_XXXX) are now put on the same
contract that R_LoadLightmaps() gives lightmaps stored inside the BSP.
Applied identically to the OpenGL-lineage, Vulkan, and RTX renderers.

Why

These atlases never pass through R_LoadLightmaps() — they arrive via the
regular shader/image path and are recognised only by a name sniff in
R_CreateImage(). That hook set IMGFLAG_NO_COMPRESSION | IMGFLAG_NOSCALE | IMGFLAG_COLORSPACE_LINEAR, which left four gaps against lightmapFlags
(tr_bsp.c):

  1. No overbright shift. Internal lightmaps run through R_ProcessLightmap()
    -> R_ColorShiftLightingBytes(), applying r_mapOverBrightBits - tr.overbrightBits, the r_mapOverBrightCap normalisation, and
    r_mapGreyScale. External ones got none of it. With stock settings
    (r_mapOverBrightBits 2, tr.overbrightBits forced to 0 without hardware
    gamma) internal lightmaps come out up to 4x brighter — same map, different
    lighting depending only on where the lightmap is stored.
  2. IMGFLAG_COLORSHIFT was dead engine-wide. All three renderers implement
    the consumer in their upload paths; nothing ever set the flag. The only other
    mentions were commented-out lines directly above this hook.
  3. Light scale applied twice. Without IMGFLAG_NOLIGHTSCALE,
    R_LightScaleTexture() ran on external lightmaps, so r_intensity (and
    gamma, absent hardware gamma/FBO) hit them once in the lightmap and again in
    the diffuse texture they multiply against. Internal lightmaps skip it.
  4. |= let MIPMAP and PICMIP survive. Shader stages set both.
    IMGFLAG_NOSCALE does not help here — it only skips the power-of-two
    rounding, and the picmip block below runs regardless. r_picmip 3 shrank a
    lightmap atlas 8x, and mipmapping bled adjacent tiles together. Internal
    merged atlases are protected by a 2px border plus GL_CLAMP_TO_BORDER; a
    packed lm_ atlas has no such padding.

Reviewer notes

  • The upstream Quake3e line (preserved as a comment in the pre-change source)
    achieved this with a blunt = that also clobbered flags the caller had set.
    This uses an explicit &= ~(MIPMAP|PICMIP) plus |= instead, so clamp mode
    and other caller flags are untouched. Clamp mode and IMGFLAG_RGB are read
    from the local flags parameter rather than image->flags, so they were
    never affected either way.
  • IMGFLAG_LIGHTMAP is deliberately not set. It would only be half-applied:
    the GL renderer reads it from the local flags for TMU-1 placement, not from
    image->flags, so setting it here would change the internal-format choice
    without changing TMU assignment.
  • Out of scope: maps built with q3map2 -external still render fullbright.
    That scheme leaves LUMP_LIGHTMAPS empty and keeps lightmapNum >= 0 on
    surfaces, expecting the engine to load maps/<mapname>/lm_XXXX.tga itself.
    R_LoadLightmaps() never does, so tr.lightmaps stays NULL and $lightmap
    stages fall back to tr.whiteImage. It degrades safely — no crash — but the
    map is unlit. Adding that loader is a feature, not a correctness fix; happy to
    do it separately if FnQL should run stock Quake Live maps, which use that
    layout.
  • Pre-existing wart left alone: mutating image->flags after the caller computed
    flags makes every later R_FindImageFile() on the same lm_ texture trip
    the mixed-flags warning. PRINT_DEVELOPER only, inherited from upstream.

Testing

  • tests/untrusted_asset_bounds_tests.py and tests/ql_font_source_tests.py:
    59 passed, 29 subtests passed.
  • All three modified translation units syntax-check clean under MSVC (cl /Zs).
  • Not exercised on a live GPU against a map with external lightmap atlases.

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@themuffinator @claude
Put external lightmap atlases on the BSP lightmap contract
d1fdcd5
Lightmaps in maps/<mapname>/lm_XXXX arrive through the regular
shader/image path rather than R_LoadLightmaps(), so they missed the
treatment internal BSP lightmaps get. Bake the overbright/greyscale shift
that R_ProcessLightmap() applies to the internal ones, skip the intensity
and gamma light scale so it is not applied a second time on top of the
diffuse texture's, and keep the authored size. Mipmapping and picmip are
cleared because a packed atlas carries no border padding, so both blur and
bleed neighbouring lightmap tiles.

Applied identically across the OpenGL-lineage, Vulkan, and RTX renderers.

Co-Authored-By: Claude Opus 5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 6, 2026

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@themuffinator
themuffinator merged commit 66e080d into main Aug 6, 2026
@themuffinator
themuffinator deleted the fix/external-lightmap-parity branch August 6, 2026 18:15
themuffinator added a commit that referenced this pull request Nov 16, 2026
@themuffinator
Merge pull request #3 from themuffinator/fix/external-lightmap-parity
329b98f
Put external lightmap atlases on the BSP lightmap contract
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@themuffinator
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.