Light dependent materials

I want to make a material that renders its emissive component only at parts of meshes which are not receiving light or maybe receiving light less than a certain amount!

For example a material that makes object look normal in the light but glows when the same object moves to dark environment

This would have been easy in a forward rendering path. As UE4 uses a deferred rendering path, we don’t have access to light vectors. If you had the light vector, you would only need to use the dot product to filter out the lit and dark area of the mesh.

Maybe there is a trick that can be used in deferred rendering. Is there anyone who knows how?

umm… we do have access to light vectors ! but I dont know how to use it yet
it shows error if I link it to multiply function !

This expression is deprecated in Unreal Engine 4 as lighting
calculations are now deferred.

As far as I know, only light functions can use them.

Having this same question myself, seeing lots of others asking it… Its such a simple thing and it’s just “base color” but made emissive and reversed… I’m having trouble understanding why that’s impossible to pull off. I don’t understand this stuff technically so I admit ignorance but it seems like there should be some function to just flip some of the options that are already there… I don’t see why this needs to be so complex

If it can’t be done at all that’s seriously frustrating… making planets is basically impossible

I managed to piece together (more like improvise) a decent solution (which is by no means complete) and I thought to share it with other people having the same problem. Anybody who knows more please help to improve this

Here is a video of it in action [UE4] Light dependent material (Light Vector workaround) - YouTube

and this is the shader logic used for it (the emissive channel logic)

So as workaround what I did was to manually put a vector parameter in the shader that indicates actual (or approximate) position of the light source to be used for calculating approximate light vector and then use the dot product and other common mathematics to determine if the light is falling on the current vertex and then feed the result to the emmissive channel

With blueprints and c++ logic a set up can be used in the game where the parameter regarding the position of light can be set during runtime

So far the shader technique have given decent result. There is a area between the lit and unlit area which the shader logic does not reach because of strict limit of if dot product =0 (needs to be fixed)

Apprantly That would create a whole lot of messy material. And yes this is perfect for one or two lights but is difficult to implement when there are too many lights. but again you can indeed extend this to many lights (painful work)

Ah yes, this is a perfect solution if you only need one light source. Question though, don’t you need to normalize the vectors? Dot product can be quite unreliable if you do not normalize the vectors.

How does normalization cause a messy material? It is just one node for each vector. Maybe I misunderstand your reply.

Sheeeeeeiiitttt! Yes you are right! you see I’m a beginner so I didn’t knew normalisation node existed instead I was thinking of doing all multiplication and square rooting divide and what not . Thanks for telling me about that node

Unreal now has a forward renderer… is this still not possible to easily grab in the material graph?