Is Vertice Occluded with Slow glReadPixels
i do like this:
nx, ny, nz;
get (modelview),
get (projction)
get (viewport)
glu Project (vertx,verty,vertz, mv, proj, viewport, &nx, &ny, &nz);
now i''ve window coordinates of geometry vertice
from what i now want is to know if this vertice is
occluded and not in view (for example behind the wall) i quess
i need to read pixel from depthbuffer to get result
i do:
ReadPixels (vertx, verty, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
then i test like
if (depth<nz) { not visible occluded
else
visible vertice
but this is not working, anybody knows what is wrong ?
And can this like technique at all be used for
occlusion tests ?
thanks for reading this and sorry if this is asked million times.
there is no point to do this. that is what the z buffer is for. instead look into bsp, portals and other ways to help quickly determine the PVS (potential visible set) in the seen at runtime. reading from the depth buffer (which is in vram) for all your vertices (or even frustrum culled) would be MUCH slower then actually rendering those polys in many cases.
a person is right. you should (almost?) never read back form video card. this will kill your performance.
but if you just HAVE to do it then the problem is becouse coordinats form glunProject() do not go straight into ReadPixels(). You have to change Y value you get form glunProject to (window_height - Y); I hope this works...
You should never let your fears become the boundaries of your dreams.
[edited by - _DarkWIng_ on May 5, 2002 4:21:55 AM]
but if you just HAVE to do it then the problem is becouse coordinats form glunProject() do not go straight into ReadPixels(). You have to change Y value you get form glunProject to (window_height - Y); I hope this works...

You should never let your fears become the boundaries of your dreams.
[edited by - _DarkWIng_ on May 5, 2002 4:21:55 AM]
You should never let your fears become the boundaries of your dreams.
quote:
Original post by a person
there is no point to do this.
okey. btw, i've touched allready with bsp+pvs, and yes combination works very well to reject geometry, but, but it's not what i want to find now (Spatial partitioning).
occlusion stuff is new for me and very interesting.. i also know ReadPixels kills performance

but really what i'm trying to achieve is not to check
all (lol) vertices of world, ONLY vertices of for example huge bounding box of building that contains a hell much (million for example) of polygons
i don't know, but i think it is quicker (correct me if me wrong) to read this huge building bounding box vertices back with ReadPixels to find out is it visible or occluded than Render million (heh) of polygons contained in box's building, what do you think
couple of readpixels to skip building or renderr/transform million of polygons, obviously it is still not that easy

i get some results with above code i posted.. but they're very inaccurate
[edited by - glsimpson on May 5, 2002 5:26:06 AM]
[edited by - glsimpson on May 5, 2002 5:26:49 AM]
please don''t say me: use frustum culling to check if building is visible. it''s not what i want, i want to check possible occclusion.
Dark Wing: ok, gluProject y -> glReadPixels, i''ll check that.
Dark Wing: ok, gluProject y -> glReadPixels, i''ll check that.
>> don''t know, but i think it is quicker (correct me if me wrong) to read this huge building bounding box vertices back with ReadPixels to find out is it visible or occluded than Render million (heh) of polygons contained in box''s building, what do you think<<
perhaps not quicker on a gf but if youre doing this in a precalculation stage
draw everthing in one colour ''white'' draw the building''s bb in ''red'' read back the framebuffer to see if there are red pixels, if so it COULD BE visable (perhaps not).
if u are doing this in a precalculation stage then dont worry about the bb just draw the million vertex object + use the results.
if this is meant for real time the occulsion query extension is what u are after (with the objects BB)
http://uk.geocities.com/sloppyturds/gotterdammerung.html
perhaps not quicker on a gf but if youre doing this in a precalculation stage
draw everthing in one colour ''white'' draw the building''s bb in ''red'' read back the framebuffer to see if there are red pixels, if so it COULD BE visable (perhaps not).
if u are doing this in a precalculation stage then dont worry about the bb just draw the million vertex object + use the results.
if this is meant for real time the occulsion query extension is what u are after (with the objects BB)
http://uk.geocities.com/sloppyturds/gotterdammerung.html
What you are trying to do is already done:
hp_occlusion_test
Basically, hp_occlusion_test allows rendering(not to the visible buffer) a bounding box and checking if any of it is visible. NVidia''s latest drivers support it. Check out google for further info.
hp_occlusion_test
Basically, hp_occlusion_test allows rendering(not to the visible buffer) a bounding box and checking if any of it is visible. NVidia''s latest drivers support it. Check out google for further info.
or if you have geometry organized in some kind or octree or BSP it might be faster to trace a ray trough than causing GPU stall or flush
You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement