Accessing light info in "unshaded" shaders

Godot Version

4.6

Question

Hi!

I’m trying to write a shader skipping all internal godot lighting model. Render mode “unshaded” is pretty close what I’m looking for but I don’t know if exists some easy way to read scene lights in shader code (something like GetMainlLight/GetAdditionalLigh or similar) , or the only solution is to pass from code all relevant data.

Thanks in advance!

You need to implement the light() function.

Thanks for your response!

Sure, but light() function (as far as I know) is not executed in render_mode unshaded. If I use default render mode and implement light function, the final result is split in several built-ins (SPECULAR, DIFFUSE_LIGHT, ALBEDO…) and Godot calculate internally the final fragment color. I was wondering if it’s possible to do something like Vertex/Fragment shader in Unity, write the final pixel color manually

Light info is only available in light function. If you want to do something totally custom with scene lights you’ll have to pass them via uniforms.

What exact type of illumination/effect are you trying to achieve?

1 Like

Perfect. I’m just playing around with shaders. I come from other engines and I’m trying to understand how shaders work in Godot.

Thanks for your time!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.