[XNA] 2D Flashlight Vision

Started by
2 comments, last by remigius 12 years, 10 months ago
[font="Calibri"][font="arial, verdana, tahoma, sans-serif"][font="Calibri"]Okay, so I have a simple 2D tile-based top-down game.[/font]

[font="Calibri"]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.[/font]

[font="Calibri"]I guess I want something to look like this:[/font]
[font="Calibri"][attachment=2975:flashlight_vision.png]
[/font]
[font="Calibri"]I've seen stuff about ray tracing or field of view, but I'm not sure where exactly to start first. [/font][/font][/font]mellow.gif
Advertisement
Does this tutorial help?
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!

Does this tutorial help?


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.
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 this tutorial and this engine that might both offer good ways to create 2D shadows.

Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!

This topic is closed to new replies.

Advertisement