Stray light analysis for Head-up-Display - Part 2

This article demonstrates a stray light analysis workflow for a head up display (HUD). This article is part one of a three-part series.
Stray light analysis for head up display: part 1
Stray light analysis for head up display: part 3

Authored By Michael Cheng


Article Attachments


In Part 1, the specular straylight path of the picture generation unit (PGU) and sunlight are analyzed. A scene and a simple camera are added to visualize the image of the scene and the PGU received by an eye camera. To simulate efficiently straylight from the sun, a method of reverse ray-tracing from the eye camera to the sun is discussed.

In Part 2, an API Analysis tool is introduced to visualize straylight caused by the sun. This is done using a reverse ray-tracing process.

In the final part, a CAD model of the mechanical housing is imported into the system. The straylight process is repeated to analyze the straylight paths caused by scattering from the mechanical housing.

Note, while this article can be read independently, it’s suggested to read the article, Which tools to use when working on a Head-up-Display?. The straylight analysis is done on the system presented in that article.

Source: Scene

The file used in this section and the next ones can be found in the attached “v2_Step2-1_adding_scene.zar” file. Users may want to see how the HUD image overlaps with the scene. In this section, two objects, a Source DLL (Lambertian_Overfill.dll) and a Slide, are added to simulate the scene, as shown in Figure 1. The scene source is at 2000 mm from the eye camera.

Figure 1 A Source DLL (Lambertian_Overfill.dll) and a Slide object are added to the system.

The simulated image is shown in Figure 2. Since the PGU is much brighter than the scene, the maximum limit of the color bar scale at Figure 2 (B) is changed to 0.2 Watts/cm^2. The color bar scale can be change by right clicking on the color barn and selecting “Edit axis options > Z” as shown in Figure 3. Figure 2 (C) is the result on the small detector. Note that the brightness of the different sources shown in the eye camera image depends on the radiance of the source. Next section will discuss how to set up a Lambertian Source with known radiance.

Figure 2 Simulation image for PGU and scene sources.

Figure 3 Right clicking on color bar and selecting Edit axis options > Z for editing the color bar scale.

Set up sources with given radiance

The file used in this section is still the attached “v2_Step2-1_adding_scene.zar” file. It is important to clarify how to set up correctly the total power of a light source with known radiance (luminance). Setting up the sources with a correct radiance is important to evaluate the brightness and contrast of the HUD image seen by the driver.
To make it simple, all the sources here are assumed to be Lambertian. For a Lambertian source, the radiance is a constant over all directions and positions. Therefore, the total power(flux) can be calculated by:


- A is the area of the source
- L is the radiance (luminance) of the source.
Note that if the source is non-Lambertian, then the Radiance/Luminance is a function of the direction and/or position. So, an integration of the radiance over the whole area and projected solid angle are required.

The following table shows how the Total Power is considered for each source and the relationship between the source’s luminance, area, and total flux (lumen).


(nit = Lumens/sr/\(m^{2})\)


Total flux



0.025 x 0.01

250\(\times \pi\)

Sun (Reverse)


40 x 30

\(1.2\times 10^{6}\times \pi\)



4 x 3

\(9\times 10^{4}\times \pi\)

The Total Power of all sources is just a relative value. For convenience, in the attached file, the Total Power is normalized by \(\pi\) and the Source Unit is set to Watts (under System Explorer…Units).
For example, the Total Power for the Scene is set as \(6\times 10^{4}\) Watts in the system.

Sun Straylight analysis tool

The system used in this section can be found in the attached “v2_Step2-2_consider_sun_straylight.zar” file.
The previous section showed how to visualize the image of the HUD and the scene together with a correct brightness. However, it’s tricky to do the same for the sun straylight because the light is reversely traced from the eye detector to a detector polar.

To show the correct data on the eye detector, it is required to check the ray paths from the reversal source to the detector polar and feedback the transmitted power back on to the image. There isn’t currently any useful tool to do this. Therefore, in this section, a customized User Analysis tool is made via the ZOS-API, the programming user interface provided by OpticStudio.

To install the User Analysis, download the attached “” file and extract “Sun_straylight_analyzer.exe” to the folder \Documents\Zemax\ZOS-API\User Analysis\. Close and reopen OpticStudio. The User Analysis can be run under Programming…UserAnalyses as shown in Figure 4.

Figure 4 The User Analysis Sun_strylight_analyzer.exe can be downloaded from this article and used.

