pixijs / lights

Adds dynamic lighting via deferred shading to PixiJS
https://pixijs.io/lights/docs/index.html
MIT License
205 stars 29 forks source link

How to implement the shadow like FOV ? #15

Closed finscn closed 8 years ago

finscn commented 8 years ago

I want to create a game with FOV (Field of vision/view ) and Fog Of War.

Like http://christmasexperiments.com/experiments/11 . and http://www.unwinnable.com/wp-content/uploads/2013/06/Monaco.jpg https://7yrl.files.wordpress.com/2013/12/helives.png http://www.playchilla.com/wp-content/uploads/2012/12/2d-shadows.png http://i.imgur.com/B8g2o7b.jpg http://lab.wx3.com/temp/screenshot01.jpg

Could pixi-light help me ? How to implement ?

Thanks

P.S. : I know the algorithm of FOV , and I could implement it on Canvas2D with hard-edge. like this https://camo.githubusercontent.com/88bfed3e14132b417d9f5c7d01bca0b9a803abf9/687474703a2f2f692e696d6775722e636f6d2f335371706942542e6a7067 .

But I don't know how to create a FOV with soft-edges and dynamic 2d lighting effect by Pixi.js

englercj commented 8 years ago

Raycasting is a common way of doing this: http://www.redblobgames.com/articles/visibility/

Just a matter of building the occlusion map with the ray casting, bluring it, then using it as a mask.

This lib doesn't implement shadows, but the experiment you linked does so that might be helpful as well.

finscn commented 8 years ago

I've read this article two years ago and I said "I know the algorithm of FOV , and I could implement it on Canvas2D with hard-edge." P.S. : the Raycasting is not a good way.

Whatever , thanks a lot.

englercj commented 8 years ago

Raycasting is the most common way of doing this. You raycast, develop the results into geometry that you draw using the method I described.

finscn commented 8 years ago

this example : http://christmasexperiments.com/experiments/11
Don't use this project ?

englercj commented 8 years ago

No it does not, it was written before this plugin was created and while it uses "deffered rendering" it is done in a more specific way to fullfill the requirements of the Christmas Experiment.

This library implements a simple deferred renderer and normal rendering.