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
Before you make a thread asking for help, read this.
badfitz66
Prole
Posts: 29
Joined: Sat Jun 07, 2014 10:30 pm

Can someone explain how to use shaders in love2d

Post by badfitz66 » Wed Jun 25, 2014 7:33 pm

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

User avatar
veethree
Inner party member
Posts: 814
Joined: Sat Dec 10, 2011 7:18 pm

Re: Can someone explain how to use shaders in love2d

Post by veethree » Thu Jun 26, 2014 7:25 am

Code: Select all

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

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

Re: Can someone explain how to use shaders in love2d

Post by badfitz66 » Thu Jun 26, 2014 2:54 pm

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

User avatar
veethree
Inner party member
Posts: 814
Joined: Sat Dec 10, 2011 7:18 pm

Re: Can someone explain how to use shaders in love2d

Post by veethree » Thu Jun 26, 2014 3:24 pm

Please elaborate, What exactly don't you understand?

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

Re: Can someone explain how to use shaders in love2d

Post by MadByte » Thu Jun 26, 2014 3:38 pm

Read this.

User avatar
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

Post by Zilarrezko » Thu Jun 26, 2014 5:36 pm

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. :nyu:

User avatar
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

Post by OmarShehata » Tue Jul 01, 2014 10:18 am

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

http://blogs.love2d.org/content/beginners-guide-shaders

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

User avatar
kikito
Inner party member
Posts: 3152
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Can someone explain how to use shaders in love2d

Post by kikito » Tue Jul 01, 2014 10:32 am

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

User avatar
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

Post by Zilarrezko » Tue Jul 01, 2014 7:37 pm

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.

User avatar
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

Post by undef » Tue Jul 01, 2014 11:42 pm

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

Check out quadrant on Steam!

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests