Chapter 3:
Node Reference
Intro
Anchor
Appearance
AudioClip
Background
Billboard
Box
Collision
Color
ColorInterpolator
Cone
Coordinate
CoordinateInterpolator
Cylinder
CylinderSensor
DirectionalLight
ElevationGrid
Extrusion
Fog
FontStyle
Group
ImageTexture
IndexedFaceSet
IndexedLineSet
Inline
LOD
Material
MovieTexture
NavigationInfo
Normal
NormalInterpolator
OrientationInterpolator
PixelTexture
PlaneSensor
PointLight
PointSet
PositionInterpolator
ProximitySensor
ScalarInterpolator
Script
Shape
Sound
Sphere
SphereSensor
SpotLight
Switch
Text
TextureCoordinate
TextureTransform
TimeSensor
TouchSensor
Transform
Viewpoint
VisibilitySensor
WorldInfo
|
PointLight {
exposedField SFFloat ambientIntensity 0 # [0,1]
exposedField SFVec3f attenuation 1 0 0 # [0, )
exposedField SFColor color 1 1 1 # [0,1]
exposedField SFFloat intensity 1 # [0,1]
exposedField SFVec3f location 0 0 0 # (- , )
exposedField SFBool on TRUE
exposedField SFFloat radius 100 # [0, )
}
The PointLight node specifies a point light source at a 3D location
in the local coordinate system. A point source emits light equally in
all directions; that is, it is omnidirectional. PointLight nodes are
specified in the local coordinate system and are affected by ancestor
transformations.
Section "2.6.6 Light sources" contains
a detailed description of the ambientIntensity, color,
and intensity fields.
A PointLight node illuminates geometry within radius meters
of its location. Both radius and location are affected by ancestors'
transformations (scales affect radius and transformations affect
location). The radius field shall be >= 0.0.
PointLight node's illumination falls off with distance as specified
by three attenuation coefficients. The attenuation factor is
1/max(attenuation[0] + attenuation[1]×r + attenuation[2]×r2, 1),
where r is the distance from the light to the surface being illuminated.
The default is no attenuation. An attenuation value of (0, 0,
0) is identical to (1, 0, 0). Attenuation values must be >= 0.0.
A detailed description of VRML's lighting equations is contained in
"2.14 Lighting model."
TIP:
Implementations typically only perform lighting at each vertex
in the scene. This means that large polygons and PointLights tend
not to work very well together. Imagine a PointLight at the origin
with a radius of 100 m, illuminating a square that is centered
at the origin and has sides 1,000 m long (perhaps the square functions
as a ground plane for your world). Most implementations will perform
only four lighting calculations for the square, one at each vertex.
None of the vertices are lit by the PointLight because they are
too far away. The result will be a square that is dark everywhere,
instead of a square that is bright near the origin and dark near
the edges. The solution is to break the square up into multiple
pieces so that more vertices are used to draw the same picture,
forcing implementations to do more lighting calculations. The
more it is broken up, the more accurate the lighting calculationsand
the slower the scene will be rendered. Content creators must balance
the need for good-looking scenes against constraints on how many
lit vertices an implementation can process per second.
One
common technique is to fake point and spotlights by precomputing
appropriate texture maps, with lighting and shadows built-in.
This works very well as long as the lights and geometry don't
move relative to each other, but the number of texture maps required
can quickly make this impractical for scenes that are sent across
a slow network connection.
|
TIP:
The radius field of PointLight and SpotLight restricts the
illumination effects of these light sources. It is recommended that
you minimize this field to the smallest possible value (i.e., small
enough to enclose all of the Shapes that you intend to illuminate)
in order to avoid significant impacts on rendering performance.
A safe rule to live by is: "Never create a file in which the radius
fields of the light sources exceed the bounding box enclosing all
the Shapes in the file." This has the nice property that prevents
light sources from bleeding outside the original file. Keep in mind
that, during rendering, each Shape must perform lighting calculations
at each vertex for each light source that affects it. Thus, restricting
each light source to the intended radius can improve performance
and create files that will compose nicely. |
EXAMPLE
(click to run) :
The following example illustrates a simple case of the PointLight
node (see Figure 3-44). This file contains three PointLights.
The first light is positioned between the Sphere and the table
and shows the effects of light attenuation with distance (i.e.,
slight effect on the Box and Cone). The second light is positioned
to the right side of the Cone, but has specified no attenuation
(1,0,0) and thus illuminates all three objects regardless of
distance. The third PointLight is positioned to the left of
the Box, specifies linear attenuation (0,1,0) and thus has a
marginal effect on the Sphere and practically no visible effect
on the Cone. Note that a ProximitySensor is used to turn the
lights on when the user is near and to turn them off when the
user leaves the vicinity. The initial Viewpoint locates the
user outside the bounding box of the ProximitySensor, while
the second Viewpoint is inside:
#VRML V2.0 utf8
Group { children [
DEF PL1 PointLight { # Between sphere and table
location 0 -0.3 0.5 # with linear attenuation
attenuation 0 1 0
on FALSE
radius 10
}
DEF PL2 PointLight { # Right side - no attenuation
location 5 2.0 1
attenuation 1 0 0
on FALSE
radius 10
}
DEF PL3 PointLight { # Left side close to the table
location -5 -.1 2 # with linear attenuation
attenuation 0 1 0
on FALSE
radius 10
}
Transform {
translation -3 0.77 0
rotation 0.30 0.94 -0.14 0.93
scale 0.85 0.85 0.85
scaleOrientation -0.36 -0.89 -0.29 0.18
children Shape {
appearance DEF A1 Appearance {
material Material {
ambientIntensity 0.34
diffuseColor 0.85 0.85 0.85
specularColor 1 1 1
shininess 0.56
}
}
geometry Box {}
}
}
Transform {
translation 0 0.7 0
children Shape {
appearance USE A1
geometry Sphere {}
}
}
Transform {
translation 3 1.05 0
rotation 0 0 1 0.6
children Shape {
appearance USE A1
geometry Cone {}
}
}
Transform {
translation -5 -1 -2
children Shape {
appearance USE A1
geometry ElevationGrid {
height [ 0 0 0 0 0 ... 0 ]
xDimension 11
zDimension 5
xSpacing 1
zSpacing 1
}
}
}
DEF PS ProximitySensor { size 20 10 20 }
Background { skyColor 1 1 1 }
NavigationInfo { type "EXAMINE" headlight FALSE }
Viewpoint {
position 5 2 50
orientation -.2 0 .9 0
description "Outside the light zone"
}
Viewpoint {
position 0 1 7
orientation 0 0 -1 0
description "Inside the light zone"
}
]}
ROUTE PS.isActive TO PL1.on
ROUTE PS.isActive TO PL2.on
ROUTE PS.isActive TO PL3.on
|

Figure 3-44: PointLight Node Example
|