Intricate details for buildings. Adjustments to tree generation. Removed textures to make them available in a separate package.
28
layergen.py
@ -381,7 +381,7 @@ class mstr_layergen:
|
||||
self._tag == "natural" and self._value == "heath") or (
|
||||
self._tag == "landuse" and self._value == "cemetery") or (
|
||||
self._tag == "landuse" and self._value == "residential"):
|
||||
amt = randrange(2, 9)
|
||||
amt = randrange(5, 21)
|
||||
masks = glob.glob(mstr_datafolder + "textures/tile/completion/*.png")
|
||||
patchtags = [
|
||||
["landuse", "meadow"],
|
||||
@ -600,30 +600,18 @@ class mstr_layergen:
|
||||
# A bit different for tree rows
|
||||
if self._tag == "natural" and self._value == "tree_row":
|
||||
trees = Image.new("RGBA", (self._imgsize, self._imgsize))
|
||||
for t in range(20001):
|
||||
treespx = trees.load()
|
||||
for t in range(80001):
|
||||
lx = randrange(self._imgsize)
|
||||
ly = randrange(self._imgsize)
|
||||
a = mask_pix[lx,ly]
|
||||
# Just mark the hit with a black pixel.
|
||||
# This will be used as "target" by photogen
|
||||
if a[3] > 0:
|
||||
if lx < self._imgsize and ly < self._imgsize:
|
||||
tree = self.generate_tree()
|
||||
trees.alpha_composite(tree, (lx, ly))
|
||||
trees = ImageEnhance.Contrast(trees).enhance(0.8)
|
||||
if mstr_shadow_enabled == True:
|
||||
tree_shadow = Image.new("RGBA", (self._imgsize, self._imgsize))
|
||||
tree_pix = trees.load()
|
||||
shadow_pix = tree_shadow.load()
|
||||
for y in range(self._imgsize):
|
||||
for x in range(self._imgsize):
|
||||
tp = tree_pix[x,y]
|
||||
if tp[3] > 0:
|
||||
rndshd = randrange(5, 210)
|
||||
sc = (0,0,0,rndshd)
|
||||
if x+8 < self._imgsize and y+5 < self._imgsize:
|
||||
shadow_pix[x+8,y+5] = sc
|
||||
tree_shadow = tree_shadow.filter(ImageFilter.GaussianBlur(radius=2))
|
||||
tree_shadow.alpha_composite(trees)
|
||||
layer_comp.alpha_composite(tree_shadow)
|
||||
c = (0,0,0,1)
|
||||
treespx[lx,ly] = c
|
||||
layer_comp.alpha_composite(trees)
|
||||
|
||||
mstr_msg("layergen", "Layer image generated")
|
||||
|
||||
|
57
photogen.py
@ -203,6 +203,9 @@ class mstr_photogen:
|
||||
# One more thing...
|
||||
mstr_msg("photogen", "Adding features to layers")
|
||||
self.addTreesToFeatures(layers, waterlayers)
|
||||
# One final thing...
|
||||
mstr_msg("photogen", "Adding details to buildings")
|
||||
self.addDetailsToBuildings()
|
||||
|
||||
# Throw missing buildings on top
|
||||
lyr = 0
|
||||
@ -375,7 +378,7 @@ class mstr_photogen:
|
||||
for x in range(0, self._imgsize):
|
||||
frs = frstpix[x,y]
|
||||
if frs[3] > 0:
|
||||
c = ( frs[0]-30, frs[1]-30, frs[2]-30 )
|
||||
c = ( frs[0]-40, frs[1]-40, frs[2]-40 )
|
||||
frstclr.append(c)
|
||||
|
||||
|
||||
@ -388,6 +391,7 @@ class mstr_photogen:
|
||||
lyr[0] == "leisure" and lyr[1] == "park"):
|
||||
trees = Image.new("RGBA", (self._imgsize, self._imgsize))
|
||||
amt = 4000
|
||||
if lyr[1] == "cemetery": amt = 20000
|
||||
lyrmask = layers[curlyr].load() # We can use the layer image as alpha mask
|
||||
for i in range(1, amt + 1):
|
||||
lx = randrange(0, self._imgsize)
|
||||
@ -395,7 +399,9 @@ class mstr_photogen:
|
||||
lp = lyrmask[lx,ly]
|
||||
wp = wtrpix[lx,ly]
|
||||
if lp[3] == 255 and wp[3] == 0: # Exclude water bodies from tree placement
|
||||
tree = self.generate_tree(frstclr)
|
||||
tree = None
|
||||
if len(frstclr) != 0: tree = self.generate_tree(bccolor=frstclr)
|
||||
else: tree = self.generate_tree()
|
||||
trees.alpha_composite(tree, (lx, ly))
|
||||
|
||||
tree_shadow = Image.new("RGBA", (self._imgsize, self._imgsize))
|
||||
@ -414,6 +420,26 @@ class mstr_photogen:
|
||||
self._tile.alpha_composite(tree_shadow)
|
||||
curlyr = curlyr + 1
|
||||
|
||||
# Reset for tree rows
|
||||
curlyr = 0
|
||||
treerow = -1
|
||||
for lyr in self._lyrnames:
|
||||
if lyr[0] == "natural" and lyr[1] == "tree_row":
|
||||
treerow = curlyr
|
||||
break
|
||||
curlyr = curlyr + 1
|
||||
|
||||
if treerow != -1:
|
||||
rowpx = layers[curlyr].load()
|
||||
for y in range(0, self._tile.height):
|
||||
for x in range(0, self._tile.width):
|
||||
tpx = rowpx[x,y]
|
||||
if tpx[3] == 1:
|
||||
tree = None
|
||||
if len(frstclr) == 0: tree = self.generate_tree()
|
||||
else: tree = self.generate_tree(bccolor=frstclr)
|
||||
self._tile.alpha_composite(tree, dest=(x, y))
|
||||
|
||||
# Reset
|
||||
curlyr = 0
|
||||
bldg = []
|
||||
@ -433,6 +459,33 @@ class mstr_photogen:
|
||||
spix = shdw_pix[x,y]
|
||||
if bpix[3] > 0 and spix[0] == 255:
|
||||
tilepix[x,y] = ( bpix[0], bpix[1], bpix[2], bpix[3] )
|
||||
|
||||
|
||||
# Adds some intricate details to buildings
|
||||
def addDetailsToBuildings(self):
|
||||
curlyr = 0
|
||||
bldg = []
|
||||
for lyr in self._lyrnames:
|
||||
if lyr[0] == "building":
|
||||
bldg.append(curlyr)
|
||||
curlyr = curlyr + 1
|
||||
|
||||
for b in range(0, len(bldg)):
|
||||
shdw = Image.open(mstr_datafolder + "_cache/" + str(self._lat) + "-" + str(self._ty) + "_" + str(self._lng) + "-" + str(self._tx) + "_" + self._lyrnames[bldg[b]][0] + "-" + self._lyrnames[bldg[b]][1] + "_layer_shadow.png")
|
||||
shdw_pix = shdw.load()
|
||||
|
||||
det_image = Image.open(mstr_datafolder + "textures/building/details/"+str(randrange(1, 16))+".png")
|
||||
|
||||
detpx = det_image.load()
|
||||
|
||||
for y in range(0, shdw.height):
|
||||
for x in range(0, shdw.width):
|
||||
spx = shdw_pix[x,y]
|
||||
if spx[0] != 255:
|
||||
c = (0,0,0,0)
|
||||
detpx[x,y] = c
|
||||
|
||||
self._tile.alpha_composite(det_image)
|
||||
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 1.4 MiB |
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 1.4 MiB |
Before Width: | Height: | Size: 2.9 MiB |
Before Width: | Height: | Size: 2.7 MiB |
Before Width: | Height: | Size: 2.8 MiB |
Before Width: | Height: | Size: 2.1 MiB |
Before Width: | Height: | Size: 1.5 MiB |
Before Width: | Height: | Size: 557 KiB |
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 486 KiB |
Before Width: | Height: | Size: 1.8 MiB |
Before Width: | Height: | Size: 2.5 MiB |
Before Width: | Height: | Size: 2.6 MiB |
Before Width: | Height: | Size: 2.8 MiB |
Before Width: | Height: | Size: 2.6 MiB |
Before Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.0 MiB |
Before Width: | Height: | Size: 1.3 MiB |
Before Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.1 MiB |
Before Width: | Height: | Size: 2.0 MiB |
Before Width: | Height: | Size: 2.5 MiB |
Before Width: | Height: | Size: 2.4 MiB |
Before Width: | Height: | Size: 2.2 MiB |
Before Width: | Height: | Size: 2.4 MiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.7 MiB |
Before Width: | Height: | Size: 1.8 MiB |
Before Width: | Height: | Size: 1.9 MiB |
Before Width: | Height: | Size: 942 KiB |
Before Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 972 KiB |
Before Width: | Height: | Size: 895 KiB |
Before Width: | Height: | Size: 2.5 MiB |
Before Width: | Height: | Size: 1.7 MiB |
Before Width: | Height: | Size: 1.3 MiB |
Before Width: | Height: | Size: 2.7 MiB |
Before Width: | Height: | Size: 2.2 MiB |
Before Width: | Height: | Size: 2.3 MiB |
Before Width: | Height: | Size: 2.2 MiB |
Before Width: | Height: | Size: 3.4 MiB |
Before Width: | Height: | Size: 2.1 MiB |
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 2.2 MiB |
Before Width: | Height: | Size: 3.1 MiB |
Before Width: | Height: | Size: 2.8 MiB |
Before Width: | Height: | Size: 3.0 MiB |
Before Width: | Height: | Size: 2.4 MiB |
Before Width: | Height: | Size: 1.9 MiB |
Before Width: | Height: | Size: 2.2 MiB |
Before Width: | Height: | Size: 2.3 MiB |
Before Width: | Height: | Size: 2.7 MiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 828 KiB |
Before Width: | Height: | Size: 978 KiB |
Before Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 922 KiB |
Before Width: | Height: | Size: 877 KiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 859 KiB |
Before Width: | Height: | Size: 911 KiB |
Before Width: | Height: | Size: 668 KiB |
Before Width: | Height: | Size: 718 KiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.4 MiB |
Before Width: | Height: | Size: 1.8 MiB |
Before Width: | Height: | Size: 2.1 MiB |
Before Width: | Height: | Size: 2.7 MiB |
Before Width: | Height: | Size: 3.0 MiB |
Before Width: | Height: | Size: 2.2 MiB |
Before Width: | Height: | Size: 2.2 MiB |
Before Width: | Height: | Size: 1.4 MiB |
Before Width: | Height: | Size: 1.2 MiB |