Page 1 of 1

PixelEffect:send() throws error if uniform unused

Posted: Sun Nov 11, 2012 2:21 pm
by SaxonDouglass
Hello everyone,

I am working on a jam game using Love 0.8.0 and have an issue with PixelEffect. I would really appreciate your help.

I have several shaders that I would like to switch between at run-time, but some of them use uniforms and some of them don't.

If I try to send() the data to a PixelEffect without the uniforms, it throws an error. I can't just declare the uniforms in the shader because they get optimized out.

Is there some way of silencing the error on Love2D's end, or can I trick the GLSL optimiser into leaving the uniforms in?

Thank you,
Saxon

Re: PixelEffect:send() throws error if uniform unused

Posted: Sun Nov 11, 2012 4:50 pm
by Xgoff
SaxonDouglass wrote:Hello everyone,

I am working on a jam game using Love 0.8.0 and have an issue with PixelEffect. I would really appreciate your help.

I have several shaders that I would like to switch between at run-time, but some of them use uniforms and some of them don't.

If I try to send() the data to a PixelEffect without the uniforms, it throws an error. I can't just declare the uniforms in the shader because they get optimized out.

Is there some way of silencing the error on Love2D's end, or can I trick the GLSL optimiser into leaving the uniforms in?

Thank you,
Saxon
you'll probably just have to pcall those send calls

Re: PixelEffect:send() throws error if uniform unused

Posted: Sun Nov 11, 2012 10:29 pm
by SaxonDouglass
Thank you very much Xgoff, I had forgotten about pcall(). That should do the trick.

Regards,
Saxon

Re: PixelEffect:send() throws error if uniform unused

Posted: Tue Nov 13, 2012 8:22 am
by SaxonDouglass
I have been unable to get pcall() to work. I have tried it two different ways, but it still throws an error and blue screens:

Code: Select all

pcall(pixelEffect.send(pixelEffect, "rubyTextureSize", {200, 100}))

Code: Select all

pcall(pixelEffect:send("rubyTextureSize", {200, 100}))
Is there any other way I could silence or avoid this error?

Re: PixelEffect:send() throws error if uniform unused

Posted: Tue Nov 13, 2012 8:35 am
by kikito
The syntax is:

Code: Select all

pcall(function, param1, param2, ...)
So in your case:

Code: Select all

pcall(pixelEffect.send, pixelEffect, "rubyTextureSize", {200, 100})

Re: PixelEffect:send() throws error if uniform unused

Posted: Tue Nov 13, 2012 12:47 pm
by SaxonDouglass
Thank you very much kikito, that works.

I'll make sure to double-check the syntax in future.