SHADOW STEALTH

Description

Shadow Stealth implements “hide in the shadows” gameplay mechanic, perfect for thieves, assassins and alike. All the features are easily accessible from Blueprints, no C++ knowledge required.

Features

  • Supports All Light types with Static mobility.
  • Supports Point, Spot and Directional Light types with Stationary and Movable mobility.
  • Integrates with AI Perception component through AI Sight sense.
  • Easy setup with a handful of components. Level editor tools and predefined actors provided for convenience.
  • Performance is independent of the size of the map and the number of lights.
  • Static Lights support depends on Sparse Volume Lighting Sample method for Volume Lighting. Volumetric Lightmap support can be added in future updates.

Gallery

Downloads

Example project:

Changelog

1.2

  • Add AISightShadowSenseEnabled for enabling/disabling if AISight sense uses shadows (Shadow Stealth default) or not (AIPerception default)
  • Add new methods of calculating light intensity from multiple test sockets: max, min, mean, median
  • Add Shadow Lights and Shadow Stealth Character actors to placement mode
  • Add TestSelfLocation flag to shadow stealth component
  • Fix handling light color

1.1

  • Add getting per color channel light intensity
  • Fix handling light color

Documentation

Basic Usage

Scene Setup

Shadow Stealth handles static lighting differently than dynamic lighting.

Static Lighting

Shadow Stealth uses static lighting information baked by the engine. The downside of this solution is that you cannot choose which static lights should be taken into account for lighting intensity computations. But on the upside GI is taken into account, so is the Sky Light and Rect Lights.

Setup needed for static lighting is minimal. First, you need to enable ‘Use Static Lighting’ option in Shadow Stealth plugin settings (it’s enabled by default):

  1. Open ‘Project Settings’ window. You can do this through the ‘Edit’ menu in the menu bar.
  2. In the navigation panel, on the right side of the window, scroll all the way down to the ‘Plugins’ category and click on the ‘Shadow Stealth’ section.
  3. In the configuration panel, on the left side of the window, make sure that the ‘Use Static Lighting’ checkbox is checked.

Second, you need to enable ‘Allow Static Lighting’ option in ‘Engine – Rendering’ settings (also enabled by default):

  1. Open ‘Project Settings’ window. You can do it through the ‘Edit’ menu in the menu bar.
  2. In the search bar, at the top of the window, type ‘Allow Static Lighting’.
  3. In the configuration panel, on the left side of the window, make sure that the ‘Allow Static Lighting’ checkbox in the ‘Engine – Rendering’ section is checked.

Third, you need to set ‘Volume Lighting Method’ in the ‘World – Lightmass Settings’ to ‘Sparse Volume Lighting Samples’ (this one is not the default setting):

  1. Open the ‘World Settings’ window. You can do it through the ‘Window’ menu in the menu bar.
  2. In the ‘World Settings’ window find and expand the ‘Lightmass’ section.
  3. In the ‘Lightmass’ section find and expand the ‘Lightmass Settings’ category.
  4. In the ‘Lightmass Settings’ category find the ‘Volume Lighting Method’ combo box and set it to ‘Sparse Volume Lighting Samples’.
  5. Optionally you can find the ‘Volume Light Sample Placement Scale’ setting, in the same category, and reduce it from the default value of 1.0 to something between 0.25 and 0.5 (or set it to any other value of your choice). This will increase the accuracy of the static lighting intensity computation, but will also increase memory usage (in the game and in the editor) and ‘Indirect Lighting Cache’ update times (in the editor only).

Remember about building the lighting to keep your static lighting up to date.

If you want to preview ‘Sparse Volume Lighting Samples’ color, intensity, and density, you can enable ‘Volume Lighting Samples’ visualization in the ‘Level Editor’ viewport:

  1. Click on the ‘Show’ button in the top left corner of the ‘Level Editor’ viewport.
  2. In the dropdown menu move the mouse cursor on the ‘Visualize’ submenu.
  3. In the submenu check the ‘Volume Lighting Samples’ checkbox near the bottom.
  4. You can now see a grid of small squares, symbolizing color and intensity of the lighting samples, throughout the level.
Dynamic Lighting

Shadow Stealth supports dynamic lighting for Point, Spot, and Directional Lights. For each of the light types there’s a component that has to be attached to the corresponding light component:

  • ShadowPointLightComponent -> PointLightComponent
  • ShadowSpotLightComponent -> SpotLightComponent
  • ShadowDirectionalLightComponent -> DirectionalLightComponent