To use this User Analysis, users must first trace rays from the eye detector and save a ZRD file (Zemax Ray Database). It is easiest to explain how to use the tool with an example.
The following steps shows how to use this tool with the HUD system.

  1. Open the attached “v2_Step2-2_consider_sun_straylight.zar” file. Compared to the previous example “v2_Step2-1_adding_scene.zar”, the only difference in this file is one more Source DLL (#38). This source has been added for reverse ray-tracing for the small detector (#31) for sunlight analysis.
  2. Trace 1e6 #Analysis Rays from Source #36 (reverse source for big detector, #30). Note #Analysis Rays from other sources are set to 0. Save the ZRD file with the required filter string, as shown in Figure 5. The filter string was already explained in Part 1. Rename the ZRD file as later another ZRD file will be saved for the smaller detector (#31). Note the Lost energy values look large in Figure 5, but it’s actually not that large. The total source power is 1.2e6 Watts in the system, so the total Lost energy is only about 0.01%.
    Figure 5 Tracing rays for big detector.
  3. Trace 2E6 from scene source (#40) and 2E6 from PGU source (#33). In total 4E6 rays are traced. Don’t save the ZRD file or it will overwrite the previously saved ZRD file. The image on the eye detector (#30) shows the scene and the HUD image.
  4. Now open the User Analysis “Sun_straylight_analyzer”. Set it up as in Figure 6. Note that the “Only ZRD data” and “Ignore transmission” are checked. The main purpose of checking these two options is to do a sanity check; it is to check if the result is the same as the one shown in the Detector Viewer with the ZRD file selected.
    - The “Only ZRD data” means that the current detector data of the scene and the HUD image are ignored, and only the reverse rays from the source #36 is considered.
    - The “Ignore transmission” means do not consider the transmission data of the rays from the eye detector (#30) to the sun detector polar (#26).image015.pngFigure 6 Settings of User Analysis sun straylight analyzer.
  5. After clicking “OK” in the User Analysis, the result is shown as in Figure 7. The result is identical to the Detector Viewer, which also reads the same ZRD file.image017.pngFigure 7 The Detector Viewer (left) and the User Analysis (right) read the same ZRD data and show the same result.
  6. Now uncheck the “Ignore transmission” and update the User Analysis. By doing this, the tool checks each ray’s final power when they reach the detector and feedback the result to the display data. The image here now correctly considers the transmittance of the sunlight when passing through the system and reaching the eye camera. However, note there is still one unrealistic point. This image assumes that the sunlight comes from every possible direction at the same time, which is not true.
  7. To check how the straylight image overlaps with the scene and the HUD image, three actions are required:
    • (1) Set up the sunlight incident angle. To do that, measure the angle in the detector polar.
    • (2) Set the half divergence angle to 0.25 degrees.
    • (3) Uncheck “Only ZRD Data”, as shown in Figure 8.
    • The irradiance of sunlight is about 3,000 times stronger than the HUD image. To show the scene and the HUD image, set a maximum limit of 1 to the color bar as shown in the upper-right side part in Figure 8.
    • A divergence angle of 0.25 degrees is for a sun in a clear sky. In the API, this works as a filter that removes rays hitting the Detector Polar with divergence angle larger than 0.25 degrees. Users can input their own value based on requirement. If a larger divergence is inputted, for a cloudy sky for example, a “Scale” parameter is provided to adjust the sun straylight power. Figure 3 shows how to change the scale of the color bar.
      image021.pngFigure 8 Measure the straylight angle and analyze it in User Analysis sun_straylight_analyzer.exe.
  8. The process can be repeated for other straylight angles. Figure 9 shows more examples.

    Figure 9 Straylight image for path #5 in the “Sun_straylight_analyzer.exe” User Analysis.
    Figure 10 Straylight image for path #2 and #3 in the “Sun_straylight_analyzer.exe” User Analysis.

At this point, we demonstrated how to use the customized User Analysis to show the straylight from the sun overlapping the scene and the HUD image.

Below, a similar process is repeated for the small detector (#31). This is not absolutely required. It’s provided here for reference.

  1. Re-open the attached “v2_Step2-2_consider_sun_straylight.zar” file.
  2. Trace 1e6 rays from Source #38 (reverse source for small detector, #31). Note #Analysis Rays are from other sources are set to 0. Save the ZRD file with the required filter string, as shown in Figure 5. Change the ZRD name to “v2_Step2-2_small.ZRD”.
  3. Trace 2E6 from the PGU source (#33). Note the ZRD file is not saved at this stage. The scene source (#40) is not traced because the main purpose is to check the image of the HUD with the straylight from the sun on the small detector (#31).
  4. The result of the pure straylight when considering all sun angles is shown as in Figure 11. Please note that the Z scale is set back to Automatic.image027.png

    Figure 11 Straylight from the sun on the small detector (#31), considering all sun angles.

  5. There are only two possible sun angles that can cause straylight in this small view detector (#31). The result is shown in Figure 12 and Figure 13.Picture1.png
    Figure 12 Straylight image for path #6 on the small detector (#31) in the “Sun_straylight_analyzer.exe” User Analysis.
    Figure 13 Straylight image for path #2 and #3 on the small detector (#31) in the “Sun_straylight_analyzer.exe” User Analysis.


This article has demonstrated the use of an API Analysis tool to visualize the straylight from the sun when using a reverse ray-tracing method.

Next Article: Stray light analysis for head up display: part 3 where we’ll import the CAD model for the mechanical housing and study the straylight caused by this mechanical housing.

Was this article helpful?
0 out of 0 found this helpful



Article is closed for comments.