Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

Product Version: Not Selected
more ▼

asked Nov 16 '14 at 12:44 PM in Rendering

avatar image

Commander Shepard
827 62 83 220

avatar image Denny Nov 16 '14 at 01:06 PM

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?

avatar image Commander Shepard Nov 16 '14 at 01:53 PM

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 ! alt text

alt text

avatar image Denny Nov 16 '14 at 05:04 PM

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.


avatar image StevenWaltherMedia Mar 02 '18 at 09:53 PM

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

avatar image Pinworm Nov 16 '14 at 05:30 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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 https://www.youtube.com/watch?v=_J6ABO3zJ_c&feature=youtu.be

and this is the shader logic used for it (the emissive channel logic)
http://i.gyazo.com/41cb0985e76c8a5b87e15c2689c74c64.png alt text

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)

more ▼

answered Nov 17 '14 at 05:04 PM

avatar image

Commander Shepard
827 62 83 220

avatar image Denny Nov 17 '14 at 05:12 PM

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.

avatar image Commander Shepard Nov 17 '14 at 05:17 PM

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)

avatar image Denny Nov 17 '14 at 05:29 PM

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

avatar image Commander Shepard Nov 17 '14 at 05:53 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question