Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

add_shadow

Add Shadow


Description

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

Usage

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

Arguments

hillshade

A three-dimensional RGB array or 2D matrix of shadow intensities.

shadowmap

A matrix that incidates 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

Default 'FALSE'. If 'TRUE', 'hillshade' will be scaled to match the dimensions of 'shadowmap' (instead of the other way around).

Value

Shaded texture map.

Examples

#First we plot the sphere_shade() hillshade of `montereybay` with no shadows


montereybay %>%
 sphere_shade(colorintensity=0.5) %>%
 plot_map()


#Raytrace the `montereybay` elevation map and add that shadow to the output of sphere_shade()

montereybay %>%
 sphere_shade(colorintensity=0.5) %>%
 add_shadow(ray_shade(montereybay,sunaltitude=20,zscale=50),max_darken=0.3) %>%
 plot_map()


#Increase the intensity of the shadow map with the max_darken argument.

montereybay %>%
 sphere_shade(colorintensity=0.5) %>%
 add_shadow(ray_shade(montereybay,sunaltitude=20,zscale=50),max_darken=0.1) %>%
 plot_map()


#Decrease the intensity of the shadow map.

montereybay %>%
 sphere_shade(colorintensity=0.5) %>%
 add_shadow(ray_shade(montereybay,sunaltitude=20,zscale=50),max_darken=0.7) %>%
 plot_map()

rayshader

Create Maps and Visualize Data in 2D and 3D

v0.24.10
GPL-3
Authors
Tyler Morgan-Wall
Initial release
2021-04-25

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.