godotengine / godotengine/godot-docs

CanvasItem shader light functions receiving vec4(0.0) as LIGHT input

Open
#6,726 1 comment 0 reactions 0 assignees View on GitHub
area:manual bug topic:rendering topic:shaders
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

### Godot version

4.0.beta9 (e780dc332) using any renderer

### System information

Windows 11

### Issue description

It seems like CanvasItem shaders are always receiving `vec4(0.0)` as their `LIGHT` input. Based on the [docs](https://docs.godotengine.org/en/latest/tutorials/shaders/shader_reference/canvas_item_shader.html#light-built-ins), I would expect to get the value of the light that would be otherwise applied to the texture.

![image](https://user-images.githubusercontent.com/4420888/210185422-0adcc037-e744-4108-9609-97097d0b5f9c.png)

### Steps to reproduce

- Create a Sprite2D that is affected by a Light2D (point or directional)
- Attach a ShaderMaterial with a canvas_item shader to the Sprite2D.
- Try writing a `light()` function:
- If you don't set `LIGHT`, no lights are applied to the sprite at all (according to the [docs](https://docs.godotengine.org/en/latest/tutorials/shaders/shader_reference/canvas_item_shader.html#light-built-ins), not setting `LIGHT` should cause the function to be a no-op)
- If you set `LIGHT = LIGHT;`, no lights are applied (I would expect this to be a no-op)

Some extra info:
* the light's blend mode has no effect (same result with add/mix/sub)
* Setting a `LIGHT` value (e.g. `LIGHT = COLOR;`) seems to work fine
* I didn't expect this have any effect, but adding a `BackBufferCopy` node before the sprite didn't change anything

### Minimal reproduction project

[lightshaders.zip](https://github.com/godotengine/godot/files/10329517/lightshaders.zip)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.