I am working on a 2d platformer where once a player goes below y=0 world darkens and they shoulb be able to use a flashlight to see in the dungeon. I followed 2D lights and shadows sample - #20 by Haath to get where i am with my implementation today. I am very new to game dev (few months) and Defold is my first game engine.
- Currently the light cone is rendered correctly and light collisions with tiles is working as expected
- I am also rendering entire world to RT and applying ambient color in the shader to make entire screen darker when user goes below y=0
My issue: I cannot figure out a way how to render the world behind the light cone when the whole screen is dark.
- I have tried passing a world texture to the fragment shader that draws the light, which works but the issue is that this texture is an entire screen whereas i only need it to be whats behind the light.
- I have attempted to render a small square around the player to an RT in hopes to pass that as texture but i honestly have no idea if its possible or not and it didnt really work…
Below area. a few screenshots of the current state. Any tips or help is appreciated.
Here is the branch for my code https://github.com/BetweenTwoPines/subterra-scavengers/compare/main...lighting-poc
It a bit of a mess as i probably have refactored everything a million times and at this point its pure frustration…