Is there a convenient way to access individual pixels of an image?

I’d like to manipulate pixels one by one in some manner. I hate writing in low-level languages like GLSL though, especially with no autocompletion and error highlighting. So I don’t care about performance now, I just want to access pixels of an image like img[y][x] or smth similar.

However, on my own I only found how to use ByteBuffers with images loaded as ColorBuffers, which is doable but very far from a concise and simple syntax. Is there an alternative?

Hi there,
when I have the need to manipulate pixels in a color buffer I use the shadow attribute. Here’s little example where I fill a color buffer with Perlin noise

 val noise = colorBuffer(width,  height)
        val shadow = noise.shadow
        shadow.download()
        for (x in 0 until width){
            for (y in 0 until height){
                    shadow[x, y] = ColorRGBa.WHITE.opacify(perlin2D(10, x * 0.01, y * 0.01) * 0.5 + 0.5)
            }
        }
        shadow.upload()

I don’t know if this is what you are looking for, but maybe it’s a starting point.

1 Like

Oh, turns out I’m not able to read a single article to the end. Welp, thanks, this looks like exactly what I wanted!

1 Like