Re: [Solved] Need help on a raycasting light shader
Posted: Sun Jan 08, 2023 10:49 pm
Very interesting! And it's true that I didn't even ask myself the question when in general nothing is displayed immediately by an engine and several images can even be precalculated before display, it is perhaps the simplicity of Löve who made me believe it could be simple (big mistake) .
I still tried to repeat the same procedure by calculating not in love.draw but by calculating love.graphics.present in love.run and I found again the same results for the 3 shaders (~0.002 seconds on average on the same pc) so I finally also think that these are not good techniques.
Personally I would have learned things from this post, thank you once again !
Edit: I take this opportunity to specify in case someone is in the same situation as me and would like to use the last shader proposed by Sasha264, if the position of the object that the mask must cover is not at the origin of the screen (0,0), this time you need to subtract the position of the object from `screen_coords` AND `light_pos` (unlike the old one where `vec2 current_pos = screen_coords - mask_pos` was enough.
i.e.:
I still tried to repeat the same procedure by calculating not in love.draw but by calculating love.graphics.present in love.run and I found again the same results for the 3 shaders (~0.002 seconds on average on the same pc) so I finally also think that these are not good techniques.
Personally I would have learned things from this post, thank you once again !
Edit: I take this opportunity to specify in case someone is in the same situation as me and would like to use the last shader proposed by Sasha264, if the position of the object that the mask must cover is not at the origin of the screen (0,0), this time you need to subtract the position of the object from `screen_coords` AND `light_pos` (unlike the old one where `vec2 current_pos = screen_coords - mask_pos` was enough.
i.e.:
Code: Select all
vec2 a = screen_coords - mask_pos;
vec2 b = light_pos - mask_pos;