Page MenuHome

EEVEE: new node to expose individual light info and shadow to shader.
Needs RevisionPublic

Authored by Jean Da Costa (jeacom256) on Oct 6 2020, 7:08 PM.
Tokens
"Love" token, awarded by zNight."Love" token, awarded by gintszilbalodis."Love" token, awarded by gilberto_rodrigues."Love" token, awarded by pablovazquez."Love" token, awarded by TheAngerSpecialist."Love" token, awarded by mindinsomnia."Love" token, awarded by kenziemac130."Love" token, awarded by Limarest."Like" token, awarded by RedMser.

Details

Summary

Previously, there was only one method to get the shadow from a single light in EEVEE in the shader by using the separate RGB node (https://youtu.be/TpWI2rU8iF0?t=871) and it was limited to a maximum of 3 lights while eevee could support up to 128.
This patch adds a new "Light Info" node that is analogous to the old Blender internal's "Light Data" node and its main use is to expose individual shadows and vectors from the lights for use by the artist.

This node should be extremely useful for NPR artists and allow for the creation of shaders and lighting models form scratch that simply weren't possible before such as half Lambert with more than 3 lights and shadows.

Unfortunately I have no idea of how to add the same feature to cycles, so it's a EEVEE only node for now, just like Shader To Closure.



Diff Detail

Event Timeline

Jean Da Costa (jeacom256) requested review of this revision.Oct 6 2020, 7:08 PM
Jean Da Costa (jeacom256) created this revision.
Jean Da Costa (jeacom256) edited the summary of this revision. (Show Details)

Remove Right, Up and Forward sockets as those are replicable with the texture coordinate node.

Jean Da Costa (jeacom256) updated this revision to Diff 29706.EditedOct 7 2020, 5:59 PM

Make output color range from 0 to 1 and add new socket for light energy instead.

This is how the node looks right now.

Jean Da Costa (jeacom256) updated this revision to Diff 29810.EditedOct 10 2020, 5:26 PM

update patch with arcanist to make code context visible.

Could "Vector" perhaps be renamed to something like "Direction"?

In D9130#226584, @astrand130 wrote:

Could "Vector" perhaps be renamed to something like "Direction"?

I suppose it could but its often called the "light vector" so I thought it was appropriate.

@Clément Foucault (fclem) @Bastien Montagne (mont29), I hope I'm not annoying but can you have a look at this? Or at least reject it right away, this limbo sorta makes me anxious.

@Jean Da Costa (jeacom256) Thanks for the patch, but am not sure why you tagged me here, this is really not one of my areas...

@Clément Foucault (fclem) is indeed the main dev, I guess maybe also @Jeroen Bakker (jbakker) or @Brecht Van Lommel (brecht) might be interested?

@Jean Da Costa (jeacom256) Thanks for the patch, but am not sure why you tagged me here, this is really not one of my areas...

@Clément Foucault (fclem) is indeed the main dev, I guess maybe also @Jeroen Bakker (jbakker) or @Brecht Van Lommel (brecht) might be interested?

Oops, I guess it was a mistake, my bad.

I will let @Clément Foucault (fclem) decide how well this fits in the plan for EEVEE. Extending this to cycles seems doable, but we need to check if this node will eventually be supported by Cycles.

source/blender/draw/engines/eevee/eevee_lights.c
175

I would suggest to use an index to remove the searching in the fragment shaders.

source/blender/gpu/shaders/material/gpu_shader_material_light_info.glsl
13

Not sure this is the best approach. Isn't it possible to store an index to the right light and use this as light_id.
Scenes can have up to 128 lights.

source/blender/nodes/shader/nodes/node_shader_light_info.c
61

Having a single gpu function could reduce performance when for example when the shadow socket isn't used. I would separate them into some smaller functions where the data that are closely related to each other are calculated.

Jeroen Bakker (jbakker) requested changes to this revision.Oct 20 2020, 4:44 PM
Jeroen Bakker (jbakker) added 1 blocking reviewer(s): Clément Foucault (fclem).
This revision now requires changes to proceed.Oct 20 2020, 4:44 PM

This feature will not be supported in Cycles, NPR features like this are not something we plan to add there.