Can anyone explain this Directional Light behavior?

Dave The DevDave The Dev Posts: 22Member
edited May 21 in Shaders

Hello, I'm wondering if anyone can explain this Directional Light behavior.

Godot Version: 3.2.1

I'm using the shader below on a sphere. The shader uses the vertex and fragment shader simply to override the built-in Godot shaders, and disables ambient lighting. Also, there is a blank WorldEnvironment node in the SceneTree, so in theory there's no light affecting the sphere from the environment.

The light shader assigns a constant color to DIFFUSE_LIGHT making the sphere dark red. Notice I'm not using +=, so the color should be constant no matter how many lights are in the scene.

However, when I add multiple directional lights, each seems to increase the brightness of the sphere. This effect only occurs with directional lights, not omni or spot lights.

I would like to know why and how to stop it.

If I can figure this out, the next version of my Cel Shader might be able to use multiple directional lights.

shader_type spatial;
render_mode ambient_light_disabled;

void vertex() {VERTEX = VERTEX;}

void fragment() {ALBEDO = vec3(0.0, 0.0, 0.0);}

void light()
{
    DIFFUSE_LIGHT = vec3(0.1, 0.0, 0.0);
}

Sphere with one directional light...

Sphere with five directional lights...

Best Answer

  • SIsilicon28SIsilicon28 Posts: 715
    Accepted Answer

    The way I understand Godot's rendering pipeline, each directional light is processed in consecutive additive passes. No matter what you do in the light shader, they will always add on top of each other.

Answers

  • SIsilicon28SIsilicon28 Posts: 715Moderator
    Accepted Answer

    The way I understand Godot's rendering pipeline, each directional light is processed in consecutive additive passes. No matter what you do in the light shader, they will always add on top of each other.

  • Dave The DevDave The Dev Posts: 22Member
    edited May 21

    Thank you for the reply. I thought that may be the case, but I was hoping I was missing something else.

    Edit: From your suggestion, I did some research and found this...
    https://godotengine.org/article/godot-3-renderer-design-explained

    "In Godot each directional light means a new whole scene render pass, so use those with care. It's hard to need more than one anyway."

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file