Blending lots of frames

I’d like to blend the previous N frames of DirectShow video, where N is at least 100.

As a first approximation, I’ve fed the video into a VideoTexture, then into a Quad, and into a renderer with Clear: 0. The key is a SetAlpha on the Quad using white and Alpha: 0.1

This approximation works for up to around N=10 (Alpha=1/N), but after that there are really noticable posterization effects.

I started a new approach of storing the output of VideoTexture in a Queue, but I’m not sure what sort of operation I might do on the output spread that wouldn’t have the same posterization problems.

Any ideas?

the alpha channel aswell as the color channels have only 8 bit, that means 256 steps. if you devide that by 100 (thats what the alpha basically does, it multiplys the color with its value), there are only 3 steps left for every color channel, that means you have 27 colors. only idea i have, is to try to convert your video source with an extra renderer into a 64bit HD texture format and store that into the queue…

Thanks for the quick response :)

Right – bit depth is essentially the issue. I was looking at the Renderer inspektor to see if I could try what you reccomend, but I’m not sure how. I see “Windowed Backbuffer Format”, which lets me select some lower bit depths, but nothing higher.

If there’s any way of working with the frames/textures at a greater depth, that would be a solution. (At least, up to some max N)

It would also work if there was a way of scripting the blending. So if N was a power of two I could blend halves of the queue recursively. Is there any way to do this?

yes, i think a 64bit color format should solve the issue - watch out for color formats with some 16 in. but this is only available on more recent hardware.

you could try something like inputting 16 textures from a queue in the shader, using floating point calculations inside and then rendering that.

the other classic technique is applying 1/N noise each time you do a rendering. you will get a lot of noise, but no posterizing.