Selecting Area

Started by
5 comments, last by Ashaman73 13 years, 9 months ago
Hi,

So, I'm working on a progressive refinement radiosity implementation. Evidently, I need to render a scene and find out what ratio of pixels is filled by a given object.

For example, ideally, given objects 1, 2, and 3 in a scene, if the scene were to be rendered, I'd like to know that:
-object1 would cover 11% of the screen's pixels
-object2 would cover 5% of the screen's pixels
-object3 would cover 0% of the screen's pixels
-therefore, 84% of the pixels would not covered

The obvious solution is to render the scene, read back the pixels, and then count them in software, but this seems inelegant and slow. Is there a better way? Perhaps using the selection or feedback buffers?

Thanks,
G

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

Advertisement
I think you can accomplish this with occlusion queries.
Exactly what I needed. Thanks!
Here's a good example: http://developer.download.nvidia.com/SDK/9.5/Samples/samples.html

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

Hi,

Hmmmm, seems the solution is slightly more complicated. I need to be able to test at least 560 different elements, and preferably around a million. glGetQueryivARB(...) is telling me I only have 32 to work with . . .

Second opinions?

Thanks,
G

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

I'm now using glReadPixels and a RGB indexing system (256^3 possible indices). Seems to be working all right, I suppose. No other OpenGL way? Occlusion querying seemed so perfect . . .

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

Quote:Original post by Geometrian
I need to be able to test at least 560 different elements, and preferably around a million. glGetQueryivARB(...) is telling me I only have 32 to work with . . .
AFAIK, you can issue more than one query at once.
In my opinion occlusion queries are not the way to go. The overhead to handle queries and potentielly destroying your renderpipeline by setting up thousands of queries. Then there's the problem of z-buffering. You need to render the scene first to the z-buffer else you will get incorrect results from your queries.

Use PBOs to speed up the read back of the buffer, then use multithreading (each thread get its own "secondary" array to avoid locking, see previous thread ) to utilize multiple cores while rendering the next patch to an secondary framebuffer.


This topic is closed to new replies.

Advertisement