Dynamic light components without the shadow component attached won’t be seen by Shadow Stealth plugin.

For Point and Spot Lights Shadow Light Components add colliders that are used to efficiently detect lights in range. Colliders are set up automatically based on light size and shape.

There are different methods of setting up dynamic lights on the map you can use, depending on your situation.

If you start with a new map and want to place a few simple light actors, you can use actors provided for you by the plugin:

  • ShadowPointLight
  • ShadowSpotLight
  • ShadowDirectionalLight

Shadow Light Actors can be found in ‘ShadowStealth C++ Classes’ in the ‘Content Browser’. You can just place them on the level:

  1. If you cannot see the ‘Source Panel’ on the left side of the ‘Content Browser’, make it visible by clicking the button in the top left corner of the window.
  2. If you cannot see the ‘ShadowStealth C++ Classes’ top-level category in the ‘Source Panel’:
    • Click ‘View Options’ button in the bottom right corner of the window.
    • Check ‘Show Engine Content’ and ‘Show Plugin Content’ checkboxes in the popup menu.
  3. In the ‘ShadowStealth C++ Classes’ category open folder ‘ShadowStealth/Classes/Actors’.
  4. Drag one of Shadow Light Actors from ‘Content Browser’ main panel to the level viewport.

If you have a map that you would like to quickly convert to usable with Shadow Stealth plugin, you can use convenient ‘Add Shadow Lights’ option in ‘Level Editor’ context menu:

  1. In the ‘Level Editor’ viewport click on any actor to select it.
  2. Press ‘Ctrl+A’ on the keyboard to select all actors on the map. Optionally you could select only actors containing Light Components you want to convert.
  3. Right-click on any actor in the ‘Level Editor’ viewport to open the context menu with all actors still selected.
  4. Click on the ‘Add Shadow Lights’ option in the ‘Shadow Stealth’ category. If you cannot see this option, there are no dynamic Light Components without corresponding Shadow Light Component attached.

The most versatile method is to attach the Shadow Light Component to Light Component through ‘Components’ panel in ‘Blueprint Editor’ or ‘Components’ section in ‘Details’ panel in ‘Level Editor’:

  1. Select the Light Component you want to use with the Shadow Stealth plugin.
  2. Click the ‘+ Add Component’ button.
  3. In the search bar in the popup menu type ‘Shadow’.
  4. From visible components choose the Shadow Light Component corresponding to the Light Component you’ve selected.

Player Setup

The most important class in the Shadow Stealth plugin is ShadowStealthComponent.

Component

For an actor to take advantage of the ShadowStealthCompnent, it has to be attached to another scene component that has some sockets/bones defined. The most natural setup is a Character actor with ShadowStealthComponent attached to the SkeletalMeshComponent. There are multiple ways you can create one.

If you’re starting from scratch, you can create a new Character blueprint using ShadowStealthCharacter class as its base:

  1. Right-click anywhere in the main panel of the ‘Content Browser’.
  2. From the popup menu choose ‘Blueprint Class’ in the ‘Create Basic Asset’ section.
  3. In the search bar located in the ‘All Classes’ section type ‘Shadow’.
  4. From filtered classes choose ShadowStealthCharacter and click the ‘Select’ button.
  5. Name your new Character blueprint appropriately.

If you have a Character blueprint that derives directly from the Character class, you can just change the parent class to ShadowStealthCharacter:

  1. Open your Character blueprint in the ‘Blueprint Editor’.
  2. In the ‘Toolbar’ window click the ‘Edit Class Settings’ button (fifth one by default).
  3. In the ‘Details’ window click the ‘Parent Class’ combo box in the ‘Class Options’ section.
  4. In the search bar in the popup menu type ‘Shadow’.
  5. From filtered classes choose ‘ShadowStealthCharacter’.

If your Character blueprint is a part of a hierarchy of classes with the Character class at its base, you can do the above for the ancestor that derives directly from the Character class. Some other blueprints will unnecessarily have the ShadowStealthComponent, but without ‘Test Sockets’ configured it will be free.

If for some reason, you are unable to derive your character from ShadowStealthCharacter, you can add ShadowStealthComponent to it. The downside is that the AIPerception integration won’t work, because it has to be implemented with an Actor, not a Component.

  1. Open your Character blueprint in the ‘Blueprint Editor’.
  2. In the Components window choose the ‘Mesh’ component.
  3. Click the ‘+ Add Component’ button.
  4. In the search bar in the popup menu type ‘Shadow’.
  5. From filtered classes choose the ‘ShadowStealth’ component.
