shadow
Create a high accuracy hillshade with shadow casting
This program, shadow, will create a shaded-relief cube from a digital
elevation model (DEM) and a MATCH cube.
We use the sun's position at the center of the input cube or a user-defined observation time. By default, we factor in shadows cast by features. This program operates much like the ISIS 'shade' program which instead requires azimuth/elevation as input.
However, with the shadow application, using the sun's position allows much higher precision shading and enables the possibility of computing shadowed areas. The algorithm description below is provided to help understand the optimization settings.
User-Requirements
The user must supply an elevation model (DEM) and either an observation time or a cube with raw camera geometry (see 'spiceinit'). If providing an observation time, the PCK and SPK SPICE kernels associated with the DEM's target must have been downloaded and be available on the user's machine in the "base" kernels area, or their file paths must be provided as values to the PCK and SPK user parameters.
Understanding the Algorithm
The 'shade' program's algorithm is called 'hillshade' in this algorithm description.
We use the sun's position at the center of the input cube or a user-defined observation time. By default, we factor in shadows cast by features. This program operates much like the ISIS 'shade' program which instead requires azimuth/elevation as input.
However, with the shadow application, using the sun's position allows much higher precision shading and enables the possibility of computing shadowed areas. The algorithm description below is provided to help understand the optimization settings.
User-Requirements
The user must supply an elevation model (DEM) and either an observation time or a cube with raw camera geometry (see 'spiceinit'). If providing an observation time, the PCK and SPK SPICE kernels associated with the DEM's target must have been downloaded and be available on the user's machine in the "base" kernels area, or their file paths must be provided as values to the PCK and SPK user parameters.
Understanding the Algorithm
The 'shade' program's algorithm is called 'hillshade' in this algorithm description.
- Compute the sun's position at the center of the MATCH cube. The MATCH cube must have the same target as the DEM.
-
For every pixel in the input elevation model, compute the hillshade value for the pixel, and
- if the hillshade result is positive (facing towards the sun), then estimate if the pixel is in shadow;
- if the hillshade value is positive and the pixel is in shadow, then the result is an LRS;
- if the hillshade value is positive and the pixel is not in shadow, then the result is the hillshade result and
- if the hillshade value is negative, the result is low resolution saturation (LRS).
- Optimization: If SHADOW, and this elevation model pixel is known to be shadowed, consider this pixel to be shadowed and stop (no pixels are initially known to be shadowed).
- Compute the pixel's body-fixed coordinate (XYZ) position.
- If SUNEDGE, adjust the sun's position to nearer the highest (on the horizon) edge of the sun.
- Subtract the sun's position from the elevation model pixel's position, providing a vector to the center (or edge) of the sun.
- Iterate until a solution is found:
- Step along the 3D ray the current estimate of PRECISION pixels
- Project the ray back onto the elevation model to find the equivalent radius
-
Update estimate of how far along the 3D ray is equivalent to the full resolution of the
elevation model.
Optimization: Multiply the step by PRECISION.
Optimization : If SKIPOVERSHADOW, while the next linearly-extrapolated elevation model position is known to be in shadow, increase the next step size by the estimate up to MAXSKIPOVERSHADOWSTEPS times. - Check for a solution
-
If the equivalent radius is higher than the ray, then the originating pixel is
shadowed.
-
If the ray's elevation is higher than the highest point on the elevation model,
the originating pixel is in light.
Optimization: If LIGHTCURTAIN, and the ray's elevation is higher than a previous ray that intersected this pixel in the elevation model, consider the originating pixel in light. -
Optimize
-
If LIGHTCURTAIN, and the pixel was determined to be in light, record the elevations of
the ray where it projected onto the elevation model.
Optimization: If LOWERLIGHTCURTAIN, lower the elevations along the ray by subtracting the minimum difference between the ray and the elevation model while the ray was being walked.
Optimization: If CACHEINTERPOLATEDVALUES, linearly interpolate the points where the ray would have intersected the elevation model to one pixel accuracy. -
If SHADOWMAP, and the pixel was determined to be in shadow, record all points where
the ray projected onto the elevation model to be known shadowed points, excluding
the actual intersection point.
Optimization: If CACHEINTERPOLATEDVALUES, linearly interpolate the points where the ray would have intersected the elevation model to one pixel accuracy.
-
If LIGHTCURTAIN, and the pixel was determined to be in light, record the elevations of
the ray where it projected onto the elevation model.
Categories
History
Steven Lambright | 2013-02-28 | Original version. |
Kristin Berry | 2015-07-22 | Added NaifStatus::CheckErrors() to see if any NAIF errors were signaled. References #2248. |
Kaitlyn Lee | 2018-02-17 | Added the PixelType attribute to the output cube and set it to real. Documentation updated by editor. Fixes #5187. |