Skip to content

Shadow map is bound to texture slot 3: the roughness slot: on both DX11 and OpenGL #145

Open

Description

@CanReader

src/Graphics/DirectX11/DirectX11Renderer.cpp:189-190, :1203-1204;
src/Graphics/OpenGL/OpenGLRenderer.cpp:779-781, :1091-1093;
include/public/Runtime/Material.hpp:18; src/Graphics/Common/Material.cpp:37, :113

Both backends bind the shadow map to slot 3:

  • DX11: PSSetShaderResources(3, ...)
  • GL: GL_TEXTURE3

But every shader declares the shadow map at 11/12, not 3:

  • default_shader.hlsl:101: Texture2D roughnessTexture : register(t3); shadow map is t11/s1/s2 at :216-218
  • default_shader_gl.frag:89: roughnessTexture at binding 3; shadow bindings 11/12 at :170-171

And TEXTURE_SLOT_ROUGHNESS is 3 (Material.hpp:18), bound per draw at Material.cpp:37/:113.

Two consequences, both live:

  1. Nothing ever binds t11/t12 on either backend, yet ShadowMapEnabled is set to 1
    (DirectX11Renderer.cpp:1225, OpenGLRenderer.cpp:679): so CalcShadow runs against an unbound
    resource. Shadows are broken on DX11 and GL forward.
  2. Slot 3 is fought over per draw. A material with no roughness map samples the shadow depth texture as
    PBR roughness
    : wrong shading, varying with the light's view.

Corroborating evidence this is a known-but-unfixed issue: the GL renderer already carries a workaround
comment plus an unbind for exactly this collision at OpenGLRenderer.cpp:1005-1009: but it only covers the
GBuffer pass, not the forward pass.

Severity: corruption (wrong texture sampled as a material parameter) + visual (no shadows).

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

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
    backend: dx11Specific to the dx11 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: dx11Specific to the dx11 backendbackend: 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