Heyo!
As a part of my quest to learn every bit of programming possible, I would like to start getting my feet wet in shaders! the incredible complex as it seems shading system!
So I just have a few questions, because I'm a bit confused on whats happening here. And as a confused idiot, complex words will confuse me more! So! here we go!
1) Where to do shaders?
Can I just write the shader code in my np++ and flick it on or off? Yet from what I'm hearing is I have to go through GLSL and write the code in C++ in something like visual studios and then save it as some type of file?
2) How to implement into Love?
I'm thinking I can just do shaderObey = love.graphics.newShader(file) and then apply it with another setShader function or something like that. Is that it? or... yeah?... no?... maybe?
3) Where's the tutorials at?
I looked on the wiki, couldn't really find anything. Tried copying code from the wiki and drawing random stuff. That didn't work... And using someone else's code never works for me because I seem to never be able to use it worth 3 kidney beans and a tuna.
Can anyone point me to tutorials on the process of making a simple shader like... changing color? (not sure what an easy shader would be) and implementing? But you may have probably already answered that in the first two. (basically asking for support to the first two questions)
4) tips? tricks? tulips?
anything else? pointers? advice?
Thanks in advance and Have a Love-ly day (see what I did there?)
Point me to the path of shaders.
- Zilarrezko
- Party member
- Posts: 345
- Joined: Mon Dec 10, 2012 5:50 am
- Location: Oregon
- SneakySnake
- Citizen
- Posts: 94
- Joined: Fri May 31, 2013 2:01 pm
- Contact:
Re: Point me to the path of shaders.
GLSL is the language you write shaders in.Zilarrezko wrote:1) Where to do shaders?
Can I just write the shader code in my np++ and flick it on or off? Yet from what I'm hearing is I have to go through GLSL and write the code in C++ in something like visual studios and then save it as some type of file?
You can write GLSL anywhere you can write plain text. You don't have to touch C++ at all.
Yes, that's pretty much it. The wiki doesn't lie.Zilarrezko wrote:2) How to implement into Love?
I'm thinking I can just do shaderObey = love.graphics.newShader(file) and then apply it with another setShader function or something like that. Is that it? or... yeah?... no?... maybe?
http://www.love2d.org/wiki/love.graphics.newShader provides a basic introduction.Zilarrezko wrote:3) Where's the tutorials at?
I looked on the wiki, couldn't really find anything. Tried copying code from the wiki and drawing random stuff. That didn't work... And using someone else's code never works for me because I seem to never be able to use it worth 3 kidney beans and a tuna.
Can anyone point me to tutorials on the process of making a simple shader like... changing color? (not sure what an easy shader would be) and implementing? But you may have probably already answered that in the first two. (basically asking for support to the first two questions)
As for GLSL tutorials, not really sure. I never really checked out any. According to the wiki, LÖVE uses GLSL 1.20. You could try googling "GLSL 1.20 tutorial" and look around.
Hey, here is a small example:
Code: Select all
local shader
function love.load()
shader = love.graphics.newShader[[
uniform float t;
vec4 effect(vec4 color, Image tex, vec2 tc, vec2 sc) {
float r = sin(sc.x / sc.y * 8 + (mod(t, 32) * 24));
float g = sin(sc.y * sc.x / 8 + (mod(t, 32) * 16));
float b = sin(sc.x - sc.y + 8);
return vec4(r, g, b, 1);
}
]]
love.graphics.setShader(shader)
end
function love.draw()
shader:send('t', love.timer.getTime())
love.graphics.rectangle('fill', 0, 0, 800, 600)
end
Be vigilant! There lie many dangers on the path of shaders.Zilarrezko wrote:4) tips? tricks? tulips?
anything else? pointers? advice?
- Zilarrezko
- Party member
- Posts: 345
- Joined: Mon Dec 10, 2012 5:50 am
- Location: Oregon
Re: Point me to the path of shaders.
holy coconut pill bottle batman! amazing! spectacular! simpler than I thought! Grand! Tubular!
Thank you snake! I may now embark on this path of shaders!
And away! I go!!!
Thank you snake! I may now embark on this path of shaders!
And away! I go!!!
- Zilarrezko
- Party member
- Posts: 345
- Joined: Mon Dec 10, 2012 5:50 am
- Location: Oregon
Re: Point me to the path of shaders.
Bam! i'm back, cause this is a tough subject it seems. Is there anything interactive to play around with? I mean sure I can take the code you posted and play around with it, yet I can't find anything that explains things in a simplistic way with pretty pictures and/or something interactive. It's like reading a bad textbook... This is not how I expected anything at all haha. I thought there were plenty of nice looking tutorials that would tell me ("here's how to make this. Here's the code. Here's what this line is doing, here's what the other one is doing. This function takes this variable which is this. yadadfadadadadadadadadadada")
I skimmed through a bit of http://www.lighthouse3d.com/tutorials/glsl-tutorial/ and I found that I have no idea what's going on! Doesn't even seem to be any code to transfer from there to Love's semi shading language. Even if there was GLSL code I have no idea about either syntax or any of the objects that I'm messing with. Kinda lost, not going to lie.
Seems like I need a background of openGl, which I really don't... I followed a tutorial once and made a colorful triangle. But gave up when I couldn't make points move. which is sad. I'm pretty sad...
How am I suppose to use this language to create something that I can visualize? at this point I just change some values, times by modulus of t by 3 and bam spits out some pretty florescent colors.
This is probably going to turn into a Q&A topic
I skimmed through a bit of http://www.lighthouse3d.com/tutorials/glsl-tutorial/ and I found that I have no idea what's going on! Doesn't even seem to be any code to transfer from there to Love's semi shading language. Even if there was GLSL code I have no idea about either syntax or any of the objects that I'm messing with. Kinda lost, not going to lie.
Seems like I need a background of openGl, which I really don't... I followed a tutorial once and made a colorful triangle. But gave up when I couldn't make points move. which is sad. I'm pretty sad...
How am I suppose to use this language to create something that I can visualize? at this point I just change some values, times by modulus of t by 3 and bam spits out some pretty florescent colors.
This is probably going to turn into a Q&A topic
- DaedalusYoung
- Party member
- Posts: 413
- Joined: Sun Jul 14, 2013 8:04 pm
Re: Point me to the path of shaders.
I kind of agree with you. I've said it before; the reason I like LÖVE so much is part because of its awesome documentation. I've looked at similar frameworks, also the 3D ones, and found there was just a lack of proper documentation, so I'd be lost all the time, and I'm not the kind of person to ask questions about something in the forum, I want to be able to find things out for myself.
I feel the same about shaders. I've seen a tutorial or two about GLSL, but it's just poorly written, assuming previous knowledge I don't have. And even then, on top of that, LÖVE has a slightly different syntax to it, so even if I'd master GLSL, I'd still not know how to write a shader.
I must admit, I haven't read the one you just linked, but from what I can tell by looking at the first page; it starts by saying things are already deprecated. So that makes me think it either will or won't work, or will break in the next LÖVE release. And then how do I fix that, if they don't teach the right stuff?
I feel the same about shaders. I've seen a tutorial or two about GLSL, but it's just poorly written, assuming previous knowledge I don't have. And even then, on top of that, LÖVE has a slightly different syntax to it, so even if I'd master GLSL, I'd still not know how to write a shader.
I must admit, I haven't read the one you just linked, but from what I can tell by looking at the first page; it starts by saying things are already deprecated. So that makes me think it either will or won't work, or will break in the next LÖVE release. And then how do I fix that, if they don't teach the right stuff?
- Zilarrezko
- Party member
- Posts: 345
- Joined: Mon Dec 10, 2012 5:50 am
- Location: Oregon
Re: Point me to the path of shaders.
thumbs up ^
Who is online
Users browsing this forum: No registered users and 3 guests