Page 1 of 1

PixelEffects, Y U NO WORK?

Posted: Sat Dec 10, 2011 3:26 pm
by Metalcookie
So I've read the GLSL documentation, have read the readme on GLSL in Löve2D thousands of times and have searched everywhere on the forum and wiki..

All I'm trying to do is add some horizontal blur to the show. I've downloaded several .love files of examples of blur shaders, and looked a few simple examples up outside of Löve2D. Based on those examples, I made my own one ("my own one": 2% of it is my own work) and whatever I do, it won't work.

I have no problems at all running other people's .love files with shaders but whatever I make won't work ("won't work": Will compile without errors but there's no difference in the output with or without effects). I've included a .love file with purely the effect I'm trying to work with. (press space to apply the effect to the image)

Any ideas?

Info:
Löve2D version: 0.8.0 (10 dec)
OS: Win7 64-bit
Graphics card: AMD Radeon HD 6850

Re: PixelEffects, Y U NO WORK?

Posted: Sat Dec 10, 2011 5:09 pm
by slime
In glsl/pixeleffect syntax, all floating point numbers (numbers of the type 'number'/float) needs to have a decimal.

Code: Select all

number blurSize = 1/800;
needs to become

Code: Select all

number blurSize = 1.0/800.0;

Re: PixelEffects, Y U NO WORK?

Posted: Sat Dec 10, 2011 5:22 pm
by Metalcookie
slime wrote:In glsl/pixeleffect syntax, all floating point numbers (numbers of the type 'number'/float) needs to have a decimal.

Code: Select all

number blurSize = 1/800;
needs to become

Code: Select all

number blurSize = 1.0/800.0;
It works! I guess I'm not used to such a massive lack of forgiveness.

Re: PixelEffects, Y U NO WORK?

Posted: Sat Dec 10, 2011 5:28 pm
by slime
Something that's really annoying is that nvidia cards have more relaxed GLSL rules than ATI cards, so if you have an nvidia card and you make a mistake like that you might not notice until it fails on someone else's computer.

Re: PixelEffects, Y U NO WORK?

Posted: Sat Dec 10, 2011 5:39 pm
by Metalcookie
Then I'm glad I have an ATI card.. But how about those Intel cards?

Also, I just noticed that the picture I used must be very familiar to you..

Re: PixelEffects, Y U NO WORK?

Posted: Sat Dec 10, 2011 7:31 pm
by slime
Oh god... don't even get me started on intel cards. I recently tried a pretty simple equality test in a shader for something using my ATI card, and when I switched to my Intel card it returned true under the exact opposite circumstances that it was supposed to!

Re: PixelEffects, Y U NO WORK?

Posted: Sun Dec 11, 2011 4:02 pm
by Metalcookie
I'm really gonna stop with PixelEffects after this because I keep bumping into problems where I don't know what's causing them..

So now I want to change the blur effect in such a way that I can set the amount of samples it takes. I tried this using a for-loop, but somehow it just won't work again.

What I'm trying to do is replacing this(which works):

Code: Select all

sum += Texel(tex, tc - vec2(4.0*blurSize, 0.0)) * 0.6;
sum += Texel(tex, tc - vec2(3.0*blurSize, 0.0)) * 0.7;
sum += Texel(tex, tc - vec2(2.0*blurSize, 0.0)) * 0.8;
sum += Texel(tex, tc - vec2(blurSize, 0.0)) * 0.9;
sum += Texel(tex, tc + vec2(blurSize, 0.0)) * 0.9;
sum += Texel(tex, tc + vec2(2.0*blurSize, 0.0)) * 0.8;
sum += Texel(tex, tc + vec2(3.0*blurSize, 0.0)) * 0.7;
sum += Texel(tex, tc + vec2(4.0*blurSize, 0.0)) * 0.6;
by this(which doesn't):

Code: Select all

for (number i = 1.0; i >= 4.0; i += 1.0){
	sum += Texel(tex, tc + vec2(i*blurSize, 0.0)) * (1.0-(i/10.0));
	sum += Texel(tex, tc - vec2(i*blurSize, 0.0)) * (1.0+(i/10.0));
}
Because with the latter, I can change the "4.0" in "i >= 4.0;" to the amount of samples I want to take.

But it fails to do anything useful with 'sum' other than to leave it alone..

In the .love file I attached, it applies the effect after pressing space. The blur on the x-axis uses the for-loop, while the blur on the y-axis doesn't.

EDIT: I might also add that I'm doing this effect on a white dot surrounded by emptiness, so the sum will never exceed 1.0 even though the weights are high.

Re: PixelEffects, Y U NO WORK?

Posted: Sun Dec 11, 2011 4:09 pm
by bartbes
I'm pretty sure you want <=.

Re: PixelEffects, Y U NO WORK?

Posted: Sun Dec 11, 2011 4:15 pm
by Metalcookie
bartbes wrote:I'm pretty sure you want <=.
I even know how I made that mistake..
It's because I tried two possible solutions to an earlier problem, which included changing it to '>='. But the other solution was the solution that solved it, and without realizing I left this 'solution' in. That's what I get for rushing this stuff, I guess.