Page 2 of 2

Re: Shader not applied on small canvas

Posted: Mon Apr 15, 2013 12:37 pm
by Boolsheet
The primitives (circle, rectangle, polygon, ...) do not set texture coordinates (they default to zero, I think), so it will end up with the same color for all pixels. Due to some implementation specific detail in LÖVE, it will try to sample from the last image that was drawn. It may be undefined behaviour if no texture is bound.

You could use the screen coordinates instead. Calculate how far away the center is and return the right color for that spot. Note that these coordinates are in [0, screen_width] and [0, screen_height], or the same with the Canvas size if one is set. For the top-left pixel, the value would be its center (0.5, 0.5). If FSAA is activated, it will be somewhere around that.

Also note that the origin of these coordinates for the screen is at the bottom-left and Y positive will be up. Canvases are not affected by this. Older OpenGL versions do not have a setting to change that and a workaround requires precious uniforms.

Re: Shader not applied on small canvas

Posted: Mon Apr 15, 2013 2:31 pm
by jjmafiae
remember not all computers have canvas support keep that in mind :|

Re: Shader not applied on small canvas

Posted: Tue Apr 16, 2013 5:25 pm
by Gan_HOPE326
jjmafiae wrote:remember not all computers have canvas support keep that in mind :|
Well, I was hoping to use them to minimize the amount of calculations for some elements like procedurally-generated backgrounds to which shaders have been applied, to avoid re-drawing them for each frame. Is there another way to do this...?

Re: Shader not applied on small canvas

Posted: Tue Apr 16, 2013 5:33 pm
by slime
Gan_HOPE326 wrote:
jjmafiae wrote:remember not all computers have canvas support keep that in mind :|
Well, I was hoping to use them to minimize the amount of calculations for some elements like procedurally-generated backgrounds to which shaders have been applied, to avoid re-drawing them for each frame. Is there another way to do this...?
Canvases are the best way to do this, I believe. At some point you have to make a choice about minimum system requirements versus using useful game / graphics features.
Nearly every system except for some extremely low-end old computers (especially old laptops) with Intel GMA or ancient AMD/nvidia cards will support canvases.

Re: Shader not applied on small canvas

Posted: Tue Apr 16, 2013 6:07 pm
by T-Bone
I think 0.8 has a software backend for Canvases that's used if the hardware doesn't support it. So it should work on practically every computer. But it's not something you can guarantee.

Re: Shader not applied on small canvas

Posted: Tue Apr 16, 2013 6:18 pm
by Boolsheet
T-Bone wrote:I think 0.8 has a software backend for Canvases that's used if the hardware doesn't support it.
No, it does not. It only takes what the graphics driver gives. Certain drivers may fall back into software mode for some things (don't think the Canvas is one of them), but that should be very rare.

Re: Shader not applied on small canvas

Posted: Wed Apr 17, 2013 6:22 am
by T-Bone
Boolsheet wrote:
T-Bone wrote:I think 0.8 has a software backend for Canvases that's used if the hardware doesn't support it.
No, it does not. It only takes what the graphics driver gives. Certain drivers may fall back into software mode for some things (don't think the Canvas is one of them), but that should be very rare.
Hm? That's interesting, because in 0.7.2, my Netbook didn't support Framebuffers, but on 0.8.0 Canvases work. And I think I remember reading about some alternative back-end that made that possible. But I guess it was some other change they did that fixed it for me, then.

Re: Shader not applied on small canvas

Posted: Wed Apr 17, 2013 10:00 am
by Boolsheet
The code did change from 0.7.2 to 0.8.0 and it's possible that your driver reacts more friendly to the newer version. 0.9.0 will cover even more possible OpenGL configurations. They are special cases that needed to be known and have their own Canvas-setup code.

Re: Shader not applied on small canvas

Posted: Wed Apr 17, 2013 7:09 pm
by jjmafiae
slime wrote:
Gan_HOPE326 wrote:
jjmafiae wrote:remember not all computers have canvas support keep that in mind :|
Well, I was hoping to use them to minimize the amount of calculations for some elements like procedurally-generated backgrounds to which shaders have been applied, to avoid re-drawing them for each frame. Is there another way to do this...?
Canvases are the best way to do this, I believe. At some point you have to make a choice about minimum system requirements versus using useful game / graphics features.
Nearly every system except for some extremely low-end old computers (especially old laptops) with Intel GMA or ancient AMD/nvidia cards will support canvases.
yes i should have mentioned that my bad

Re: Shader not applied on small canvas

Posted: Fri Apr 19, 2013 8:00 am
by Gan_HOPE326
slime wrote:
Gan_HOPE326 wrote:
jjmafiae wrote:remember not all computers have canvas support keep that in mind :|
Well, I was hoping to use them to minimize the amount of calculations for some elements like procedurally-generated backgrounds to which shaders have been applied, to avoid re-drawing them for each frame. Is there another way to do this...?
Canvases are the best way to do this, I believe. At some point you have to make a choice about minimum system requirements versus using useful game / graphics features.
Nearly every system except for some extremely low-end old computers (especially old laptops) with Intel GMA or ancient AMD/nvidia cards will support canvases.
I see, thanks. I'll decide later then, depending on whatever looks better, since I'm still unsure about using shaders. But I guess I'd be ok with using Canvases: if I didn't, those low end computers would probably STILL have trouble (without Canvas use, even my laptop with an nVidia Geforce GT drops to 20 fps if it has to apply the shader frame by frame).