Skip to content

GL forward shader's texture-unit contract is unimplemented; lighting pass leaves GBuffer bound... #158

Description

@CanReader

assets/shaders/default_shader_gl.frag:137-139, :149, :170;
src/Graphics/OpenGL/OpenGLIBL.hpp:29-31; src/Graphics/OpenGL/OpenGLRenderer.cpp:1078, :1073-1076, :835-843, :679

Extends findings #15/#16/#17 with the sampler-unit half of the same contract break.
default_shader_gl.frag is the shader every default material gets (src/Scene/GameObject.cpp:140,
src/Assets/ModelLoader.cpp:449). Declared vs actually bound:

Resource Shader declares Renderer binds
IBL (irradiance/prefilter/BRDF) units 7/8/9 (:137-139) units 14/15/16 (OpenGLIBL.hpp:29-31)
SSAO unit 10 (:149) unit 13 (OpenGLRenderer.cpp:1078)
sampler2DShadow unit 11 (:170) unit 3 (:779, :1091)

Not one matches. Worse, the pass pair deferred-lighting → forward/transparent leaves units 8-11 bound to
GBuffer attachments (:1073-1076), so the forward shader's unit-11 sampler2DShadow reads
m_gbufferDepth: which has no GL_TEXTURE_COMPARE_MODE set (:835-843). Sampling a non-compare
texture through a sampler2DShadow is undefined per GL 4.5 §8.22.

This is live, not dormant: ShadowMapEnabled is driven from m_shadowPassEnabled (:679), so the shader
does execute the shadow fetch.

Severity: corruption (undefined GL behavior on every forward draw).

Found by a full audit of the graphics layer. Assessed severity: corruption.

Activity

  1. added this to the 0.1 Stability milestone on Sep 4, 2026
  2. added
    bugSomething isn't working
    area: renderingRenderer, shaders, post processing
    backend: openglSpecific to the opengl backend
    priority: criticalCrash, data loss, or blocks other work
    visualIncorrect or degraded rendering output
    on Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: renderingRenderer, shaders, post processingbackend: openglSpecific to the opengl backendbugSomething isn't workingpriority: criticalCrash, data loss, or blocks other workvisualIncorrect or degraded rendering output

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions