# VertexNormals2

Keywords: vertex normals

## Summary

This demo shows how the appearance of sun glints is affected by both materials and geometry.

## Related Materials

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

- Related Demos

  - The VertexNormals1 demo has a basic introduction to vertex normal interpolation using a set of spheres at various resolutions to show how quantized surface geometry can be made to appear smooth.

- Related Manuals

  - N/A

- Related Tutorials

  - N/A

## Details

The scene includes two models of an Infinity G35. One has "flat" facets and the other includes "vertex normals" which allows DIRSIG to spatially interpolate the normal across the facets. The "vertex normal" vehicle produces more realistic glints because the surface is modeled as if it is continuously curved rather than quantized. The simulation produces a 6 frame sequence by imaging the scene about once every 16 minutes. During that time, the Sun moves and the glints on the vehicle change.

## Important Files

### Geometry

The key geometry files in this demo are the OBJ files for the Infinity G35 model. There is a pair of OBJ files for the vehicle, one with and one without vertex normals.

`geometry/infiniti_g35.obj`

  Infinity G35 model (15310 polygons) without vertex normals.

`geometry/infiniti_g35_vn.obj`

  Infinity G35 model (15310 polygons) with vertex normals.

The vertex normals appear in an Alias/Wavefront OBJ file as entities starting with the keyword `vn`.

#### Adding vertex normals

If you have an OBJ geometry file that does not have vertex normals, they can be added using the DIRSIG Object Tool. For this demo, the OBJ file with the vertex normals was created from the one without them using the following command-line syntax:

    $ object_tool --input_filename=infiniti_g35.obj --addvertexnormals --output_filename=infiniti_g35_vn.obj

### Materials

The materials for the vehicle are worth some discussion. The paint and glass materials are modeling with the ShellTarget BRDF model. This allows the materials to be configured with very specular (shiny) properties.

## Setup

There are two simulation scenarios in this demo:

1. A single-frame simulation

2. A multi-frame (video) simulation

### Running the Single-Frame Simulation

This single-frame simulation produces a single image file. To run the simulation, perform the following steps:

1. Run the DIRSIG `demo.sim` file

2. Load the resulting `demo-t0000-c0000.img` file in the image viewer.

### Running the Multi-Frame Simulation

The multi-frame simulation produces 10 image files. To run the simulation, perform the following steps:

1. Run the DIRSIG `video.sim` file

2. Load the resulting `demo-t0000-c0000.img`, `demo-t0000-c0001.img`, etc. files in the image viewer.

The simulation produces 10 separate image files for the 10 different image times. The filename convention follows the standard "file per capture" naming scheme:

    demo-t0000-c0000.img
    demo-t0000-c0001.img
    demo-t0000-c0002.img
    ...
    demo-t0000-c0009.img

## Results

### Single-Frame Simulation

Because of the high dynamic range (due to the glints), using the built-in image viewer with the standard Selected Min/Max Scaling does not reveal most of the scene detail (see below);

Figure 1. Single-frame radiance image using the "Selected Min/Max Scaling".

The Selected Two Sigma Scaling does a better job of scaling the large dynamic range (see below). However, in both scalings the quantized nature of the surface polygon mesh in the lower-left vehicle is apparent. Because those flat surfaces have a constant normal across them, a sudden change in the reflected sunlight across polygon (facet) boundaries occurs to an abrupt bi-directional geometry change. The vehicle using the vertex normal (upper-right) has the same polygon surface, but the normal is being varied across each polygon such that the normal direction is continuous across polygon (facet) boundaries.

Figure 2. Single-frame radiance image using the "Selected Two Sigma Scaling".

The effect of the vertex normal interpolation can be observed by looking at the Avg. Entry Angle [degrees] truth image, which shows the quantization of the normal across the surface of the car without vertex normals (lower-left) compared to the car with the vertex normals (upper-right):

Figure 3. Single-frame "entry angle" truth image using the "Selected Two Sigma Scaling".

### Multi-Frame Simulation

The output of the multi-frame simulation is 10 individual image files. The frames can be scaled and encoded into a video format for viewing using a variety of 3rd party software tools (ffmpeg, mpeg_encode, etc.).

Figure 4. An animation of the multi-frame time sequence.