Intricate details for buildings. Adjustments to tree generation. Removed textures to make them available in a separate package.

This commit is contained in:
Marcus Str. 2024-12-21 18:18:49 +01:00
parent 3de9058cc6
commit c7f96e7783
591 changed files with 63 additions and 22 deletions

View File

@ -381,7 +381,7 @@ class mstr_layergen:
self._tag == "natural" and self._value == "heath") or ( self._tag == "natural" and self._value == "heath") or (
self._tag == "landuse" and self._value == "cemetery") or ( self._tag == "landuse" and self._value == "cemetery") or (
self._tag == "landuse" and self._value == "residential"): self._tag == "landuse" and self._value == "residential"):
amt = randrange(2, 9) amt = randrange(5, 21)
masks = glob.glob(mstr_datafolder + "textures/tile/completion/*.png") masks = glob.glob(mstr_datafolder + "textures/tile/completion/*.png")
patchtags = [ patchtags = [
["landuse", "meadow"], ["landuse", "meadow"],
@ -600,30 +600,18 @@ class mstr_layergen:
# A bit different for tree rows # A bit different for tree rows
if self._tag == "natural" and self._value == "tree_row": if self._tag == "natural" and self._value == "tree_row":
trees = Image.new("RGBA", (self._imgsize, self._imgsize)) 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) lx = randrange(self._imgsize)
ly = randrange(self._imgsize) ly = randrange(self._imgsize)
a = mask_pix[lx,ly] 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 a[3] > 0:
if lx < self._imgsize and ly < self._imgsize: if lx < self._imgsize and ly < self._imgsize:
tree = self.generate_tree() c = (0,0,0,1)
trees.alpha_composite(tree, (lx, ly)) treespx[lx,ly] = c
trees = ImageEnhance.Contrast(trees).enhance(0.8) layer_comp.alpha_composite(trees)
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)
mstr_msg("layergen", "Layer image generated") mstr_msg("layergen", "Layer image generated")

View File

@ -203,6 +203,9 @@ class mstr_photogen:
# One more thing... # One more thing...
mstr_msg("photogen", "Adding features to layers") mstr_msg("photogen", "Adding features to layers")
self.addTreesToFeatures(layers, waterlayers) self.addTreesToFeatures(layers, waterlayers)
# One final thing...
mstr_msg("photogen", "Adding details to buildings")
self.addDetailsToBuildings()
# Throw missing buildings on top # Throw missing buildings on top
lyr = 0 lyr = 0
@ -375,7 +378,7 @@ class mstr_photogen:
for x in range(0, self._imgsize): for x in range(0, self._imgsize):
frs = frstpix[x,y] frs = frstpix[x,y]
if frs[3] > 0: 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) frstclr.append(c)
@ -388,6 +391,7 @@ class mstr_photogen:
lyr[0] == "leisure" and lyr[1] == "park"): lyr[0] == "leisure" and lyr[1] == "park"):
trees = Image.new("RGBA", (self._imgsize, self._imgsize)) trees = Image.new("RGBA", (self._imgsize, self._imgsize))
amt = 4000 amt = 4000
if lyr[1] == "cemetery": amt = 20000
lyrmask = layers[curlyr].load() # We can use the layer image as alpha mask lyrmask = layers[curlyr].load() # We can use the layer image as alpha mask
for i in range(1, amt + 1): for i in range(1, amt + 1):
lx = randrange(0, self._imgsize) lx = randrange(0, self._imgsize)
@ -395,7 +399,9 @@ class mstr_photogen:
lp = lyrmask[lx,ly] lp = lyrmask[lx,ly]
wp = wtrpix[lx,ly] wp = wtrpix[lx,ly]
if lp[3] == 255 and wp[3] == 0: # Exclude water bodies from tree placement 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)) trees.alpha_composite(tree, (lx, ly))
tree_shadow = Image.new("RGBA", (self._imgsize, self._imgsize)) tree_shadow = Image.new("RGBA", (self._imgsize, self._imgsize))
@ -414,6 +420,26 @@ class mstr_photogen:
self._tile.alpha_composite(tree_shadow) self._tile.alpha_composite(tree_shadow)
curlyr = curlyr + 1 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 # Reset
curlyr = 0 curlyr = 0
bldg = [] bldg = []
@ -435,6 +461,33 @@ class mstr_photogen:
tilepix[x,y] = ( bpix[0], bpix[1], bpix[2], bpix[3] ) 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)
# Correct some layer issues # Correct some layer issues
def correctLayerIssues(self, layers): def correctLayerIssues(self, layers):

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 557 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 486 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 942 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 972 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 895 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 828 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 978 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 922 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 877 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 859 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 911 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 668 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 718 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Some files were not shown because too many files have changed in this diff Show More