top of page
Search
  • Writer's picturehippowombat

UE4: Illumination Detection Blueprint Framework



I spent a week working on a framework that tells you how illuminated an actor is by lights in your level. It’s all blueprint-based, using components & overlaps & tracing. In this post I’ll break down how the system works, how to set it up in your project, and detail some limitations. In a more thorough post, I’ll break down all the code so that if you’re not using UE4 4.20 or newer, or if you’re just curious how this system was made, you can go through the creation process yourself.

Overview

This post assumes the end user is somewhat familiar with the Unreal Engine editor, blueprints scripting & actor editing. I’ll try to break things down as simply as possible. First, here are some videos showcasing how the system works, and what it tries to accomplish:



Here we see the base system, which traces from the points to the lights, and returns an illumination value showcased in the arrow color above the player’s head.



In this video, we see some more complex examples, with light sources being tracked on moving objects, and probe points having sample radii for more broad coverage of areas, as well as individual debugging intensity values.



Finally in this video, we see the probes sampling the color data multiplied by the intensity divided by scaled distance from the light sources, with color mixing for multiple different color overlaps, giving light intensity and color value at each probe intersection point.

The basic workflow for this system is:

-User copies IlluminationDetection folder from the Github Source Project to their project’s content folder -Actor gets assigned probe components -User places light boundary volumes for point & spot lights in level -Player assigns light illumination components to directional/sky lights in level -At runtime, probes trace for appropriate light sources and return light (and optionally color) illumination information. If their traces return a hit, it means that the probe does not have a clear line of sight to the light source, which means it’s in the shadows. -End user can use that data however they’d like, be it for stealth or puzzle mechanics or something else.


This system will only trace for lights when it’s appropriate, thanks to the overlap logic it espouses; directional lights will always get a probe to trace, as they’re a global light actor. Sky lights also get checked every time the Detect Light Vis function runs, but it has the advantage of not needing trace logic, as it’s both global and ambient.


Point lights will only prompt a probe to trace if that probe is overlapping an Illumination Volume that’s assigned to the given point light. (I’ll go over how to assign volumes further down.)


Spot lights will also only prompt a probe to trace if that probe is overlapping an illumination volume that’s assigned to it, with an additional vector math step to determine if the probe is also within the spot light’s cone.


In order to assign volumes to lights, you can either place Illumination Sphere Volumes or Illumination Cube Volumes (found in IlluminationDetection>Blueprints>IlluminationVolumes) in your level and assign them to the appropriate spot/point lights (which will adjust location, bounds scale accordingly) OR you can use a handy blueprint that I included that does that work for you.


If you want to make these point/spot light volumes automatically, drag a BP_LightOverlapManager actor into your level, and then click the Generate Overlaps button. This will run through all the point lights and spot lights in your level and place/orient/adjust sphere overlap volumes for you. You can also remove the generated overlaps, and show/hide their bounds using the other Buttons in the Actor Details panel.


The Illumination Probe component can be attached to an object or skeletal sockets or really whatever you’d like, and has a handful of variables, including debugging options, and bools to control whether to check for directional lights, sky lights, and color values. The Max Illumination value is the individual probe’s overall Illumination value, which you can set to any arbitrary scale you’d like. In the example project, the 8 probes attached to the character all attribute to the player’s overall illumination equally. But going through and manually adding the probes to a character or object allows you to set different values per probe, as a probe on someone’s face might deserve a higher illumination value, as an AI would conceivably be able to identify a person’s face more than, say, their foot.


The source code for this is available here, and is built in UE4 version 4.20. If you’d like to try a demo, that is available here. I’ll return with a more in-depth walk through of how to use this, along with a video, but I wanted to get a baseline description out, as I’ve been excited to get this system completed and released. Cheers!

745 views

Recent Posts

See All

Fear

Post: Blog2_Post

Subscribe to my mailing list!
I'll try not to bug you too often!

Thanks!

bottom of page