Skip to content

Reading radiance in sky shader in compatibility mode does not work #114606

@unixfan2

Description

@unixfan2

Tested versions

  • Reproducible with 4.5.1-stable

System information

Godot v4.5.1.stable (f62fdbd) - Ubuntu 22.04.5 LTS 22.04 on X11 - X11 display driver, Multi-window, 2 monitors - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 3050 - Intel(R) Xeon(R) CPU E5-1620 v2 @ 3.70GHz (8 threads) - 125.7 GiB memory

Issue description

  • Reproducible with 4.5.1-stable
  • I wanted to use this simple sky shader in compatibility mode (as suggested in the sky shader documentation):
shader_type sky;

void sky() {
    if (AT_CUBEMAP_PASS) {
        COLOR = vec3(1.0, 0.0, 0.0);
    } else {
        COLOR = texture(RADIANCE, EYEDIR).rgb;
    }
}

The cubemap pass is done (objects get a red tint due to ambient light), but RADIANCE can not be read (black sky). I'm using NVIDIA GeForce RTX 3050 with driver version 580.95.05 (linux).
A renderdoc capture suggested that the sampler binding differs from the engine binding.
A working quick-and-dirty fix is to change

uniform samplerCube radiance; //texunit:-1

to

uniform samplerCube radiance; //texunit:-2

in drivers/gles3/shaders/sky.glsl and shifting the following texunits accordingly.

I'm completely new to the godot code and currently don't have much time, so I guess I missed something. I will investigate further, but maybe here is an expert who can give hints in the meantime so I don't think in the wrong direction.

Steps to reproduce

use the sky shader described in the issue description

Minimal reproduction project (MRP)

N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions