[osg-users] distant nodes in orthographic projection turn black

Peter Amstutz peter.amstutz at tseboston.com
Wed Mar 18 07:41:01 PDT 2009

I am having a puzzling problem that I hope someone might have some 
insight on what is happening:

My application renders a terrain using a top-down, orthographic view, 
and places various icons (simple flat meshes mostly) to represent 
simulation agents (soldiers and vehicles).  One of our testers noticed 
that when you zoom out to a certain distance where the icons are very 
small but still visible, sometimes some of the units (always the medium 
and small icons) turn black.  Zooming in restores the proper color.  It 
is very sensitive to the projection parameters, sometimes it is 
correctly rendered at moderate zoom, turns black after zooming out, and 
then is colored properly again after zooming out even more.

Some details:
The icons are ordinary geode nodes.  They use flat color materials, no 
textures.  The icons are composed of several submeshes, usually text on 
a background with a border.  It's hard to say, but usually only one of 
the submeshes turns black.

The camera is held at a fixed Z elevation, and "zooming" is accomplished 
by changing the orthographic projection parameters to have a wide view 
or a narrow view.  Panning on the XY axis changes only the XY camera 

The scene is lit with a single downward-facing infinite light.  It casts 
(.8, .8, .8) colored ambient light.

I'm using the default setting for Near-Far culling plane.

Icons are scaled based on a logarithm function of the zoom level 
(meaning that at high zoom levels the icons are scaled up a bit from 
their natural sizes, but not linearly with the zoom level).  I scale the 
icons by updating the transform matrix and calling dirtyBounds().

This behavior is sensitive to the elevation of the camera.  When the 
camera was located at an elevation of 10000 units (meters) many of the 
icons would exhibit this problem, when the camera was lowered to 1000 
units, fewer icons rendered improperly, and at 300 units everything 
rendered just fine.

So, tentatively the solution is simply to ensure that the camera is 
placed as close to the action as possible, but if anyone has any ideas 
as to what is really going on here, I would be very curious.  Perhaps I 
am running afoul of some "small object" optimization, that culls objects 
thought to be too small to show up on screen?

- Peter

More information about the osg-users mailing list