LOD stands for Level of Detail. This node lets you specify alternative
representations of a graphical object, and the distance ranges to use each
representation.
The following fields are defined:
level specifies the set of alternative representations of a
graphical object
center specifies a 3D point to which the distance is computed.
range specifies a set of distances, floating point values greater
than or equal to zero. There must N distances specified, if N+1 levels
are specified. The distances must be ordered starting from the smaller
distance, otherwise the results are undefined. If this field is left empty
then this is a hint to the browser telling it that it should select a level
where a constant display rate can be accomplished.
Syntax:
LOD {
level []
center 0 0 0
range []
}
This node can have a major impact on the performance of a browser, therefore
its role can't be overstated. Look at the following figure
In it you see three cylinders. The left one which isn't really a cylinder,
more like a pyramid, has only four sides, the middle one has 8 sides, the
right one has 16 sides. These cylinders were created using Extrusion
nodes.
You can see that they are different by the way they reflect light. Now
look at the next figure.
The above figure includes the same three cylinders but placed further away
from the user. It is becoming difficult to distinguish between the right
and middle cylinders, although you can still clearly see the difference
between the left cylinder and the other two.
In the above figure the user is further away from the cylinders than in
the previous figure and as a result it is harder to distinguish which is
the more detailed, and the less detailed cylinder.
This sequence of images has a single purpose: to show that with distance
the perception of the details in an object becomes harder. This is the
reasoning behind the LOD node. Why draw very complex shapes when they are
too far away from the user for details to be recognized? The more complex
a shape is the more demanding is the task of drawing it. If an object is
far away there is no benefit in drawing the object full of detail.
The LOD node can be used in the following way:
if the user is close to the object draw the most detailed version
when the user is not close anymore, but still not to far away draw
a less detailed version
when the user is very far away draw only a crude version of the object.
By selecting less detailed versions when the user is not close to a object,
time is saved and the user perceives no difference due to distance. You
can specify as many levels of detail as desired. The user should try to
keep changes from one level of detail to the next as small as possible
so that a performance break will not occur.
The LOD can also be used to avoid drawing objects which are invisible,
for instance in another room. In this case one can specify an empty object,
for instance a Shape without a
geometry.
The range field specifies which version of the object is drawn.
The objects should be specified in the level field by decreasing
level of detail. If the distance from the user to the object is smaller
than the first range specified, then the first version, the more
detailed, will be drawn, if the distance is between the J-1 and J ranges,
then the Jth version is drawn. If the distance is greater than
the last range specified, with an index I, then the Ith
version is drawn.
The main problem is knowing how much is "close", "not to
far away", and "very far away". This is perhaps something
the browser developers should think about, providing coordinates for the
user's position.
If browsers did provide the user's position then one could have the several
versions with different levels of detail of the object drawn at the origin,
then the user would move away from the objects until no difference was
perceived between the full detailed version and a slightly less detailed
version. The user's position could then be used to compute the distance
when the level of detail should be changed. This procedure would be repeated
for all levels of detail until all versions looked the same.
Unfortunately most browsers do not provide the user's position so it becomes
a matter of trial and error.
Source code exemplifying the use of a LOD node:
#VRML V2.0 utf8
LOD {
range [20,40]
level [
#full detail 16 sided cylinder
Shape{
appearance Appearance { material Material { diffuseColor 1.0 1.0 1.0}}