Sockets

By now you should have a Character blueprint with ShadowStealthComponent in it. The next step is to set sockets, from the parent component, that will be tested for light intensity.

  1. Open your Character blueprint in the ‘Blueprint Editor’.
  2. In the ‘Components’ window choose the ‘ShadowStealth’ component.
  3. In the ‘Details’ window locate the ‘Shadow Stealth’ category.
  4. Click the ‘+’ button next to the ‘Test Sockets’ property.
  5. Click on the combo box of the new ‘Test Sockets’ element.
  6. Select the socket/bone you want to participate in light intensity computations.

You can choose as many sockets as you want, but remember that each new socket will add to the CPU usage of the Shadow Stealth plugin.

Trace Channel

The Shadow Stealth plugin uses traces to determine if a dynamic light reaches the Test Socket on the character. By default ‘Visibility’ trace channel is used.

If you’ll choose to use the default channel, you must make sure that your character does not block the ‘Visibility’ trace channel. This shouldn’t be a problem when using ShadowStealthCharacter or Character classes as a base for your character, because:

  • CapsuleComponent uses Pawn collision preset, which ignores the ‘Visibility’ trace channel.
  • Mesh uses CharacterMesh collision preset, which also ignores the ‘Visibility’ trace channel.

You can create your own trace channel to allow ignoring meshes that for example don’t cast a shadow:

  1. Open ‘Project Settings’ window. You can do this through the ‘Edit’ menu in the menu bar.
  2. In the ‘Engine’ section in the navigation panel on the left side of the window, choose the ‘Collision’ category.
  3. In the main panel on the right side of the window, click ‘New Trace Channel…’ button.
  4. In the ‘New Channel’ type in ‘Name’ (e.g. ‘ShadowVisibility’), select ‘Block’ as ‘Default Response’, and click the ‘Accept’ button.
  5. In the ‘Preset’ category you have to change responses to your new channel in following presets: NoCollision, OverlapAll, OverlapAllDynamic, Pawn, Spectator, CharacterMesh, InvisibleWall, InvisibleWallDynamic, Trigger, and Ragdoll:
    • Double-click on a preset.
    • In the ‘Trace Type’ category for your new channel check the same checkbox as next to the ‘Visibility’ channel.
    • Click the ‘Accept’ button.

You can also create your own presets based on engine presets, e.g. ‘BlockAllButShadowVisibility’ from ‘BlockAll’:

  1. Click the ‘New…’ button in the ‘Preset’ section.
  2. Copy settings from one of engine presets.
  3. Type a new name into the ‘Name’ field.
  4. Set ‘Collision response’ of your new channel to ‘Ignore’.

The last thing to do is to change ‘Trace Channel’ used by Shadow Stealth:

  1. In the navigation panel, on the right side of the window, scroll all the way down to the ‘Plugins’ category and click on the ‘Shadow Stealth’ section.
  2. In the main panel on the right side of the window, set ‘Trace Channel’ to your new channel.

Blueprint Functions

There are two main functions exposed to blueprints:

  • ‘Get Light Intensity’ – get maximum light intensity at all sockets
  • ‘Get Light Intensity at Socket’ – get light intensity at the selected socket
  • ‘Get Light Intensity RGB’ – get maximum per channel light intensity at all sockets
  • ‘Get Light Intensity RGB at Socket’ – get per channel light intensity at the selected socket

Both functions return light intensity as a floating-point value. There is no set boundary value for distinguishing the shadow from the light. You’ll have to choose one that is appropriate for your lighting, camera, and post-processes setup.

Debug Visualisation

There’s a console variable ‘ShadowStealth.DebugDraw’ that controls debug visualization of ShadowStealthComponent state. Set it to ‘1’ to enable or ‘0’ to disable the visualization. The visualization consists of:

  • Integer value, the top one, representing the number of dynamic lights that are currently in the range of the ShadowStealthComponent.
  • Floating point value, the bottom one, representing the current maximum light intensity at all sockets.
  • Wireframe spheres representing test sockets. Blue means that the socket is completely shaded and yellow means that the socket is lit. If static lighting is used, spheres most likely will always be yellow.
  • Lines representing traces from dynamic lights to sockets. Lines are blue when in the shadow and yellow when in the light.

AIPerception Integration

