Antiochos's picture

Additive blending with overflow - Is this even possible?

I'm curious if there's any way to get a colour to wrap around when it hits its max value to 0 again with OpenGL. It's for a screensaver effect - I figure I'll end up doing it by texture manipulation, but I thought I'd toss it out here to see if there's something I missed.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

I can't think of a way to do this through blending, but this would be simple to implement in a shader.

winterhell's picture

One way would be to render your scene to an offscreen rgba16i texture, and then draw that on the screen with a simple shader that does fract() on the whole color. There might be a need to normalize the color /255 before doing the fract part.
I think you'd need GL.ClampColor(ClampColorTarget.ClampReadColor, ClampColorMode.False); when reading the texture.
And finally with that texture you'd be able to wrap the pixels only 255 times. In that case you'll either ping-pong the values with another texture every now and then,or use a rgba32i texture.

Sorry for being vague, I havent encountered this exact scenario before.