Page 5 of 6

Re: Love2d GLSL Shaders

Posted: Sat Jul 26, 2014 7:05 pm
by AndreyMust19
Hello, guys. I'm ask here.

With

Code: Select all

vec4 effect(vec4 color, Image texture, vec2 tc, vec2 pc) {
vec4 pixel = Texel(texture, tc)
return pixel*color
}
drawing images, but not drawing lines, circles and rectanges (they not have texture).

And with

Code: Select all

vec4 effect(vec4 color, Image texture, vec2 tc, vec2 pc) {
return color
}
drawing lines, but not images (just fills color).
How to draw images and drawable-primitives with one shader? How to find what no have texture coordinates?

Re: Love2d GLSL Shaders

Posted: Sat Jul 26, 2014 7:36 pm
by slime
The first one will work in both cases, because the Texel function will always return pure white when drawing untextured things.

Re: Love2d GLSL Shaders

Posted: Sun Jul 27, 2014 8:38 am
by AndreyMust19
Create new project.

Draw-code:

Code: Select all

if settings.effect ~= 0 then love.graphics.setPixelEffect(effects[settings.effect]) end
	love.graphics.draw(image);
	love.graphics.setColor(255,255,255,255)
	love.graphics.rectangle('fill',0,0,200,100)
love.graphics.setPixelEffect()
NO SHADER
Image

NORMAL SHADER
Image
[[
vec4 effect(vec4 color, Image texture, vec2 tc, vec2 pc)
{
return Texel(texture, tc)*color;
}
]]
GRAYSCALE
Image
[[
vec4 effect(vec4 color, Image texture, vec2 tc, vec2 pc)
{
vec4 pixel = Texel(texture, tc);
float gray = (pixel.r + pixel.g + pixel.b)/3;
pixel.r = gray;
pixel.g = gray;
pixel.b = gray;
pixel.a = color.a
return pixel;
}
]]
What i doing wrong? Why rectangle is gray, not white ('grayscale2' is just name of normal shader)?
What standart shader love2d used, for 'blend' mode?

Re: Love2d GLSL Shaders

Posted: Sun Jul 27, 2014 8:45 am
by slime
The issue is that you're using LÖVE 0.8.0 (which has been superseded for over half a year already.) What I said only applies to 0.9.0 and newer - update your LÖVE! You'll need to update your code too, but it's worth it.

Re: Love2d GLSL Shaders

Posted: Sun Jul 27, 2014 10:12 am
by Jeeper
slime wrote:The issue is that you're using LÖVE 0.8.0 (which has been superseded for over half a year already.) What I said only applies to 0.9.0 and newer - update your LÖVE! You'll need to update your code too, but it's worth it.
To add to this, updating your code will not take long at all. I had a quite huge project that took 5-10min or so to convert.

Re: Love2d GLSL Shaders

Posted: Sun Jul 27, 2014 5:38 pm
by Ref
Presume you have this figured out by now. If not, look at attachment.

Re: Love2d GLSL Shaders

Posted: Mon Jul 28, 2014 5:41 pm
by AndreyMust19
Thx all for helping. Anyway game almost ready.

Re: Love2d GLSL Shaders

Posted: Sat Oct 11, 2014 3:30 pm
by AndreyMust19
Hello again!

How with shader transform from:
Image
to this:
Image

I think, need drawing of image down? How it make at GLSL?

Re: Love2d GLSL Shaders

Posted: Sun Oct 12, 2014 10:22 am
by Germanunkol
If the shapes you're showing are meshes, using vertices, then you should look into vertex shaders.

Vertex shaders can take a vertex and move it somewhere else, think of it as "positioning" objects.

However, it's not quite clear what you want to do: Are the shapes moving? Do you know exactly where the shapes are? Or are they somewhere else every time?

In any case, the method above is not the best way to go - instead, create the shapes in Lua and then move them in Lua.
Or why does it need to be in glsl (why on the graphics card?)

Re: Love2d GLSL Shaders

Posted: Sun Oct 12, 2014 10:33 am
by Zilarrezko
It took me a couple look overs to see what was happening.

The shapes from the top image are "smeared" downward. Kinda like how lighting creates a shadow, this is kinda what's happening here. Except It's not like a point light, it's like a wave of light or something from the top.

I am very unfamiliar with working with shaders, and in no way can manipulate them to do something that I would like without basically copying someone else. So when I saw it yesterday, I passed it by.

However, I did see something that had a very similar effect.

I would guess you would do what he is doing. Though you don't need to bend the objects like he did with rectangular to polar.