LTC Real Time Area Lights

2025/09/10

WebGL demo.

This document will guide you through the usage of LTC light package. Here are showcases for different light type:

Polygon light:

img

Linear light:

img

Textured light:

img

Samples

There are two samples in package, you can import them from PackageManager’s Sample tab and play around. If no Sample tab appears, you can also copy Realtime Area Light/Samples~ folder to Assets.

Shader Graph Sample

It demonstrates how to customize a shader graph to make it receives LTC lighting.

When enter play mode, the light spawner will spawn polygon lights or linear lights randomly at random place, and there is also a polygon light whose polygon vertices is changing, shows how to set polygon light shapes at runtime.

Shader Code Sample

It demonstrates how to customize a hand written shader to make it receives LTC lighting.

The interesting part is the lazer beam simulated by a linear light combined with physics raycasting, which rotates around in play mode, and it will be occluded by obstacles. Linear lights are well suited for effects like light saber, laser scope.

Basic Usage

In order to usage LTC lights, there must exist one and only one LTCLightManager instance in scene. You can use the Prefabs/LTCManager.prefab directly.

The next step is to make materials’ receiving LTC lighting:

For Shader Graph

There is no way for us to intercept the lighting process of Fragment block, but we can just add our additional LTC lighting to the emission channel, which will be added to the final lighting result.

img

So what we need is add a LTCLighting node (inclued in this package) in shader graph, add input channels which is almost identical with Fragment block, and link output to Fragment block’s emission. You can just refer to the ShaderGraph sample.

For Shader Code

It’s also convenient to extend your hand written shaders to receive LTC lighting, there already exists helper functions to convert URP’s lit shader input to LTC lighting input, actually they are quite the same.

Use URP lit as an example, firstly we should include LTC shaders in LitForwardPass.hlsl:

#include "Packages/com.petabytes.ltclight/Shaders/LTC_URP.hlsl"

Then add LTC lighting after URP’s pbr calculation:

// For example in LitForwardPass.hlsl
InitializeBakedGIData(input, inputData);
half4 color = UniversalFragmentPBR(inputData, surfaceData);

// Add LTC lighting here
color.rgb += CalculateFragmentLTC(inputData, surfaceData);

That’s all!

The last step is adding LTC light instances in your scene.

LTC Lights

Currently we support polygon light, linear light and textured area light. More types will be added in the future such as bezier curve shaped area lights.

There are common attributes for both light types:

NameDescription
ColorLight color in RGB
Intensitylight intensity
RangeThe space range affected by light, it has different meaning for different light types, It will not be affected by transform scale, can be visualized when selected
Light ModeTo use diffuse lighting, specular lighting or both of them
Use World PositionUse object local space or world space for light shapes

Attributes polygon light specific

NameDescription
RangeThe radius of bounding sphere, places outside the sphere will not be lighted
Double SidedIf the polygon light affect both sides
PolygonPointsAssign customized polygon shapes, the polygon points should be 2D polygon, and centered at origin
PresetSome preset polygon shapes like pentagon, hexagon, etc. It’s an editor only attribute for convenience, not exist in runtime

Attributes linear light specific

NameDescription
RangeThe radius of a capsule shape, it determines the radius of caps and tube, places outside the capsule will not be lighted
Start PointThe start point of linear light, the center of start cap
End PointThe end point of linear light, the center of end cap
RadiusIt is not related with Range, it’s the thickness of the linear light, the thicker the brighter

Attributes textured light specific

NameDescription
IsRealTimeIf true, the texture prefiltering process will be executed each frame, which brings additional cost. Use it for content which is always changing, such as video textures
TextureThe texture of this light, it can be a static Texture2D, or some runtime generated RenderTexture
WidthThe width of textured light
HeightThe height of textured light