Abstract
This article describes a novel algorithm for built environment 2.5D digital model shadow generation that allows identities of shadowing sources to be efficiently precalculated. For any point on the ground, all sources of shadowing can be identified and are classified as actual or experiential obstructions to sunlight. The article justifies a 2.5D raster approach in the context of modelling of architectural and urban environments that has in recent times shifted from 2D to 3D, and describes in detail the algorithm which builds on precedents for 2.5D raster calculation of shadows. The algorithm is efficient and is applicable at even precinct scale in low-end computing environments. The simplicity of this new technique, and its independence of GPU coding, facilitates its easy use in research, prototyping and civic engagement contexts. Two research software applications are presented with technical details to demonstrate the algorithm’s use for participatory built environment simulation and generative modelling applications. The algorithm and its shadow origin tagging can be applied to many digital workflows in architectural and urban design, including those using big data, artificial intelligence or community participative processes.
Keywords
Introduction
This article presents the process and application of a novel 2.5D algorithm for shadow calculation with tagging of the sources of those shadows. Calculating shadows in digital built environment models is an important process as it assists architects and urban designers both in evaluation of physical qualities, such as urban heat island, solar irradiance, window solar collection and solar amenity, and in achieving intangible, qualitative goals such as place making and citizen experience of space.
Modelling of architectural and urban environments has in recent times made a shift from predominantly 2D representation to 3D representation.1,2 While 3D representation offers greater fidelity to the actual built environment and better innate scope for sophisticated analytics, its use comes at the cost of greater computational overheads of processing time, model aquisition, and equipment cost and complexity. This is undoubtedly true for shadow calculation: although the accuracy of shadows in 3D modelling can be great, their calculation is intensive. Furthermore, there is still a valid role for dimensional modes other than 3D: many mapping and geographic information system (GIS) platforms popularly used, such as OpenStreetMap™, are not 3D or truly 3D in practice, and the creation and collation of 3D features, such as crowdsourced building data, are more laborious than less detailed alternatives.
A compromise between the reductionism of 2D and the resource intensiveness of 3D is 2.5D. Less detailed than 3D representation, 2.5D representations abstract 3D data by specifying information in one of the three axes with a single quantity, with that axis being the ‘0.5D’. For built environment modelling, this axis is typically up-down: information in the Z-axis is limited to height alone. Rasterised Digital Elevation Models (DEMs) are a typical use of 2.5D in built environment modelling. In these, the model is divided into minimum cells of uniform dimension in the X–Y plane, usually pixels, and the environment representation is quantised to fit that cell grid.
Although 2.5D representation is efficient, it does have an inherent limitation in that it cannot truly represent the case of an object separated from the ground such as a bridge, roofed open space, outward-sloping wall or balcony. In that case, the object must be either omitted or treated as a solid from the ground to its top extents. Further limitations on representational fidelity are introduced if using a raster 2.5D format as building and other geometry is unlikely to exactly match the cell grid. This leads to two notable artefacts: in the case of a partially covered cell, geometry will either be missing or overrepresented as the filled state of cells is binary, and, in the case of a geometry boundary that does not exactly align with the orthogonal grid, that boundary will have an aliased or jagged representation.
Despite these limitations, 2.5D representation can work well for appropriately selected applications. The raster artefacts mentioned above can be mitigated by appropriate choice of cell dimension. For example, a precinct-scale study might be sufficiently accurate for a particular purpose at 1-m resolution. Applications such as solar envelopes – the maximum volume for a building calculated with respect to the sun’s path that preserves a given level of solar amenity in adjacent spaces – as commonly implemented are in effect operating in 2.5D, and their calculation is hence not limited by explicit 2.5D representation. 3
Calculating shadows in rasterised 2.5D allows a rapid, responsive, heuristical approach that is suitable for such purposes for which the above-given fidelity issues are not an impediment. The method for calculating origin-aware shadows in this article extends a raster 2.5D procedure first proposed by Richens 4 and elaborated on by Ratti and Richens. 5 Their central concept is that a total shadow volume is generated for a raster DEM as the aggregate of partial shadow volumes. A copy of the DEM is successively translated directly away from the sun to give partial shadow volumes. This iterative translation continues until the copy DEM is fully subsumed by the ground plane, upon when the original DEM is subtracted from the aggregated partial shadow volumes to give the final shadowing result. The translation increment is a vector pointing from the sun to the DEM; the vector is scaled such that the larger of its X and Y components is 1 so that the DEM translations align with either of the X or Y pixel boundaries.
In the following years, the approach of Richens and Ratti has been variously applied, although often in rationalised form of a scan line process. In that process, the translation vector is used to step pixelwise across the raster DEM while keeping register of the current elevation of the shadow, if one exists, along that scan line. These scan lines are not necessarily in the X or Y direction; instead, the pixelwise step direction depends on the sun vector for the chosen time and day.
Piper et al. used the approach for direct physical manipulation of a DEM by users for real-time shadow feedback to those users. 6 Their system, Illuminating Clay, combined a table-top tactile clay landscape model, to be altered by users, which was laser scanned to create a DEM and onto which the shadowing and other computational analysis are displayed by an overhead projector. Ratti and Richens used the algorithm to calculate sky view factors (SVFs) in a DEM by running it for many light sources distributed over the sky dome and, for each pixel in the DEM, calculating SVF as the ratio of number of times a pixel is not shadowed to the count of sky light sources. 7 Ratti and Morello used the algorithm to calculate solar envelopes in 2.5D. 8 Carneiro et al. 9 used the algorithm in a package of urban environment quality indicator tools to calculate solar incidence radiation and, as part of this, measured shadowing on facades. Redweik et al. 10 used the algorithm to model solar irradiance and extended it to allow for a slope value per raster cell and visual overlay of algorithm results for different times of day or year. In related work, Bremer et al. 11 used a voxel-based shadow heuristic for multiscale 3D GIS modelling of solar income.
This article presents a novel 2.5D raster-based approach for shadow generation in digital built environment modelling with identities of shadowing sources for any point on the ground efficiently precalculated. A unique contribution of the research is the rapid classification and computational indexing of shadowing sources as either actual or experiential from the point of view of an observer on the ground (Figure 1). Actual shadow origins are those features that block the sun, that is, the feature one would see if looking from the sun’s position to a point of interest on the DEM. Experiential shadow origins are those features that appear to block the sun, that is, the feature one would see if looking from a point of interest on the DEM to the sun’s position. A feature can be simultaneously an actual and experiential shadow origin for the same sun position.

Actual and experiential shadow origins. The girl on the left has buildings A and B as her actual and experiential shadow origins, respectively, whereas the boy on the right has building A alone for both origins.
Origin-aware shadow algorithm
The novel origin-aware shadow algorithm given in this article (‘the algorithm’) modifies and extends the recently used scan line approach to the Ratti and Richens method. Its inputs, outputs, processing and use are given below. The technical detail in the description may not be for every reader but is provided for the benefit of those with a programming interest.
Inputs
A temporary raster DEM representing elevations of features of interest, such as buildings or trees, is created. Alongside this DEM, a corresponding raster is populated with unique integer IDs for those features of interest, with any raster pixel that does not contain a feature being initialised with a predefined ‘unset’ value.
In addition, a temporary raster DEM representing the terrain elevations is created; this is different to some other implementations, and the original Ratti and Richens description, that only specify use of a flat ground plane represented by a single Z-axis value.
A final, composite DEM is created by superimposing the feature DEM on the terrain DEM to give a DEM of all elevations in the model. This composite DEM and the corresponding ID raster are preserved for use in the processing step.
Outputs
The result of the shadow calculation algorithm is output to a raster with size and indexing corresponding to the input DEM. Multiple sun positions are accommodated in this raster by using a unique bitmask for each sun position: if that bitmask is set in an output pixel, then that pixel is in shadow for that sun position. This bitmask solution is convenient to implement but does limit the number of sun positions to the bit length of the output raster pixel; however, alternative data structures could be used if a greater number of sun positions is needed.
For each sun position to be calculated, two additional output rasters are created: one for actual shadow origin feature IDs and one for experiential shadow origin feature IDs.
Processing
The standard scan line shadow calculation algorithm is modified by, for each scan line of pixels, maintaining two stacks of temporary data:
A stack of floating-point numbers holding the height of all ‘alive’ or current shadows (shadow height stack). This replaces the usual single-variable technique for storing the current shadow height.
A stack of integer numbers holding the feature ID of the source of all alive shadows (shadow origin stack).
These two stacks are always pushed and popped in conjunction so that they maintain the same size and so that items on them with equal indices correspond to each other.
The two stacks are initially empty at the start of a scan line. On each pixelwise step within a scan line, and while the current pixel is within the DEM bounds, the following steps are performed:
Any items in the shadow height stack are updated with the Z component of the sun position vector.
Any obsolete or ‘dead’ shadows – being those with height less-than-or-equal-to the current DEM pixel – are popped from the shadow height and origin stacks.
If there is a feature associated with the current DEM pixel, and if that feature is new and therefore not recorded on the top of the shadow origin stack, or if the shadow height and origin stacks are empty, then the relevant data for the current DEM pixel position should be pushed onto the stacks.
If the shadow height and origin stacks are not empty, then, for the current pixel,
set the output shadow raster with the sun position bitmask, set the experiential shadow origin feature ID raster with the top element of the shadow origin stack and set the actual shadow origin feature ID raster with the bottom element of the shadow origin stack.
It would be trivial to extend the algorithm to identify the specific part of a feature that originates a shadow by either when storing the experiential and actual shadow origin feature IDs, also storing the originating raster pixel index, or else by using sub-feature IDs.
Use and verification
Finding the shadow origins of any pixel in the DEM is simply a matter of accessing the corresponding pixel in the experiential and actual shadow origin feature ID rasters for all desired sun positions. The retrieved feature IDs may then be used to look up the feature in the source feature data.
A verification implementation was developed in the C++ programming language using OpenGL™ for graphics rendering (Figure 2). The unoptimised, single-threaded implementation, which modelled three simultaneous sun positions over a notional area of 100 m square at 10-cm resolution with continual procedural change to the raster DEM elevation data, was able to run in excess of 30 fps on a standard Windows™ laptop (i7-6700HQ, 32 GB RAM, GeForce GTX 1060).

A verification implementation of the algorithm in OpenGL and C++.
Proof of concept software applications
The algorithm’s application in built environment simulation was investigated and demonstrated with two research software applications which are here presented with technical details.
Participatory built environment simulation with reactive scripting for design
A web-based interactive simulation was developed to demonstrate precinct-scale origin-aware shadow analysis for community engagement and explanatory utilisation in low-end computing contexts.
The model tests the algorithm as part of a reactive scripting for design workflow. Reactive scripting for design inserts input of the user, being either the designer or non-expert stakeholder, as a vital decision-making step within iterative, self-referential digital workflows 12 (‘Designer in the loop’ and related terms have gained currency in recent years; I see reactive scripting for design to be in this paradigm). The technique makes explicit those cohering parameter connections that are the essence of a design scenario and allows adjustment of those connections. It thereby assists navigation of intractable issues or rivalrous considerations and allows adaptation and change to become part of the development of the system. The interaction with actual and experiential shadow origins in the web-based model demonstrates to the user, in this reactive scripting context, the effect of shadows and their contribution to the experience of place so that users can become the arbiter of the dilemmas illustrated.
Technical implementation
The application was developed in HTML, JavaScript™ and the Mapbox™ open source mapping platform. The application simulates at 1-m resolution a square-kilometre section of Melbourne, Australia, selected to cover a variety of built environment usages, including central business district, parkland, river, transport and entertainment.
Building data were obtained from the City of Melbourne Open Data Platform. 13 The dataset contains, for each building in the City of Melbourne in 2015, a building footprint given as a closed outline of latitude and longitude coordinates and the elevation of the tallest part of that building. Terrain data were obtained from the Google Maps™ Elevation API for queried latitude and longitude points.
The application, on starting, loads and processes a local copy of the City of Melbourne building data to create a temporary raster DEM of buildings for the selected square-kilometre section (Figure 3, left). In the same step, the corresponding feature ID raster is created. A temporary terrain DEM is created by interpolating across a grid of elevations, sampled over the target area, obtained from the Google Maps™ Elevation API (Figure 3, middle). The composite DEM used in the algorithm is then synthesised from the building and terrain DEMs (Figure 3, right).

Feature (left), terrain (middle) and composite (right) DEMs in cyclic false colour.
The composite DEM is processed by the algorithm for one or more specified sun positions. Within the modelled area, the resulting shadows are presented with an industry-common visualisation hierarchy of overlapping, alpha-blended shadows so that areas that are covered by more sun position shadows are correspondingly darker, as has been used in widely accepted commercial built environment modelling packages such as Autodesk Ecotect™ and Ladybug Tools for Rhinoceros™/Grasshopper™.
User experience and participation
The application provides an interface that allows non-specialist users to explore shadows and their origins in the selected area of Melbourne. Controls are partitioned for the environment-level and location-specific interactions enabled by the algorithm.
An action bar gives users control of environment-level interactions with the algorithm, and those outcomes are automatically calculated and immediately viewed (Figure 4, top). Any day of year may be chosen, and, within that day, any combination of hours from 8:00 a.m. to 4:00 p.m. may be selected for which to display building shadows (Figure 4). This use of hour granularity and choice of hour range is a design decision and not a limitation of the algorithm. A button within the action bar highlights for the user the interplay of shadows and changing terrain elevation. The use within the computational process of a separate ground DEM, rather than a simple uniform ground plane, allows terrain elevation to be coloured so that users may more easily observe how shadows moving over rising or falling terrain are shortened or lengthened.