The AIPerception integration overrides the default AISight sense behavior. Instead of one trace to the center of an actor and binary stimuli strength (0.0 or 1.0), it:

  1. Performs a trace for each test socket on ShadowStealthComponent.
  2. From all sockets that passed the trace test the one with the highest light intensity is chosen.
  3. The light intensity is normalized to a range defined in the settings (more about that later).
  4. If the normalized light intensity is greater than 0.0, the actor is in sight and the light intensity is used for stimuli strength.

AISight light intensity range can be configured in Shadow Stealth plugin project settings. There are three values:

  • ‘AISight Intensity Hidden Lower Bound’: used as the lower bound of the range when the owner of the AIPerception component has no knowledge about player whereabouts.
  • ‘AISight Intensity Sighted Lower Bound’: used as the lower bound of the range when the owner of the AIPerception component has seen the player lately (has active AISight stimuli).
  • ‘AISight Intensity Upper Bound’: used as the upper bound of the range.

AISight light intensity range can also be overridden in the ShadowStealthComopnent. Look for ‘AISight Intensity Hidden Lower Bound Override’, ‘AISight Intensity Sighted Lower Bound Override’, and ‘AISight Intensity Upper Bound Override’ advanced properties. If their values are greater than 0.0, they override values from settings.

Setup

If your Character blueprint derives from ShadowStealthCharacter, it already integrates with AIPerception. If not look into the ‘Player Setup’ section above.

Light Intensity Change Events

ShadowStealthComponent provides events for light intensity exceeding or falling below defined values. You just have to add light intensity values, you want to be notified about, to ‘Notify on Exceed/Fall Below Intensities’ and handle ‘On Notify Exceed/Fall Below Intensity’ events in your Event Graph:

  1. Open your Character in the ‘Blueprint Editor’.
  2. From the ‘Components’ window choose ShadowStealthComponent.
  3. In the ‘Details’ window find the ‘Shadow Stealth’ category, and ‘Notify on Exceed Intensities’ and/or ‘Notify on Fall Below Intensities’ array properties in it.
  4. Add some light intensity values to one or both arrays.
  5. With ShadowStealthComponent still selected right-click on the ‘Event Graph’ window.
  6. In the popup menu expand ‘Add Event for Shadow Stealth’, then ‘Shadow Stealth’.
  7. Click on ‘Add On Notify Exceed Intensity’ or ‘Add On Notify Fall Below Intensity’.
  8. The event node has one parameter, ‘Intensity’, which gives the light intensity value this event concerns.

There are also convenience events that notify on light intensity exceeding or falling below AISight intensity bounds. You just have to enable ‘Notify on AISight Intensity Bounds’ flag and handle the appropriate event:

  1. Open your Character in the ‘Blueprint Editor’.
  2. From the ‘Components’ window choose ShadowStealthComponent.
  3. In the ‘Details’ window find the ‘Shadow Stealth’ category, and ‘Notify on AISight Intensity Bounds’ property in it.
  4. Check the ‘Notify on AISight Intensity Bounds’ checkbox.
  5. With ShadowStealthComponent still selected right-click on the ‘Event Graph’ window.
  6. In the popup menu expand ‘Add Event for Shadow Stealth’, then ‘Shadow Stealth’.
  7. Click on one of:
    • ‘Add On Notify Exceed AISight Intensity Hidden Lower Bound’
    • ‘Add On Notify Fall Below AISight Intensity Hidden Lower Bound’
    • ‘Add On Notify Exceed AISight Intensity Sighted Lower Bound’
    • ‘Add On Notify Fall Below AISight Intensity Sighted Lower Bound’
    • ‘Add On Notify Exceed AISight Intensity Upper Bound’
    • ‘Add On Notify Fall Below AISight Intensity Upper Bound’

If there is more than one event fired on one frame, they will be fired in an order:

  • Ascending for ‘exceeded’ events.
  • Descending for ‘fall below’ events.

Additional Features

Enable/Disable Light

If you want to disable stationary or movable LightComponent during gameplay you can set its:

  • ‘Visible’ property to ‘false’,
  • ‘Hidden in Game’ property to ‘true’.

Shadow Light Components will abide by those properties set on their parents. You can change this behavior by changing one of the following Shadow Stealth plugin settings:

  • ‘Use Invisible Lights’ – use light components with ‘Visible’ property set to ‘false’.
  • ‘Use Hidden in Game Lights’ – use light components with ‘Hidden in Game’ property set to ‘true’.

If you want to disable Shadow Light Component directly, you can set its ‘Enabled’ property to ‘false’.

Comments

Your email address will not be published. Required fields are marked *

Scroll to top