Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify overbright implementation #1406

Merged
merged 2 commits into from
Nov 14, 2024
Merged

Commits on Nov 13, 2024

  1. Use half float instead of int16 for color buffer

    This allows us to use values greater than 1 in the color buffer and as
    the color output of a fragment shader, so we don't have to worry so much
    about values getting clamped in multi-stage shaders.
    
    Co-authored-by: Thomas Debesse <dev@illwieckz.net>
    slipher and illwieckz committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    e5a4caf View commit details
    Browse the repository at this point in the history
  2. Simplify full-range overbright implementation

    Multiply lightmaps and light grid by the light factor right when they
    are used, instead of the elaborate canceling system. Vertex light
    multiplication in lightmapped stages is handled by the scaling of the
    white image lightmap (treated as 4.0). Various bugs will be fixed, since
    the canceling approach relied on detecting an enormous amount of special
    cases and not all of them were handled.
    
    In a few places there can be issues with intermediate color buffer values
    exceeding 1.0, but this is worked around (on reasonably good hardware) by
    the previous commit setting up an RGBA16F framebuffer. When limited to
    RGBA8 framebuffers, as can be tried with r_highPrecisionRendering 0,
    this rewrite is a mixed bag. In some places it leads to clamping in the
    color buffer (example: Pulse viewpos 4822 -1312 -1314 98 13), while in
    others it improves results due to the effective 2 extra bits of
    precision in the framebuffer (example: Procyon viewpos -955 3443 276 94
    7).
    
    There are a few cases where lightmap/lightgrid scaling doesn't apply
    that required special handling:
    - For intermediate stages of light styles, the already-existing
      detection of STYLELIGHTMAP and STYLECOLORMAP is used. For these stage
      types u_Color is scaled by the light factor. Example: metro-b1-2
      viewpos -1172 627 107 94 -21.
    - For non-lightmapped vertex-lit surfaces, u_ColorModulate is scaled
      by the light factor. Example: station15 small plants.
    - For fullbright lightmapped stages, the light factor is set to 1.
      Example: Procyon star chart.
    
    Some bugs (in non-clamped overbright mode) that are fixed by this commit:
    - Non-lightmapped vertex-lit surfaces (like the station15 plants) are
      now scaled by the light factor as they should be.
    - Procyon star chart is no longer too dark with material system.
    - Glowmap-like stage implemented with q3 syntax in a control panel
      shader are no longer wrongly overbright-scaled, causing visual noise.
      zittrig-arena viewpos 1201 -301 -338 87 0
    
    Co-authored-by: Thomas Debesse <dev@illwieckz.net>
    slipher and illwieckz committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    344932f View commit details
    Browse the repository at this point in the history