(using Godot 4.7.0)
I have a mesh whose material is assigned a custom spatial shader and which is being illuminated by multiple lights in the scene, all of which have shadows enabled. From what I understand, the float ATTENUATION which is available in the spatial shader’s light function accounts for 2 distinct things in the shading pipeline - the shadows to be present on the mesh, and also the effect of light falloff from any lights that aren’t DirectionalLight3Ds. This allows for a very simple [multiply by ATTENUATION] operation in the shader’s code so that it responds to both shadow mapping and light falloff for every light present.
However, this introduces the limitation that I cannot access either of these 2 things individually, which I would like to be able to do to achieve a visual effect - specfically, in calculating the lighting of the portion of the mesh not facing the light (this shader is a toon shader which visually splits the mesh to have a lighter portion and a darker portion, which are calculated independently), I want to be able to multiply this darker portion only by the light falloff value, such that the presence of shadow in the darker portion is irrelevant. But I can’t do that since ATTENUATION includes both things, and of course I can’t not multiply by the falloff value at all because then the darker portion would not respond to falloff from any non DirectionalLights and it would result in that blocky “you didn’t multiply by ATTENUATION” look at the edges of the lights’ areas.
So now I would like to ask the question - would it be feasible to split ATTENUATION into 2 variables, 1 which represents shadow and 1 which represents light falloff, in Godot’s shading pipeline, such that they can then be accessed by users when creating custom shaders? I must admit I’m not familiar with the source code responsible for shading (or really any of the source code), so this is more out of curiosity than suggestion, though I may open a request for this change if it truly seems feasible and desirable enough to implement.
And, while writing this, I did think of a potential workaround, which is to move the programming for the darker portion into a separate shader which has shadows disabled (thus making ATTENUATION account only for light falloff), render that first, and then add the lighter portion via a second shader which still has shadows enabled. So that may be possible, but I would much rather have these 2 things be individually accessible so that I can keep everything neatly within a single shader.