Keywords: sources, instancing

Summary

The purpose of this demo is to show how sources can be instanced like other geometry in a DIRSIG scene. Specifically, this demo shows how to package a base object with one or more sources, and then instance that package statically and dynamically.

The following demos, manuals and tutorials can provide additional information about the topics at the focus of this demo:

Details

The focus of the demo is to show the user the approach commonly used to "bundle" sources with other geometry. In this example, a facetized geometry model of a vehicle (a Hummer H3) will be packaged with a pair of sources to act as head lights. That "H3 with lights" bundle can then be instanced as a piece of geometry multiple times. In addition to the facetized H3 example, the same source geometry is bundled with a built-in geometry primitive (a cylinder) to create a "lightpost", which can also be instanced as a piece of geometry multiple times.

Important Files

This section highlights key files important to the simulation.

The Radiometric Description of the Light

The material for the light bulb uses a blackbody 3000 Kelvin blackbody curve to approximate a tungsten source. This description can be found in the materials/demo.mat file:

MATERIAL_ENTRY {
    ID           = 5000
    NAME         = 300 Watt Tungsten Source
    EDITOR_COLOR = 1.0, 1.0, 1.0
    DOUBLE_SIDED = FALSE
    OPTICAL_DESCRIPTION = SOURCE
    INTENSITY_FILENAME  = sources/300w_3000k.int
    SOURCE_SHAPE        = 10
}

The SOURCE_SHAPE of 10 results in a narrow beam pattern.

Packaging the H3 Geometry and Headlights

The base vehicle geometry is a Hummer H3 vehicle (see geometry/h3.obj). The h3_with_lights.glist ODB file "bundles" the H3 geometry with two instances of a GLIST defined <basesource>:

<geometrylist>
  <object>
    <basegeometry>
      <obj><filename>h3.obj</filename></obj>
    </basegeometry>
    <staticinstance/>
  </object>

  <object>
    <basesource>
      <pointsource matid="5000">
        <pointing>
          <vector><x>0.0</x><y>1.0</y><z>0.0</z></vector>
        </pointing>
      </pointsource>
    </basesource>
    <staticinstance name="driver_headlight">
      <translation>
        <point><x>-0.65</x><y>2.535</y><z>0.975</z></point>
      </translation>
      <rotation units="degrees" rotationorder="xyz">
        <cartesiantriple><x>-20</x><y>0</y><z>0</z></cartesiantriple>
      </rotation>
    </staticinstance>
    <staticinstance name="passenger_headlight">
      <translation>
        <point><x>+0.65</x><y>2.535</y><z>0.975</z></point>
      </translation>
      <rotation units="degrees" rotationorder="xyz">
        <cartesiantriple><x>-20</x><y>0</y><z>0</z></cartesiantriple>
      </rotation>
    </staticinstance>
  </object>
</geometrylist>

The two <staticinstance> descriptions for the light bulb position the source where the headlights should be on the H3. The H3 geomety has the front pointing up the + Y axis (which will make putting the object in motion easy later). Hence, the X translations (+/- 0.65 meters) reflect the translation for the left and right headlight. The Y translation (+2.535 meters) reflects the translation to the front of the car. The Z translation (+0.975 meters) reflects the translation from the ground up to the height of the headlights. The -20 degree X rotation aims the sources down a little from their +Y axis direction.

Note
It is always good to place the a light source slightly offset from the geometry to avoid interference from that geometry. In this case, the headlights are slightly in front of the vehicle.

Packaging the Lampost with a Source

A similar approach was taking to create a simple lampost using the built-in cylinder object geometry and a <basesource> in a single GLIST file (see geometry/lightpost.glist):

<geometrylist>
  <object>
    <basegeometry>
      <cylinder>
        <matid>10</matid>
         <point_a><point><x>0</x><y>0</y><z>-1</z></point></point_a>
         <point_b><point><x>0</x><y>0</y><z>+1</z></point></point_b>
        <radius>0.2</radius>
      </cylinder>
    </basegeometry>
    <staticinstance/>
  </object>

  <object>
    <basesource>
      <pointsource matid="5000">
        <pointing>
          <vector><x>0.0</x><y>0.0</y><z>-1.0</z></vector>
        </pointing>
      </pointsource>
    </basesource>
    <staticinstance>
      <translation>
        <point><x>0.0</x><y>0.0</y><z>-1.1</z></point>
      </translation>
    </staticinstance>
  </object>
</geometrylist>

This light post geometry is actually centered at the origin rather than up at it’s final height. This translation is introduced when this object is instanced in the final scene.

Assembling the Scene

