Learn R Programming

hillshader (version 0.1.2)

add_shadow_2d: Add shadow

Description

Multiplies a texture array or shadow map by a shadow map.

Usage

add_shadow_2d(hillshade, shadowmap, max_darken = 0.7, rescale_original = FALSE)

Value

A shaded map.

Arguments

hillshade

A 2D matrix of shadow intensities.

shadowmap

A matrix that indicates the intensity of the shadow at that point. 0 is full darkness, 1 is full light.

max_darken

Default '0.7'. The lower limit for how much the image will be darkened. 0 is completely black, 1 means the shadow map will have no effect.

rescale_original

Ignored.

Author

Slight modification from Tyler's code in rayshader::add_shadow

Examples

Run this code

library(rayshader)

# Create elevation matrix
el_mat <- raster_to_matrix(maungawhau)

el_mat %>%
 # Create hillshade layer using
 # ray-tracing
 ray_shade() %>%
 # Add ambient shading
 add_shadow_2d(
   ambient_shade(
     heightmap = el_mat
   )
 )

Run the code above in your browser using DataLab