Calculation options (top) and results for 9:00 a.m., 12:00 p.m. and 3:00 p.m. on 22 June 2018.
Users may better understand the local significance and consequences of shadows and their origins by selecting elements within the simulation. By default, users see shadows for all buildings and specified sun positions. Selecting any single building will show only the shadows for which that building is actually responsible (Figure 5): that is, that building’s unique shadow contribution to the environment. Within a building’s unique shadow are shown the alpha-blended contributions of other buildings: a user is thus invited to step across the simulation and trace the interconnected spatiotemporal causes of shadowing in the built environment simulated. In the example illustrated, the selected building at 196 Flinders Street casts in the simulation a much-truncated shadow at 9:00 a.m. and no shadow at all at 3:00 p.m. due to Saint Paul’s Cathedral to the west.

A selected building for 9:00 a.m. and 3:00 p.m. on 22 September 2018 and that building’s unique shadow contribution to the environment.
As part of the reactive scripting for design loop, adjustable building elements within the simulation may be selected by the user and their heights increased or decreased in response to the experiential and actual shadowing information provided by the algorithm. A user interacting in this way thus inserts into a design process based around the simulation their knowledge, assumptions and preferences that might otherwise not be captured.
Users may also select a point on the terrain to place a ‘sensor’ marker for which to show both the actual and experiential shadow origins for all selected sun positions (Figure 6, right). In the example illustrated, the marker near 82 Flinders Street has, left to right, an actual and an experiential building for the 3:00 p.m. sun position and an actual-and-experiential building for the 9:00 a.m. sun position. Such buildings are colour-coded and labelled with the relevant sun position hour.

A selected point (yellow dot marked with an ‘X’) for 9:00 a.m. and 3:00 p.m. on 22 September 2018. The leftmost and centre colour-coded buildings are actual and experiential shadow origins, respectively, for the selected point at 3:00 p.m., and the rightmost building is the actual and experiential shadow origin at 9:00 a.m.
By making explicit the origin of shadows within the simulation, the user is involved as the decision maker in the reactive scripting for design loop. Furthermore, this web-based model implementation provides a responsive user experience of real-time shadow calculation, and demonstrates a use case for the algorithm of rapid, heuristical and interactive solar modelling for community engagement for any place in the world for which low-cost 2.5D building data can be generated.
Generative modelling of solar envelopes
A simple proof of concept model for use of the origin-aware algorithm in generative techniques in built environment modelling was created in Java™, and expands on the solar envelope approaches of Knowles, 3 Ratti and Morello, 8 and White. 2 In the model, building solar envelopes are evolved by adjusting their volumes in response to continuous assessment of their effect on street-level solar amenity.
Technical implementation
The model’s precinct-level urban environment simulation is initialised with a randomly generated city grid composed of 10 m2 building-block cells (Figure 7). Each unit of contiguous cells, which is defined by separating streets, is considered to be a single, connected building. Each cell within a building is filled with a uniform, common starting height chosen to fall between predefined common minimum and maximum height limits. The building is hence given an overall minimum solar envelope volume to be conserved. Pedestrian ‘portals’ are placed on the interior streets and perimeter of the city grid, and shortest paths are found between them using Dijkstra’s algorithm. Sun positions for selected times of day and/or year are set for the shadow algorithm so that the buildings cast shadows which are calculated at 1-m resolution.

The simulation starting condition showing sun positions, shadows and uniform building heights.
The simulation runs with the steps below until a relative equilibrium is found; this ending state is reached when the rate and magnitude of adjustments to the generated solar envelopes fall below a given threshold.
New pedestrians are spawned at portals at a rate such that the pedestrian population maintains a given level of simulation coverage. These pedestrians are not agents as they merely travel between assigned starting and ending portals and make no independent decisions, and are instead best considered to be moving sensor markers along the lines of the sensor markers in the previously described web-based implementation.
Pedestrians, as they obediently travel, maintain a weighted moving average, with a specified, adjustable sliding window, of their time in sun and shadow to provide a street-level ‘thermal comfort’ or solar amenity metric.
For each simulation frame, a pedestrian, if in shadow, reports its thermal comfort to the building cell casting that shadow. Any building cell that does not receive reports that it is contributing to excessive cooling may spontaneously grow its height by a small increment, shown in green in Figure 8. Any cell that does receive such reports will attempt to reduce its height: first by consuming green self-seeded height if present and then, if that is not present, by attempting to pass on part of its height to a neighbouring cell in its building, while not causing minimum nor maximum height limits to be breached.