The geometry/demo.glist is the main geometry file for the scene. This file combined a ground plane geometry, four static (not moving) instances of the "light post" object, and two dynamic (moving) instances of the "H3 with headlights" object. The H3 instances use the Delta Motion model to create a pair of instances traveling in opposite directions:

<geometrylist>

  <object>
    <basegeometry>
      <groundplane>
        <matid>10</matid>
      </groundplane>
    </basegeometry>
    <staticinstance/>
  </object>

  <object>
    <basegeometry>
      <glist><filename>lightpost.glist</filename></glist>
    </basegeometry>
    <staticinstance>
      <translation>
        <point><x>-5</x><y>-8</y><z>+5</z></point>
      </translation>
      <rotation units="degrees">
        <cartesiantriple><x>+45</x><y>-20</y><z>0</z></cartesiantriple>
      </rotation>
    </staticinstance>
    
    <staticinstance>
      <translation>
        <point><x>+5</x><y>-8</y><z>+5</z></point>
      </translation>
      <rotation units="degrees">
        <cartesiantriple><x>+45</x><y>+20</y><z>0</z></cartesiantriple>
      </rotation>
    </staticinstance>
    
    <staticinstance>
      <translation>
        <point><x>+5</x><y>+8</y><z>+5</z></point>
      </translation>
      <rotation units="degrees">
        <cartesiantriple><x>-45</x><y>+20</y><z>0</z></cartesiantriple>
      </rotation>
    </staticinstance>
    
    <staticinstance>
      <translation>
        <point><x>-5</x><y>+8</y><z>+5</z></point>
      </translation>
      <rotation units="degrees">
        <cartesiantriple><x>-45</x><y>-20</y><z>0</z></cartesiantriple>
      </rotation>
    </staticinstance>
  </object>
  
  <object>
    <basegeometry>
      <glist><filename>h3_with_lights.glist</filename></glist>
    </basegeometry>
    
    <dynamicinstance>
      <motion type="delta">
        <filename>h3_1.mov</filename>
      </motion>
    </dynamicinstance>
    
    <dynamicinstance>
      <motion type="delta">
        <filename>h3_2.mov</filename>
      </motion>
    </dynamicinstance>
  </object>

</geometrylist>

Summary of Geometry Files

geometry/h3_with_lights.glist

The Hummer H3 geometry packaged with two light bulbs (headlights).

geometry/lightpost.glist

The "lightpost" (a built-in cylinder geometry) packaged with a single light bulb.

geometry/demo.glist

The top level geometry that creates two dynamic instances of the "H3 with headlights" and 4 static instances of the "lightpost".

Simulations and Results

There are two simulation scenarios included in this demo:

  1. A single-frame simulation

  2. A multi-frame (video) simulation

The Single-Frame Simulation

Run the single-frame demo.sim file using DIRSIG4:

$ dirsig4 demo.sim

or using DIRSIG5 with a higher convergence setup to account for the lower radiance overall levels:

$ dirsig5 --convergence=30,250,1e-12 demo.sim

Load the resulting demo-t0000-c000.img radiance file in the DIRSIG image viewer and display the RGB bands using one of the high dynamic range scaling options (e.g., "two sigma" or "two percent" scaling). In this case we will employ the "two percent" option:

$ image_tool convert --autoscale=percent --format=png demo-t0000-c0000.img
The single-frame simulation.

single frame

The Multi-Frame Simulation

Run the single-frame demo.sim file using DIRSIG4:

$ dirsig4 video.sim

or using DIRSIG5 with a higher convergence setup to account for the lower radiance overall levels:

$ dirsig5 --convergence=30,250,1e-12 video.sim

All the frames produced by the multi-frame simulation can be scaled in a single execution of the image_tool by using the appropriate wildcards for the image filename:

$ image_tool convert --autoscale=percent --format=png demo-t0000-c*.img

If you have the FFmpeg utility installed you can encode the frames into various video formats:

Using FFmpeg to encode to an MPEG-4 video file.
$ ffmpeg -i demo-t0000-c%04d.img.png -pix_fmt yuv420p video.mp4
Using FFmpeg to encode to an animated GIF file.
$ ffmpeg -i demo-t0000-c%04d.img.png -pix_fmt yuv420p -f gif video.gif
video
Figure 1. Animated GIF video of the multi-frame simulation (using 2% scaling).
Note
The apparent dimming of the scene during the animation is a result of the two-percent autoscaling option adapting to the overall brightness of the frames, similar to how auto-gain control (AGC) adjusts on consumer cameras. Supplying a fixed gain to image_tool (rather than using the --autoscale option) or a detailed sensor model would avoid this artifact.