# Light sweep effect

This topic is 2163 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How do I create effect like CC Light Sweep effect in After Effects or like this Light Sweep Image Processor on page 67. I'm trying to implement this effect in HLSL.

Any resource on how this effect is done or where to find it would be appreciated!

Thanks!

EDIT: I need to implement this as a pixel shader that is applied to a texture (that has alpha channel) before it is drawn to 2D scene.

Edited by zz2

##### Share on other sites

Considering this is a light effect, you can take a look at photon mapping if you want to model this physically accurate to some extend.

Should you not want to go through that trouble that much, you can perhaps use projected textures (search for examples with caustics).

##### Share on other sites

Oh I don't need real 3D light effect. I just need to apply animated light sweep effect to 2D texture (that has alpha channel) before drawing it onto a scene. Its for 2D game. I am sorry, I should have been more clear about that in my original post.

Basically I just need to write a shader that will generate an angled line that has highest intensity at the center of the line's width. Then I would animate line's position to move it across the texture.

Optionally: An edge detection that produces an emboss like effect for light sweep like the CC Light Sweep effect in After Effects would be a nice bonus, but it is not required for effect I need to work.

##### Share on other sites

Alright.

Well you already gave the answer yourself really, you can draw a line at the angle you need and use a fall off from the interpolated values to make it less bright when going out. You would need to look up the math for it.

Another way would be to use another texture as a mask and multiply the black/white values of your "light sweep mask" with the original color.

Another option would be to use the alpha channel if it's not used for anything. Would be used in the same manner as the mask.

Hope it helps

##### Share on other sites

I managed to write a simple shader. In the end I didn't even use angle calculation (i just assumed its a line falling at 45°, because i don't really need variable angle in this case).

Here's the shader. Its really crude (fixed angle, limited fall off, no other fancy stuff), but it works:

float4 color;
color = tex2D(input , uv.xy);
color.rgb /= color.a; //unpremultiply

float sweep = progress - 0.5;
sweep *= (1 + fuzzyAmount);

float uvDistanceFromLine = abs((uv.x-sweep)-(uv.y+sweep));
float intensity = 1 - saturate((uvDistanceFromLine + fuzzyAmount) / (2 * fuzzyAmount));
color.rgb += intensity * opacity;
color.rgb *= color.a; //premultiply

return saturate(color);


"progress" parameter is animated from 0 to 1 in game for light sweep effect.

• 11
• 9
• 17
• 13
• 11