Home‎ > ‎D) Software‎ > ‎D.A) VBA‎ > ‎

D.8.6) Simple ray trace

Having played with the generation of a viewshed from SRTM data VBA was used to create a 'ray-traced' image of the terrain.

A nominal 1280 x 1000 'screen' was placed at a distance from a theoretical eye-point. For each pixel on the 'screen' a 'visual ray' was extended from the eye-point, through the 'pixel' and on to an intersection with the terrain (if there is one). Each point was coloured according to the gradient of the terrain.

(Native chart from Excel)

The normal vector to a triangle formed by three of the four data points around the point of intersection was calculated via a cross-product. The triangle formed by the other points was ignored (for now). The normal vector allowed the terrain the be shaded according to gradient and direction. 

The raw result is shown below. Despite the image being 1300 pixels across the terrain looks blocky and Minecraftesque - this is a reflects the granularity of the SRTM data.

As might be expected, changing the distance between the observer and the 'screen' changes the field of view.

I subsequently smoothed the data.

Including the effects of distance and of illumination, the view looking north from south of Bognor results in an image like this