OpenGL bug or canvas format limitation ?

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.
Post Reply
logoliv
Prole
Posts: 29
Joined: Mon Jan 27, 2014 3:05 pm

OpenGL bug or canvas format limitation ?

Post by logoliv »

I develop shaders using Löve for many years, but it's the first time I really don't understand what happens, I really need help here...
I just ported this shader (https://www.shadertoy.com/view/MtGXRK) to Löve and after some iterations I don't have the same result as the model anymore :death:
I suspect that perhaps the floor or mod functions are defective in OpenGL 1.2, or perhaps RGBA32f canvas format is not sufficient for big integers ? (not so big anyway, as the max pile here is 20000, 160000 on Shadertoy)
Any help will be welcome !
Last edited by logoliv on Thu Jan 26, 2017 11:33 am, edited 8 times in total.
logoliv
Prole
Posts: 29
Joined: Mon Jan 27, 2014 3:05 pm

Re: OpenGL bug or canvas format limitation ?

Post by logoliv »

For those interested in mathematics and who want to know more about sandpiles, here's a video on Numberphile that explains them :
https://www.youtube.com/watch?v=1MtEUErz7Gg
pedrosgali
Party member
Posts: 107
Joined: Wed Oct 15, 2014 5:00 pm
Location: Yorkshire, England

Re: OpenGL bug or canvas format limitation ?

Post by pedrosgali »

Lol I was just about to say they did a really interesting numberphile on sandpiles but you beat me to it. :)

Code: Select all

if not wearTheseGlasses() then
  chewing_on_trashcan = true
end
logoliv
Prole
Posts: 29
Joined: Mon Jan 27, 2014 3:05 pm

Re: OpenGL bug or canvas format limitation ?

Post by logoliv »

some help please ?
User avatar
GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

Re: OpenGL bug or canvas format limitation ?

Post by GijsB »

logoliv wrote: I just ported this shader (https://www.shadertoy.com/view/MtGXRK)
Ha that's me :D

Also i'm currently checking your source code..

Got it : When you draw a canvas it gets converted back to rgba8, I've the same problem with my pathmarcher :(.

(So when your draw the buffer to temp the shader gets destroyed)
logoliv
Prole
Posts: 29
Joined: Mon Jan 27, 2014 3:05 pm

Re: OpenGL bug or canvas format limitation ?

Post by logoliv »

Hi Gijs, nice to see you here :ultrahappy: as the Shadertoy comments are somewhat limited...

temp is just a placeholder to say to Löve to draw on buffer with love.graphics.setCanvas(buffer) which has 32 bit floating point format ("r32f"). When I draw to the screen with love.graphics.setCanvas(), the information about sand piles is still stored in buffer (which is read only in disp shader) :cool:

I've coded other Löve shaders using RGBA32f canvas format and had no problem with it, the difference is that I always stored small floating point numbers and not big integers like sandpiles. As I seriously doubt that the problem comes from a bad port of the functions floor() and mod() to Löve, my best candidate for now is that RGBA32f format has limitations in Löve that are not present in the Shadertoy implementation...

I've also opened a bug report here : https://bitbucket.org/rude/love/issues/ ... on-problem
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: OpenGL bug or canvas format limitation ?

Post by slime »

I replied to the bitbucket issue:
slime wrote:It is not immediately obvious to me what you're expecting it to look like compared to what it actually looks like to you.

However you are sampling from a texture that you are rendering to in the same shader. This is undefined behaviour in all graphics APIs and will result in unpredictable results on any GPU, OS, or framework used.

You also have alpha blending active when your shaders are active, and the temp Canvas stores normalized [0-1] colors rather than floating point since you don't specify any particular format so LÖVE uses the default rgba8.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: OpenGL bug or canvas format limitation ?

Post by raidho36 »

Do you even need 32 bit floating point texture here? Pretty sure sandpiles require no more precision than 3 bits, making rgba8 format more than sufficient.
User avatar
GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

Re: OpenGL bug or canvas format limitation ?

Post by GijsB »

raidho36 wrote:Do you even need 32 bit floating point texture here? Pretty sure sandpiles require no more precision than 3 bits, making rgba8 format more than sufficient.
To get the correct result a sandpile needs a lot of sand, not an infinite amount(so no infite replenishing), so more precision is needed.
slime wrote:I replied to the bitbucket issue:
slime wrote:It is not immediately obvious to me what you're expecting it to look like compared to what it actually looks like to you.

However you are sampling from a texture that you are rendering to in the same shader. This is undefined behaviour in all graphics APIs and will result in unpredictable results on any GPU, OS, or framework used.

You also have alpha blending active when your shaders are active, and the temp Canvas stores normalized [0-1] colors rather than floating point since you don't specify any particular format so LÖVE uses the default rgba8.
So how could we inplement a backbuffer correctly?
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 7 guests