Page 1 of 1
OpenGL bug or canvas format limitation ?
Posted: Sun Jan 22, 2017 6:57 pm
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
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 !
Re: OpenGL bug or canvas format limitation ?
Posted: Sun Jan 22, 2017 7:51 pm
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
Re: OpenGL bug or canvas format limitation ?
Posted: Sun Jan 22, 2017 7:54 pm
by pedrosgali
Lol I was just about to say they did a really interesting numberphile on sandpiles but you beat me to it.
Re: OpenGL bug or canvas format limitation ?
Posted: Wed Jan 25, 2017 4:34 pm
by logoliv
some help please ?
Re: OpenGL bug or canvas format limitation ?
Posted: Wed Jan 25, 2017 6:11 pm
by GijsB
Ha that's me
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)
Re: OpenGL bug or canvas format limitation ?
Posted: Wed Jan 25, 2017 10:11 pm
by logoliv
Hi Gijs, nice to see you here
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)
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
Re: OpenGL bug or canvas format limitation ?
Posted: Thu Jan 26, 2017 1:17 am
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.
Re: OpenGL bug or canvas format limitation ?
Posted: Thu Jan 26, 2017 3:58 am
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.
Re: OpenGL bug or canvas format limitation ?
Posted: Fri Jan 27, 2017 2:30 pm
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?