Hi Zach -- Querying the stencil/depth buffer would be expensive, since it effectively flushes the graphics pipe. However, if you run with vsync enabled and assuming your rendering load is light enough, there might be time to query the stencil/depth buffer after you issue the swap. The results of the query could be used for rendering glare in the next frame. Query the stencil/depth buffer using glReadPixels().
As an alternative, OpenGL now supports an occlusion feature. Render all possible occluders first, then enable occlusion query, render the Sun, and disable occlusion query. During vsync, ask OpenGL how many pixels were rendered during the occlusion query, and use the results in the next frame's glare rendering. This could, in theory, give you better results than sampling six points as you're doing now, since it should give you the total number of "sun pixels" visible. Note that both of these techniques use the previous frame's computations for the next frame's rendering, so they require strong frame-to-frame coherency. Finally, we'd have to let Robert comment on the computeIntersections function, as I'm not familiar with it. But I have to wonder if there are some optimizations you could make. If there are some objects in your scene that you know could never occlude the Sun, don't spend time checking for occlusions against them, that sort of optimization. Good luck with that, Paul Martz Skew Matrix Software LLC http://www.skew-matrix.com 303 859 9466 > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Zach Deedler > Sent: Saturday, December 09, 2006 5:48 PM > To: 'osg users' > Subject: [osg-users] Sun occlusion > > Hello, > > PROBLEM > I want to change the size of the sun's glare dependent on if > it is occluded. > > INVESTIGATION > I implemented this using the computeIntersections function. > I convert the sun's 3D coordinates to screen coordinates. > I check for about 6 intersections with various points on the sun. > This affects performance by about 5Hz. > Checking for 1 intersection still affects frame rate greatly. > > QUESTION > 1) Anybody have ideas how to make this more efficient? > 2) Would the LineOfSight class be better to use? > 3) Would using the depth or stencil buffers be better? If > so, how do I query the depth buffer? > > Thanks. > > Zach > > _______________________________________________ > osg-users mailing list > [email protected] > http://openscenegraph.net/mailman/listinfo/osg-users > http://www.openscenegraph.org/ _______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
