Occlusion queries inside shaders and "group objects queries" for HW-frustum culling

Originally posted by gamefreedom:
Have you tried implementing this using GLSL? It would be good to have a (at least speculative) comparison (in efficiency and difficulty) if you want to promote this suggestion. [/QB]
Yep, the problem with the current raytacing with the GPU is that there is no efficient way to discard AABBs with triangles inside from the fragment shader. You need some spatial structure to hierarchicly discard the triangles, and doubt this could be performed atm in a fragment shader like I want. So far I found:

        [http://www.clockworkcoders.com/oglsl/rt/gpurt1.htm](http://www.clockworkcoders.com/oglsl/rt/gpurt1.htm)            
        [http://gpurt.sourceforge.net/DA07_0405_Ray_Tracing_on_GPU-1.0.5.pdf](http://gpurt.sourceforge.net/DA07_0405_Ray_Tracing_on_GPU-1.0.5.pdf)            
        [http://graphics.stanford.edu/papers/gpu_kdtree/kdtree.pdf](http://graphics.stanford.edu/papers/gpu_kdtree/kdtree.pdf)           
[http://inferno.hildebrand.cz/index.php?f...p=0&r=&m=&dir=0](http://inferno.hildebrand.cz/index.php?fs=1&s=14&p1=0&p2=0&p3=0&p4=0&p5=0&p6=0&p7=&p8=&c1=0&c2=0&c3=0&c4=0&c5=0&c6=0&p=0&r=&m=&dir=0)     

These implementations are a nightmare and far from efficient ( tables show it, see last 128x128 drops near 0fps using only 1024 triangles )

Perhaps with the upcoming geometry shader you could hack it, but will be hard 8( And I finish with a reflexion… If the AGEIA ppu can do this by HW very easy ( see the closestHit function in the PhysX sdk )… why not a graphic card? And also Renderman can use the gatherPoints() function to achieve this…

So we need the “castRay” GLSL function and an extension to batch triangle groups so can be discarded fast using their AABB or something.