## Can someone explain how to use shaders in love2d

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Prole
Posts: 29
Joined: Sat Jun 07, 2014 10:30 pm

### Can someone explain how to use shaders in love2d

vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords )

How do I use the line above?
What a wonderful caricature of intimacy

veethree
Inner party member
Posts: 805
Joined: Sat Dec 10, 2011 7:18 pm

### Re: Can someone explain how to use shaders in love2d

Code: Select all

shader = love.graphics.newShader([[
vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords )
{
}
]])

Prole
Posts: 29
Joined: Sat Jun 07, 2014 10:30 pm

### Re: Can someone explain how to use shaders in love2d

Still don't understand..
What a wonderful caricature of intimacy

veethree
Inner party member
Posts: 805
Joined: Sat Dec 10, 2011 7:18 pm

### Re: Can someone explain how to use shaders in love2d

Please elaborate, What exactly don't you understand?

Party member
Posts: 495
Joined: Fri May 03, 2013 6:42 pm
Location: Germany

### Re: Can someone explain how to use shaders in love2d

Zilarrezko
Party member
Posts: 345
Joined: Mon Dec 10, 2012 5:50 am
Location: Oregon

### Re: Can someone explain how to use shaders in love2d

I think he's really fresh to shaders. Seeing his recent posts, he seems eager to do shaders yet no one really gave him help. Only a let me google that for you even though documentation on Löve's way to do shaders has it's differences, the differences aren't documented well at all.

While veethree's post was very straight forward, I think really the new people need some guidance into the transition into Löve's shaders easier, rather than "Just read this post".

Really since I don't know a lot about it myself due to the bad documentation... and since apparently there are no very good GLSL tutorials out there (at least that's what I'm told).

Neverthe less I suggest you learn a good bit of C++ and then GLSL version 120. I found a decent series by a nice Hungarian man here. And yes that series is in version 120 of GLSL (which Löve uses)

Löve does like it says on the page in the wiki that was posted above, or, here; make some things simple, by passing in variables as arguments in the function that Löve runs for shaders (variables like sampler2D and texture coordinates and screen coordinates).

Another way you could possibly learn is by reading the code from this post tree. However if you're like me, that will boggle your mind and you will get confused.

I tried to make code for that per-fragment lighting shader in that tutorial series I linked. However I got frustrated that it didn't work and for some reason or rather. I think, Slime said that normals don't work the same in Löve as they do in openGL or something on a per vertex basis or something.

To be honest I've hit a wall there so I'm dropping it for a while. I still have no idea how to make anything I want in shaders, or what anything is. But I can make every pixel red, hopefully that counts right? Maybe you'll have better luck? In any case good luck man, and sorry for the long post. I'll probably get chewed out for being an idiot. Have a good one.

OmarShehata
Party member
Posts: 259
Joined: Tue May 29, 2012 6:46 pm
Location: Egypt
Contact:

### Re: Can someone explain how to use shaders in love2d

Just thought I'd leave this here, you guys might find it useful.

Do let me know if this was useful, or if you still have questions that we could maybe tackle in another post.

kikito
Inner party member
Posts: 3150
Joined: Sat Oct 03, 2009 5:22 pm
Contact:

### Re: Can someone explain how to use shaders in love2d

That blogpost was very helpful, thanks Omar!
When I write def I mean function.

Zilarrezko
Party member
Posts: 345
Joined: Mon Dec 10, 2012 5:50 am
Location: Oregon

### Re: Can someone explain how to use shaders in love2d

Very helpful is an understatement in my case. It's pretty much necessary if you're starting out with GLSL and Löve's shaders.

I really hope you continue that because a lot of people will thank you for it. It's a shame there is no "follow author's content" option in those blogs. Or at least I'm not seeing one.

If I can really understand the content I'm willing to make video tutorials of it, unless you were planning that already.

undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

### Re: Can someone explain how to use shaders in love2d

Thank you Omar!
A lot of people have been waiting for this, including me!