Sign in to follow this  
Daichi

[XNA] 2D Flashlight Vision

Recommended Posts

[font="Calibri"][size="2"][font="arial, verdana, tahoma, sans-serif"][size="2"][font="Calibri"][size="2"][size="2"]Okay, so I have a simple 2D tile-based top-down game.[/size][/size][/font]

[font="Calibri"][size="2"][size="2"]I have these guards that are trying to spot the player. They have a field of view that I want to represent as a flashlight glow that lights up the area. This area will be where the guard can see, so I'll also need to detect if the player is inside one of the guards' views. Tiles can also block their vision.[/size][/size][/font]

[font="Calibri"][size="2"][size="2"]I guess I want something to look like this:[/size][/size][/font]
[font="Calibri"][size="2"][size="2"][attachment=2975:flashlight_vision.png]
[/size][/size][/font]
[font="Calibri"][size="2"][size="2"]I've seen stuff about ray tracing or field of view, but I'm not sure where exactly to start first. [/size][/size][/font][/size][/font][/size][/font][img]http://public.gamedev.net/public/style_emoticons/default/mellow.gif[/img]

Share this post


Link to post
Share on other sites
[quote name='remigius' timestamp='1307705269' post='4821671']
Does [url="http://www.catalinzima.com/2010/07/my-technique-for-the-shader-based-dynamic-2d-shadows/"]this tutorial[/url] help?
[/quote]

Do I actually need something this complicated? I don't necessarily need to cast light in all directions, just at a specific angle of view. heck, I don't even need to cast shadows, only a light overlay.


I should also specify that I'm trying to target WP7, which I think has problems with custom shaders.

Share this post


Link to post
Share on other sites
Ah yeah, for WP7 custom shaders won't work. I'm a bit out of the loop, but I think the phone just doesn't allow custom shaders at all (for now).

I can't seem to think of anything much simpler though. Whether you're casting shadows or light, the basic problem is the same. If you want the light to be occluded, the only techniques I can come up with are 2D versions of shadowmapping or shadow volumes. I did find [url="http://archive.gamedev.net/reference/articles/article2032.asp"]this tutorial[/url] and [url="http://krypton.codeplex.com/"]this engine[/url] that might both offer good ways to create 2D shadows.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this