Commit a9dce5d9 authored by Thomas Albrecht's avatar Thomas Albrecht

cherry picked fake ambient occlusion: gradually darken facade textures towards the ground

Conflicts:
	textures.py
parent 3bab140b
......@@ -104,7 +104,7 @@ def check_height(building_height, t):
# - error acceptable?
if building_height >= t.v_cuts_meters[0] and building_height <= t.v_size_meters:
# print "--->"
if 0 and t.v_align_bottom:
if t.v_align_bottom or parameters.BUILDING_FAKE_AMBIENT_OCCLUSION:
logging.debug("from bottom")
for i in range(len(t.v_cuts_meters)):
if t.v_cuts_meters[i] >= building_height:
......
#!/usr/bin/env python
import numpy as np
from PIL import Image
from copy import copy
def img2RGBA(img):
"""convert PIL image to individual np arrays for R,G,B,A"""
n = np.array(img)/255.
height_px, width_px = n.shape[:2]
if len(n.shape) == 2:
n_channels = 1
else:
n_channels = n.shape[2]
zero = np.zeros((height_px, width_px))
if n_channels == 1:
R = copy(n)
G = copy(zero)
B = copy(zero)
A = copy(zero) + 1.
elif n_channels >= 3:
R = copy(n[:,:,0])
G = copy(n[:,:,1])
B = copy(n[:,:,2])
if n_channels == 4:
A = copy(n[:,:,3])
else:
A = copy(zero) + 1.
else:
raise NotImplementedError("can't handle number of channels")
return R, G, B, A
def RGBA2img(R, G, B, A=None):
channels = "RGB"
if A: channels = "RGBA"
height_px, width_px = R.shape
n = np.zeros((height_px, width_px, len(channels)))
n[:,:,0] = R #* random.uniform(0.5, 1.0)
n[:,:,1] = G
n[:,:,2] = B
if A: n[:,:,3] = A
#channel_name = 'RGBA'
#for i, channel in enumerate([R, G, B, A]):
# print "%s: %1.2f %1.2f" % (channel_name[i], channel.min(), channel.max())
out = (n*255).astype('uint8')
return Image.fromarray(out, channels)
......@@ -95,6 +95,10 @@ BUILDING_SKEL_ROOFS_MAX_ANGLE = 50 # have a random angle between MIN and MAX
BUILDING_SKEL_MAX_NODES = 10 # -- max number of nodes for which we generate pySkeleton roofs
BUILDING_SKEL_MAX_HEIGHT_RATIO = 0.7 # -- skip skel roofs if ratio of roof height to base building height is larger than this
BUILDING_FAKE_AMBIENT_OCCLUSION = True
BUILDING_FAKE_AMBIENT_OCCLUSION_HEIGHT = 6.
BUILDING_FAKE_AMBIENT_OCCLUSION_VALUE = 0.7
EXPERIMENTAL_INNER = 0 # -- do we still need this?
# -- Parameters which influence the height of buildings if no info from OSM is available.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment