This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

Can anyone explain this Directional Light behavior?

Dave The DevDave The Dev Posts: 22Member
edited May 2020 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: 693
    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: 693Moderator
    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 2020

    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

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.