Feasibility of separating ATTENUATION into 2 distinct variables in Godot's shading pipeline

(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.

This is already proposed as SHADOW_ATTENUATION, so you don’t need to open a new one: Decouple shadows from `ATTENUATION` into its own `SHADOW_ATTENUATION` built-in in `spatial` shaders · Issue #2905 · godotengine/godot-proposals · GitHub

It’s been open since 2021 and it’s on the VFX and Techart wishlist board with the status set to Needs implementer.

Feasibility is pretty well answered too, since there’s an implementation that got most of the way: Separate shadow attenuation from attenuation by QbieShay · Pull Request #86074 · godotengine/godot · GitHub

That one adds a SHADOW_ATTENUATION keyword where using it causes the shader to split the two, and leaving it out keeps ATTENUATION working as it does now. The author tested it across all three renderers for omni, spot, and directional. It broke for SpotLight after a rebase and stalled there. It’s milestone 4.x with a salvageable label, and the author said in July 2025 it isn’t on hold, the PR just broke before it could merge and they moved to other code.

What I’d probably do is add your toon shader case to the proposal thread, since it’s an implementer it’s waiting on rather than more discussion about whether it’s wanted.