Archived

This topic is now archived and is closed to further replies.

2do

Per Pixel Test

Recommended Posts

Hi I would like to know if it is possible to do a fast test if a pixel was rendered or not. (i''d like to use that for rendering my lensflares faster. at the moment i test if the line from the point to the camera intersects my bounding volumes or some triangles. but hey: this is so sloooow i guess it is possible to render just some white pixels and test for this if the lensflare is visible or not. how could i do this?

Share this post


Link to post
Share on other sites
Use gluProject to find the lensflare''s screen coordinates. Then use glReadPixels to get the depth buffer value at that point. Compare it with the z-value you got from gluProject. If it''s less than the one from the depth buffer, the lens flare is visible.

Share this post


Link to post
Share on other sites
but remember : Reading back from frame buffer is *slow*. It causes bubble in rendering pipeline and if not placed in right place it might crash your framerate.

You should never let your fears become the boundaries of your dreams.

Share this post


Link to post
Share on other sites
NO-NO don''t use VRAM reads. They are SLOW. And if I say SLOW I mean SLOOOOOOOOOOOW. Use NV_occlusion_query or do a raycast with the CPU.

Share this post


Link to post
Share on other sites
Hi! Thx for your answers!

So all those fancy 3D Engines out there use the NV extension is this also available for other 'newer' 3D Cards?
hmm... but whats up with older engines like unreal engine? would they trace a ray for every lensflare in frustrum? this seems to be a bottleneck for me... hmm. okay, i think it goes like this:


for every lensflare in frustrum
intersection := false
trace ray
if ray intersects bounding volume
test for every triangle
if there was an intersection
intersection := true
if intersection
draw lensflare


but hu. if there are objects with hundreds of polygons (imagine an enemy in front of a light source) and 20 lensflares... ugh. would this really work?

[edited by - 2do on August 18, 2002 7:50:55 AM]

Share this post


Link to post
Share on other sites
You can use a simple VRAM readback. It''s not slow, if you only read a single pixel. Around 90% of all engines out there do it like that.

It''s true that it creates a bubble in the command stream, but a very small one for a single pixel. Try to do it at the end of the frame. And if you''re not hopelessly geometry bound, then you won''t even notice a speed difference at all.

Just don''t start reading back hundreds or thousands of pixels per frame.

/ Yann

Share this post


Link to post
Share on other sites
to back up what Yann saiz, if glReadPixels(..) is a bottleneck then youre not using it correctly (unless youre reading 100,000''s pixels a frame)

http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share this post


Link to post
Share on other sites