2D Spotlight implementation (HLSL + C#)

By April 11, 2012 Blog, Games, XNA Games 3 Comments
blog_post_lightspot

Many people have been asking me how i implemented the spotlight inside my xbox game wages of war. See screenshot at top.

The red light on the left, and the spots on the wall are all the implementation of the spotlight.

I rely inside this post that you have implemented the system that i described inside my post 2D Lightning Continued.

Inside this tutorial a point light is created. Now you can use the following code to implement a spotlight class in the same manner as we did with the point light.
Basically they are almost the same, but this spotlight has some different properties to give to the Shader.

I updated the Lightning sample as that is easier (i hope) for you to understand what you have to implement to achieve this effect in your game.

The arrow keys control the angle of the spot light and up, down control the height of the spot.

Enjoy!

 

Download link:

LightningSample - Spotlight Addon (1001)

 

3 Comments

Leave a Reply