Quick question about GPGPU

I think this is a common issue with gpgpu, as this happens in pretty much every project i do.

when i sample uv in my simulation/gpgpu fragment shader, there appears to be some rounding errors
i sample them like so
prevPosition.a = rand(gl_FragCoord.xy / textureRes)

has anyone bumped into this issue before? if so, how did you solve it?

What alibi has the rand(...) function? Usually pseudo random generators are more suspicious than floating point precision.

1 Like

sorry i posted the wrong code lol (although you can see how some of the subsequent points have matching color), points in those gaps do not exist, it’s not a color problem but a uv sampling problem. here’s the correct line of code

vec3 position = vec3(gl_FragCoord.xy / textureRes, 0.0);

^ here, it samples everything correctly but it leaves those strange gaps, the amount of gaps and their position are different for different resolutions, the gpgpu resolution for this example is 200x200

this is a common issue i’ve had for ages btw

I officially give up. The provided amount of code (just a single line) is insufficient for me to debug it and to extract any hypothesis.

Possible reasons (in descending probability order) are:

  • a bug in your code (it could be in lines 276-283)
  • a discrepancy between canvas sizes, css sizes, pixel ratios, etc
  • the browser has issues with GPGPU
  • the driver is buggy (or not updated)
  • there is really a bug in the GPU

But let me answer your questions:

I have never experiences such black lines. I have never resolved such issue.

I hope someone else might provide some help.

1 Like

huh really? i thought this was a really common thing since i bump into it so often, regardless of which of the many ways of implementing gpgpu i use. i thought it was easily recognizable and therefore didn’t post much code thinking that people would pick up on it, that’s my bad

i’ll setup a codesandbox tomorrow to make it easier, really strange if no one else has ran into this issue before

It’s not that we don’t run into bugs… ( well maybe @PavelBoytchev doesn’t :slight_smile: ) but… just that to diagnose something as complex as a visual/spatial anomaly in a gpgpu app, based on nothing more than random snippets of code, and a screenshot, is basically/usually/often a Giant waste of time for everyone involved. The issues are Verry rarely in the snippet of code that you might think its in, and in order to approach debugging things you really need a working reproduction, like a codepen/fiddle/glitch to even start figuring it out. (sometimes the issue is easy like that, and those questions are super satisfying)…
And as volunteers here, we get our kicks from solving problems because doing so helps heal our own past traumas, so when a freaky problem shows up, but there isn’t enough info to go on, and all the steps to help us succeed in figuring it out haven’t been taken, it’s very frustrating (for me at least)… because you’ve clearly taken some time to make the screenshot and sort of describe the issue, and we don’t want to waste your time or ours.
There’s also the question of like… the fact that we often work in our day jobs for real money, and so taking 20/30 minutes to dig into someones problem, is the equivalent of taking a 100 dollar bill and burning it to help a stranger. (brain cells and elevated cortisol in reality) :smiley:

For your problem, it could be a rounding error where you’re multiplying some 0 to 1 float by some Integer dimension value, and then truncating the result, without adding a .5 in there before you do so.

vec3 position = vec3((gl_FragCoord.xy+.5) / textureRes, 0.0);

But that’s just a completely wild guess based on super limited information, and likely just adding noise to the discourse!

Just my2c on the psychology involved.

2 Likes