Particle Multi-Directional Light Shader

Today I started working on a fake volumetric particle shader that simulates lights from six directions. I wanted to make some improvements to just using the default lit particle shading in unreal, its nice but has a very flat appearance.

The first thing I did was add contrast and gamma controls for the user in order to quite drastically alter the amount of light that appears to hit parts of the billboard. This gives us the ability to make quite different looking particle effects from the same texture sheet. This is particularly important as this technique requires two textures and therefore is more memory intensive than a single flipbook sheet.

1

I just used a contrast node in UE4, here’s the contrast being adjusted. Contrast tends towards extremes, lengthening the distance between the darkest blacks and brightest whites.

2c6c0ef387674fedec358439dc4c4cb8

For gamma I just raised the texture to a power. This tends to affect midtones more. A higher gamma value boosts the darker parts of the image, while one less than 0 make the dark regions lighter. Default gamma for most displays is 2.2, but a value of 1.2 was pretty nice. I’d done some gamma correction in Houdini which might be throwing things off.

92534ebad12e93108b5116426d5b0544

 

This is the interesting part! To create that volumetric look, we want to know how far from our imaginary 6 lights that each pixel of the billboard is, in order to determine its intensity.

To do that, we take the texture, and dot it with a unit vector. As the texture is not normalized, we are projecting the texture onto the light direction which returns the length of that projection.

Diving the texture by this result gives us varied intensity based on distance – when the pixel is receiving less light (based on the texture), the intensity is raised.

3

Here’s what the effect with adjusted gamma and contrast looks like with and without the light direction adjustment.

629540694f713d6f5953d7ce608b74ef

The current result looks something like this! Next is figuring out how to blend my textures with the particle colour!

2

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s