Shader not applied on small canvas

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Shader not applied on small canvas

Post 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.
Shallow indentations.
jjmafiae
Party member
Posts: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: Shader not applied on small canvas

Post by jjmafiae »

remember not all computers have canvas support keep that in mind :|
Gan_HOPE326
Prole
Posts: 7
Joined: Sun Apr 07, 2013 2:51 pm

Re: Shader not applied on small canvas

Post 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...?
User avatar
slime
Solid Snayke
Posts: 3175
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Shader not applied on small canvas

Post 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.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Shader not applied on small canvas

Post 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.
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Shader not applied on small canvas

Post 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.
Shallow indentations.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Shader not applied on small canvas

Post 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.
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Shader not applied on small canvas

Post 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.
Shallow indentations.
jjmafiae
Party member
Posts: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: Shader not applied on small canvas

Post 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
Gan_HOPE326
Prole
Posts: 7
Joined: Sun Apr 07, 2013 2:51 pm

Re: Shader not applied on small canvas

Post 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).
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 5 guests