add_shadow_2d {hillshader}R Documentation

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)

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.

Value

A shaded map.

Author(s)

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

Examples


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
   )
 )


[Package hillshader version 0.1.2 Index]