NME: Shadow output of 'Lights' node doesn't work with multiple lights

Hello,

I’m trying to recreate the ShadowOnlyMaterial with the NodeMaterialEditor because I need to control the shadow opacity. Here’s is what I have came up with:

https://nme.babylonjs.com/#GA2RPP

Every is working great as long as there is only 1 light in the scene.
If I have multiple lights, only the shadows of the last light added into the scene show up.

Here is a Playground that reproduce the issue: https://playground.babylonjs.com/#VM49TX#2

Am I doing something wrong or is there some sort of limitations ?
If I cannot get the shadows from multiple lights, is there a way to at least choose wich light will be used by the node ? Relying on the creation order isn’t a very robust solution…

The Lights.shadow output gives you the value of the last light in the scene, indeed. So, if this light has no shadow generator, you’ll get 1. I think this output was mainly intended for use in the case of a single light.

The ShadowOnly material also has this problem, which is why there’s an activeLight property: when you set a value, it rearranges the lights to ensure that the right light will be used by the shader.

To overcome this problem and handle the multi-light scenario, I wonder if we could add a new output like “AggregatedShadow” that would give you the % for the current pixel not in shadow, regardless of the number of lights (or even change “shadow” if we consider it to be a bug)…

I ended up creating a PR, because I think the way it currently works is buggy :

Thank you for your quick response ! :slight_smile:

Once the PR has been merged, what’s the best way for me to know when the fix is available in the next package version ?

It will be available on the Playground the next day it is merged, and the next thursday morning (european time) for the npm packages.