Created
March 26, 2019 21:44
-
-
Save oganm/2f1cb21b056b4630b52cb2dde1bda9d1 to your computer and use it in GitHub Desktop.
terrain stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rayshader) | |
library(ambient) | |
k = 8 | |
m = noise_perlin(dim = c(2^k,2^k),octaves = 9) | |
mToMap(m) | |
m = noise_simplex(c(2^k,2^k),fractal = 'fbm',octaves = 4,lacunarity = 2,gain = .5,frequency = .01) | |
mToMap(m,1.4/3) | |
mToMap = function(m,landRatio = 1/3){ | |
map = m %>% ogbox::scaleToInt(0,1000) | |
raymat = ray_shade(map) | |
waterLimit = quantile(map,1-landRatio) | |
water = waterLimit>map | |
map = map - waterLimit | |
map %>% | |
round %>% | |
sphere_shade(texture = "desert") %>% | |
# add_water(water[,ncol(water):1], color="desert") %>% | |
add_shadow(raymat) %>% plot_3d(map,zscale=50,fov=0,theta=-45,phi=45,windowsize=c(1000,800),zoom=0.75, | |
water=TRUE, waterdepth = 0, wateralpha = 0.5,watercolor = "lightblue", | |
waterlinecolor = "white",waterlinealpha = 0.5) | |
map %>% | |
round %>% | |
sphere_shade(texture = "desert") %>% | |
add_water(water[,ncol(water):1], color="desert") %>% | |
plot_map() | |
} | |
addContinent = function(corner1,corner2){ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment