Keywords: UV mapping
Summary
This demo highlights the use of the UV coordinate system to apply maps to scene geometry. Unlike the "vertical drape" projection which is ties to the global XY coordinate system, the UV projection approach uses a secondary coordinate system that is native to the object geometry. Therefore, the UV coordinate system moves with those objects. In this case, a simple scene that contains UV mapped objects shows how a mapped property (in this case a material map) rotates with the objects.
Details
This scene demonstrates the UV texturing capability that goes beyond the global XY plane texturing that is normally done. Objects must have UV coordinates specified either by (a) ingestion of an OBJ geometry or (b) via select built-in geometry primitives available in the ODB and GLIST files. Currently, only the built-in "sphere" geometry has UV coordinates. This demo scene consists of UV mapped cubes (using an OBJ file) and a UV mapped sphere (using the build-in sphere geometry). The various cubes have slighlty different orientations to demonstrate that the UV mapping is indeed independant of global orientation.
A more detailed discussion of the various map projection options is provided in the Maps Manual.
Important Files
This section highlights key files important to the simulation.
Scene Geometry
The objects in this simple scene are defined in geometry/demo.odb
.
The scene consists of a ground plane (using the build-in geometry),
a sphere (using the build-in geometry) and five instances of a cube
(using an external OBJ file):
DIRSIG_ODB = 1.0
GROUND_PLANE {
MATERIAL_ID = 105
}
SPHERE {
CENTER = 0, +1.5, 0
RADIUS = 1.0
MATERIAL_IDS = 100
}
OBJECT {
OBJ_FILENAME = cube.obj
UNITS = METERS
INSTANCES {
INFO = -3.0, +1.5, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 20.0
INFO = +3.0, +1.5, 0.0, 1.0, 1.0, 1.0, 0.0, 45.0, 45.0
INFO = -3.0, -1.5, -0.9, 1.0, 1.0, 1.0, 0.0, 0.0, -20.0
INFO = 0.0, -1.5, -0.9, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0
INFO = +3.0, -1.5, -0.9, 1.0, 1.0, 1.0, 0.0, 0.0, +20.0
}
}
The scene has two rows (foreground and background) each containing
three objects. The sphere object is centered in the background
row. The first two instances for the cube.obj
object create a pair
of cubes that flank the sphere in the background row. The last three
instances embed the cubes in the ground (note the negative Z in the
translation) and rotates them around Z. The instances for each cube
are rotated with respect to the global XY coordinate system. However,
the UV coordinate system defined by the OBJ geometry file will translate,
scale and rotate with those instances.
Scene Maps
The materials across the surface of the sphere and box objects are remapped via material map in the scene file. The general material map setup is shown below:
<materialmap name="Checkerboard" enabled="true">
<matidlist>
<matid>100</matid>
</matidlist>
<projector>
...
</projector>
<dcmatlut>
<entry>
<dc>0</dc><matid>105</matid>
</entry>
<entry>
<dc>255</dc><matid>110</matid>
</entry>
</dcmatlut>
<image>
<filename>pattern.png</filename>
</image>
</materialmap>
Tip
|
The source image file is in the PNG format. Many user’s forget that DIRSIG allows you to use PGM, JPG or PNG format image files for most map types. |
The details of the setup are beyond the scope of this demo, however
the choice of the projector is important. The two possible <projector>
options will be discussed in the following sections.
UV map projection
The UV Projector will compute image map coordinates using the UV coordinate system associated with the object. There are no options for the projector itself at this time:
<projector origin="image" flipx="false" flipy="true" extendx="repeat" extendy="repeat" >
<uvprojector/>
</projector>
The UV Projector configuration is used in the uv_map.scene
file.
Drape map projection
The Drape Projector computes the image map coordinates using coordinate system that is tied to the global XY coordinate system. This coordinate system is defined by an origin at the specified Scene ENU XY location (the Z coordinate isn’t used) and a GSD that specifies the horizontal spacing of image coordinate steps:
<projector origin="image" flipx="false" flipy="true" extendx="repeat" extendy="repeat" >
<tileprojector>
<insertpoint>
<point><x>0</x><y>0</y><z>0</z></point>
</insertpoint>
<gsd>0.00781</gsd>
<rotation>0</rotation>
</tileprojector>
</projector>
The Drape Projector configuration is used in the drape_map.scene
file.
Setup
This demo has two simulation scenarios, and the output of each will be compared:
-
A UV mapping scenario in the
uv_map.sim
file, which uses theuv_map.scene
file. -
A drape mapping scenario in the
drape_map.sim
file, which uses thedrape_map.scene
file.
However, since the same .platform
file is used for both simulations
(only the .scene
file is different), the same output image filename
will be used. Therefore, one simulation should be run and the output
visualized before running the second simulation, which would overwrite
the image data produced by the first simulation.
To run and compare simulations, perform the following steps:
-
Run the DIRSIG
uv_map.sim
file. -
Load and examine the resulting
demo.img
anddemo_truth.img
files in the image viewer. -
Run the DIRSIG
drape_map.sim
file. -
Load and examine the resulting
demo.img
anddemo_truth.img
files in the image viewer.
Results
The primary output of the simulation is a single band radiance image. Because there are two simulations to compare, the results of each will be discussed and compared.
UV Projection
The image below is the output of the UV projection simulation (uv_map.sim
)
in the built-in image viewer using the "Selected Min/Max Scaling".
The three square tiles in the foreground are the OBJ cube object inserted
below the ground to isolate the top surface. These three instances were
assigned Z rotation, and the mapped pattern rotates with the objects.
The two cubes in the background are the same OBJ cube, but they are placed
higher so that the map can be seen to wrap around the side surfaces. The
right cube is rotated about multiple axes but the map "sticks" to the sides
because the UV coordinate system provided in the OBJ file rotates with the
object. The sphere object (background center) features a built-in UV
coordinate system, which is similar to a latitude and longitude coordinate
system. At the top of the sphere the UV coordinates "compress" as the
coordinates converge. Note that in the animation, the map follows the
objects in motion because it is tied to an inherent coordinate system
associated with the object.

Drape Projection
The image below is from the "vertical drape" projection simulation
(drape_map.sim
). In this case, you can see how the checkedboard
pattern completely ignores the orientation of the various objects.
The foreground row of three square tiles all have the checkerboard
oriented with the global XY coordinates rather than rotating with
them. The background row of objects show the major limitation of
the global XY projection, as the left-rear cube features vertical
surfaces "smeared" with the same value because those locations on
the sides of the box have the same global XY coordinate and, hence,
project to the same map image pixel. Note that in the animation, the map
does not follow the object in motion because it tied to the global
coordinate system rather than one associated with the object.

UV Coordinate Truth
The UV coordinates are included in the Intersection truth. The image below contains an RGB visualization of the U coordinate, V coordinate and image radiance assigned to the red, green and blue channels, respectively. Although the specific RGB colors do not convey information, the patterns in these colors can be used to visualize how the UV coordinate system moves with each instance. For example, coordinate color pattern on the three square tiles in the foreground can be seen to rotate with each tile.