Generated solar envelopes in the simulation. Pedestrians are shown at street level with their thermal comfort moving average indicated in blue (cold) to red (warm); the building cells they report to in each simulation frame are similarly tagged. Pedestrian portals are shown as yellow hexagons.
Results
The initial results demonstrate that the origin-aware shadow algorithm is a useful tool for generative design (Figure 8). The solar envelopes found in the proof of concept display forms that are not of immediately intuitive derivation, and their forms are novel compared to the outputs of those established approaches discussed in this article that rely directly on the sun’s position. Furthermore, the use of origin-tagged shadows enables these envelopes to respect two conditions not considered in established approaches: first, the actual use and experience of the environment by pedestrians (insofar as those are modelled in this nascent simulation) and, second, conservation of buildings’ solar envelope minimum volumes while attempting to maximise volumes.
The use of the algorithm here shown can be directly applied to other architectural and urban design issues. To illustrate, the generative solar envelopes, which in this application have been driven by the moving averages of shadowing experience along pedestrian circulation paths, may respond instead to overshadowing of an urban park to ensure at least a certain proportion of that park is unshadowed for all daylight hours throughout the year.
Future work
Community participation and generative modelling research software applications of the algorithm have been documented in detail in this article. Although further verification of application of the algorithm is beyond the scope of this article, the results of those two proofs of concept suggest the algorithm can be applied in other research, prototyping and civic engagement contexts in architectural and urban design, and raise the question of ’where next?’
At the time of writing, four areas of ideational application are being investigated by the author.
The low processing overhead and responsive interactivity of the algorithm makes it suitable for inclusion in self-help parametric digital workbench apps designed to help residents explore for themselves viable social and geospatial organisation for their settlements. 14 This digital workbench app framework, to be applied in developing communities with little access to powerful computing technology, relies on integrated mechanics to illustrate built environment issues so to allow citizens to visualise the consequences of their decisions and prioritise competing outcomes and interests.
The algorithm can assist working with big data. As a proof of concept for winnowing large datasets before more expensive computational processes are applied, a digital tool for using the algorithm to display shadows from large point cloud input is being investigated. An example use of this is city-scale LIDAR point cloud data may be rapidly quantised to 2.5D raster form for immediate shadow and shadow origin inspection, with the output used as a decision-making step to guide development of a further computational design workflow or to complement computationally intense 3D analysis.
The capacity of the algorithm to rapidly generate shadow analyses with origins tagged allows it to be incorporated efficiently in certain artificial intelligence workflows. The generative solar envelopes research software application discussed here is already using a quasi-evolutionary-computing methodology: further work will show application of the algorithm to true artificial intelligence contexts. For example, it can be incorporated into the fitness assessment step of a genetic algorithm process such as one evolving architectural form in the manner of Besserud and Cotton, 15 and it can be used to generate labelled training data for machine learning processes such as a generative adversarial network to produce sketch street design options for greenfield projects.
The applied modelling and visualisation techniques used in the proofs of concept are only a subset of those possible. Novel extensions and their applicability to, and significance for, community participation, analytical and other purposes are being explored. Areas being investigated include the possibilities of experiential shadows as a distinct mode of display and simulation, the potential of explicit display of the effect of terrain on shadow coverage via colour gradients and other means, and the modelling and significance of shadowing at varying levels from the ground, such as the experience and preference accommodation of people of different heights.
Furthermore, the algorithm can extend the precedent works given in the introduction. The method of Ratti and Richens 7 to calculate SVFs, for example, may be extended to also identify the specific buildings and classes of buildings that contribute most to poor SVF with the results used to inform a process for addressing the negative externality those building owners impose on the public.
Conclusion
Using the 2.5D raster DEM technique for shadow generation described in this article as an alternative or complement to 3D shadow modelling allows origin-aware shadows to be calculated efficiently at large scales. Despite fidelity limitations of 2.5D representation, the approach can be powerful in appropriately selected use cases as is demonstrated by the two proof of concept software applications.
The capability of 2.5D raster-based shadow modelling is greatly extended by the novel origin-aware shadow calculation algorithm detailed in this article. Shadow origin indexing allows digital built environment models to respond specifically to the actual features contributing to shadowing. The identification and computational indexing of actual and experiential shadow origins is, based on a survey of relevant literature at the time of writing, a novel extension to shadow modelling in built environments.
The method for shadow origin labelling here presented has relatively low computational overhead and is simple to implement and modify, and hence can be applied to many digital workflows in architectural and urban design, including those using big data, artificial intelligence and community participative processes.
Footnotes
Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) received no financial support for the research, authorship, and/or publication of this article.
