Jump to content

Does this example still exist? Point Light


the-simian
 Share

Recommended Posts

point-light

I was browsing the dev logs and was curious about maybe adding a point light, like in this image. I know I could add a custom GL pipeline, but I figured since this image exists, maybe at once time there was a demo showing how to do this with Phaser 3. can this still be done (as of about v 3.10.x)  or is this gone? Thank you to anyone who knows :)

or this...

dungeon

Where the tilemap is blocking the point - light.

Link to comment
Share on other sites

Wow, that's old stuff - right back from 2015 iirc! This never even made it past the very first R&D builds. There are no shadows in v3 currently (so you can't emulate the images above), although it's definitely something that will be added eventually.

Link to comment
Share on other sites

You can kind of fake it!

...it's distinctly slower than if it was all done in a GL pipeline but it still looks cool and is sufficiently performant if carefully applied (the jitter in the gif is a result of screencap, the scene runs at 60pfs):

fakeshadows.gif.a7289b464c24a86d92f04e2db64e4d07.gif

 

It's basically two layers:

The background (becomes the unlit version) that has the tint set to the ambient color of the light. Next I add the layer that I want to have lit and apply a geometry mask based on a raycast from my light's point. Red Blob Games has a good guide on how raycasting works & how to implement it. My code is not quite in a state that it would be useful to share though I can try to nudge it in that direction if folks want.

There are plenty of caveats and limitations on what you can do with this but for a lot of situations this can probably get you pretty close to what you had in mind.

best of luck, lmk if you have any questions :D

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...