Click to See Complete Forum and Search --> : OpenGL Identical Vertex Count


tcblake
April 5th, 2008, 05:09 PM
Hi,

I'm new to graphics programming, so please bear with my ignorance.

I'm looking for a way, _using the GPU and OpenGL_, to change the color of a rendered pixel depending on _how many_ identical (x, y, z) point vertexes are sent to the GPU from the application.

This isn't ordinary image manipulation of course, but real-time vertex position data from an acquisition card. I need to set pixel color differently for those vertexes that have been read multiple times during a sample period from those read fewer times. For example, if I get 187000 samples during a frame, and 4000 of those happen to be at one point, it should be a different color than another point that only had (say) 200 samples contributing. The number of possible points is 2K x 2K integers.

This is very easy to do in the app, but for timing reasons I need to offload it to the graphics card (NVidia 8800). Is there a way to do this within OpenGL?

Note that this isn't blending, nor is it doable with the accumulation buffer, because the "accumulation" needs to happen before any rendering occurs.

Any hints would be most welcome.

Thanks in advance.

Thomas Blake

STLDude
April 5th, 2008, 05:59 PM
The problem is that vertex program only works on one vertex (one in/one out).

Some ideas,
* During acquisition of your data if you can add another attribute to each vertex which will contain number of hits, then you could read that inside vertex shader and output color based on that.
* What about writing all your data first to render target, where each vertex would add small number to it (done in a pixel shader), then in the next pass you would read that render target (using as a regular texture into your texture sampler) and derive some color based on that.
* I have not looked into geometry shaders, but maybe there is something that might help you.

All this assumes that you will end using vertex and pixel shaders.