x

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"

How can I measure the amount of light hitting a mesh?

I want to create a variable that shows the amount of light hitting a mesh (e.g. a small cube that is partitally shadowed) Is there any measurement, how much light hits the mesh? Or, is there a not too complicated way to get create one? Thank you for any answer!

Product Version: UE 4.12
Tags:
more ▼

asked Jul 25 '16 at 10:45 AM in Rendering

avatar image

JHaagRD
3 1 2 3

avatar image NoobsDeSroobs Jul 25 '16 at 10:47 AM

How accurate do you have to be? What usage is this for? What are you trying to achieve by calculating this?

There are several methods that might be good enough or give you the result you want, but we need more information.

avatar image JHaagRD Jul 25 '16 at 01:00 PM

I intend to do a stealth game, top down view. Right now I try to figure out what technical options I have. The main purpose is to calculate the visibility of the main character by other (enemy) actors, but other possibilities like hidden traps would be nice (you'd need light to see them, but this light could show the characters position). I've a lot of c++ practice but i'm completely new to graphics.

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

2 answers: sort voted first

From what I understand you have a few options:

The easiest is simply to do a line trace from the object to all lights and see if you are visible. This will not be very flexible, but it is cheap and easy to implement. This is just a visible, not visible system. You can not be partially visible. However, what you can do is to use distance between the object and the light to indicate how visible you are. 5 meters away or closer and you are completely visible, 10 meters away or farther and you are invisible.

You can also use a distance based method where all you do is check if the object is close enough to the light. Let us say that you have an object in the world and your light has a range of 5 meters around you. Then you can have a hitbox around the light that triggers on overlap. You can filter the overlap events to only continue if the class of the other object is of a certain type. That way you can select what is being affected and what is not. This can also be combined with a trace.

Another option that will give you more accuracy and more flexibility is to have several locations on the object that all check if they are visible IF they are within range to be effected. That if is needed to not waste resources. You can then have a simple calculation to find out how visible you are by adding the light values of each point by doing an independent line trace for each.

Finally you can write a custom material that goes though all vertices or fragments and calculate how much is actually visible to the lights. This is very expensive and is not easy to do properly. For 99% of all situations where you might want it some version or combination of the methods I outlined above will be preferable.

I hope this helps.

more ▼

answered Jul 25 '16 at 01:37 PM

avatar image

NoobsDeSroobs
2.7k 108 36 180

avatar image JHaagRD Jul 25 '16 at 01:50 PM

It helps a lot, thank you very much! Define sample points, check visibility - if visible calculate lighting impact from all light sources in reach. Again: thank you!

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

If you need it for gameplay purposes, I suggest doing a trace from the object to the light, checking if anything interrupts visibility. For better approximation, you could do this from several points( all corners of the cube), and average the results. This is doable in blueprints. Obviously you can only afford to implement this for 1 object only, for performance reasons.

Rendering side of things looks different. It is possible to approximate this in post process material, but no way nearly accurate. You should inform what are you intending to achieve, since in most cases when such questions arise there already is an elegant solution

more ▼

answered Jul 25 '16 at 11:07 AM

avatar image

Deathrey
7.9k 130 31 295

avatar image JHaagRD Jul 25 '16 at 01:01 PM

I intend to do a stealth game, top down view. Right now I try to figure out what technical options I have. The main purpose is to calculate the visibility of the main character by other (enemy) actors, but other possibilities like hidden traps would be nice (you'd need light to see them, but this light could show the characters position). I've a lot of c++ practice but i'm completely new to graphics.

(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