Graphics Reference
In-Depth Information
float t_top = 1.;
float t_bot = 1. - dt;
for( int it = 0; it < numLayers; it++, t_top = t_bot,
t_bot -= dt )
{
float smax_top = 1. - t_top;
float smax_bot = 1. - t_bot;
int nums = it + 1;
float ds_top = smax_top / float( nums - 1 );
float ds_bot = smax_bot / float( nums );
float s_top = 0.;
float s_bot = 0.;
for( int is = 0; is < nums; is++,
s_top += ds_top, s_bot += ds_bot )
{
ProduceVertex( s_bot, t_bot );
ProduceVertex( s_top, t_top );
}
ProduceVertex( s_bot, t_bot );
EndPrimitive( );
}
}
The results of this shader, when you start with two four-sided pyra-
mids, are shown in Figure 12.8. The figure shows the resulting approxima-
tions for several different subdivision levels. Level 3 is a reasonable approxi-
mation of a sphere, and it would not take many more levels to make this
sphere look very good indeed. The fact that this expansion can include a
varying number of subdivisions makes it a good candidate for LOD opera-
tions and the like.
However, there is one subtle problem with using geometry shaders for
general LOD work. For speed, emited vertices are meant to be carried in mem-
ory on the graphics chip. Thus, there is a limited amount of space to hold them.
As of this writing, most graphics cards limit geometry shaders to 1024 emited
vertices. This is good for line LOD, such as the Bézier curve, but surface LOD,
such as the sphere, consumes those 1024 very quickly. The tessellation shader
is probably a beter way to do actual surface LOD.
Search WWH ::




Custom Search