Shader outruns the player

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
yoyohoho
Prole
Posts: 14
Joined: Tue Apr 14, 2020 12:07 pm

Shader outruns the player

Post by yoyohoho »

Hey guys!

I'm playing around with shaders for the first time and though it's challenging it's a lot of fun.

I'm creating a 2D platformer, where the setting is a cave so I thought it would be neat to have the lightning only just around the player.
However, I'm having a problem where this eclipse of light simply outruns the player as the map starts scrolling (look at the GIF):
The attachment shader_problem.gif is no longer available
I have no clue why this is. I'm using a variable called playPosition that simply tracks the position of the player on the x-axis.
It's almost all in my main.lua which I have enclosed as well if you want to take a look. The shader-code is in the top while the shader is being drawn in love.draw.

I really hope one of you is able to help me. :awesome:
Attachments
shader_problem.gif
shader_problem.gif (59.87 MiB) Viewed 3879 times
sphyrth
Party member
Posts: 260
Joined: Mon Jul 07, 2014 11:04 am
Contact:

Re: Shader outruns the player

Post by sphyrth »

Before people start requesting for your love file, I think the problem has a connection with the camera.

Looking at your gif, the shader begins to have a problem the moment the camera begins scrolling with the player.
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: Shader outruns the player

Post by pgimeno »

Yeah, it looks like a double transformation.

main.lua is not there, by the way. The forum software is bugged when it comes to multiple attachments. It's not possible to be more specific without the code, sorry.
yoyohoho
Prole
Posts: 14
Joined: Tue Apr 14, 2020 12:07 pm

Re: Shader outruns the player

Post by yoyohoho »

sphyrth wrote: Tue Apr 21, 2020 7:47 am Before people start requesting for your love file, I think the problem has a connection with the camera.

Looking at your gif, the shader begins to have a problem the moment the camera begins scrolling with the player.
Just a little question, when you say that people are going to request my .love file, deos that mean that I should include the entire folder with all my game files or just a distributed version of the game?

Yes, you were right. It somehow added the position of the player (player.x) to the position of the camera (map.camX) so all I had to was to subtract the latter from the prior. Thank you so much!
yoyohoho
Prole
Posts: 14
Joined: Tue Apr 14, 2020 12:07 pm

Re: Shader outruns the player

Post by yoyohoho »

pgimeno wrote: Tue Apr 21, 2020 8:04 am Yeah, it looks like a double transformation.

main.lua is not there, by the way. The forum software is bugged when it comes to multiple attachments. It's not possible to be more specific without the code, sorry.
That's good to know, thanks. I figured it out (look at my reply to the first post), I'm not sure what a double transformation is, but it sounds like that might have been the issue.
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: Shader outruns the player

Post by pgimeno »

yoyohoho wrote: Tue Apr 21, 2020 8:18 am Just a little question, when you say that people are going to request my .love file, deos that mean that I should include the entire folder with all my game files or just a distributed version of the game?
It means something we can run and test, in order to be able to debug ourselves. The idea is that if you have the code and can't figure it out, you can't expect others to figure it out without the code. There aren't many cases such as this in which the problem is evident from the screenshot. Also, not many people post a screenshot.

Dummy replacement images would be OK, if it is runnable. A minimal .love file with just the code necessary to be able to see the problem, even without images, would also be OK.
yoyohoho
Prole
Posts: 14
Joined: Tue Apr 14, 2020 12:07 pm

Re: Shader outruns the player

Post by yoyohoho »

pgimeno wrote: Tue Apr 21, 2020 8:28 am
yoyohoho wrote: Tue Apr 21, 2020 8:18 am Just a little question, when you say that people are going to request my .love file, deos that mean that I should include the entire folder with all my game files or just a distributed version of the game?
It means something we can run and test, in order to be able to debug ourselves. The idea is that if you have the code and can't figure it out, you can't expect others to figure it out without the code. There aren't many cases such as this in which the problem is evident from the screenshot. Also, not many people post a screenshot.

Dummy replacement images would be OK, if it is runnable. A minimal .love file with just the code necessary to be able to see the problem, even without images, would also be OK.
Gotya, that makes perfect sense. I did include the main.lua file but I guess you couldn't see it due to the bug that you mentioned. I'll make sure to include it in future posts :)
Post Reply

Who is online

Users browsing this forum: No registered users and 192 guests