From 9eddb9742529637488b295d4c084af4836a3d437 Mon Sep 17 00:00:00 2001 From: "Marcus Str." Date: Mon, 27 Jan 2025 21:56:59 +0100 Subject: [PATCH] Corrections to amount of small trees and their shadow rendering. Test of render successful. Adjustment to base Perlins required for some tags. --- defines.py | 10 +++++----- layergen.py | 35 +++++++++++++++++++++++++---------- photogen.py | 12 ++++++++---- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/defines.py b/defines.py index 36aa7ce..733a505 100644 --- a/defines.py +++ b/defines.py @@ -74,12 +74,12 @@ mstr_xp_genscenery = True mstr_xp_scn_normalmaps = True # Paths to required X-Plane scenery tools -mstr_xp_meshtool = "/home/marcus/Developer/Projects/orthographic/bin/MeshTool" -mstr_xp_ddstool = "/home/marcus/Developer/Projects/orthographic/bin/DDSTool" -mstr_xp_dsftool = "/home/marcus/Developer/Projects/orthographic/bin/DSFTool" -mstr_xp_xessrc = "https://dev.x-plane.com/update/misc/MeshTool/" +#mstr_xp_meshtool = "/home/marcus/Developer/Projects/orthographic/bin/MeshTool" +mstr_xp_ddstool = "D:/Developer/Projects/orthographic/bin/DDSTool.exe" +mstr_xp_dsftool = "D:/Developer/Projects/orthographic/bin/DSFTool.exe" +#mstr_xp_xessrc = "https://dev.x-plane.com/update/misc/MeshTool/" mstr_xp_floor_height = 2.8 # 2.5m ceiling height + 30cm concrete per floor -mstr_xp_ortho_location = "/home/marcus/Data/Sim/Simulator/orthographic/" +mstr_xp_ortho_location = "D:/Simulator/12/Custom Scenery/z_orthographic/" # If you set the above to true, you can define for which features you # want to generate normal maps for. The below is my recommendation for diff --git a/layergen.py b/layergen.py index 60c6d33..59f3a3b 100644 --- a/layergen.py +++ b/layergen.py @@ -377,7 +377,10 @@ class mstr_layergen: if self._zoomlevel == 16: samples = 2000 txts = glob.glob(mstr_datafolder + "textures/" + self._tag + "/" + self._value + "/*.png") - ptc_src = Image.open(txts[randrange(0, len(txts))]) + ptc_name = txts[randrange(0, len(txts))] + while "brd" in ptc_name: + ptc_name = txts[randrange(0, len(txts))] + ptc_src = Image.open(ptc_name) if self._zoomlevel == 16: ptc_src = ptc_src.resize((250,250), resample=Image.Resampling.BILINEAR) clrz = mstr_colorizer(ptc_src) @@ -386,15 +389,23 @@ class mstr_layergen: for i in range(samples): xp = randrange(-125, 1924) yp = randrange(-125, 1924) + ptc = clrz._grs.rotate(randrange(0, 360), expand=True) + if self._value == "golf_course": + ptc = clrz._baseimg.rotate(randrange(0, 360), expand=True) tmp_layer.alpha_composite(ptc, (xp,yp)) # Add the seamless border brd = Image.open(mstr_datafolder + "textures/" + self._tag + "/" + self._value + "/brd.png") brd_clrz = mstr_colorizer(brd) - tmp_layer.alpha_composite(brd_clrz._grs) + if self._value != "golf_course": + tmp_layer.alpha_composite(brd_clrz._baseimg) + else: + tmp_layer.alpha_composite(brd_clrz._grs) - tmp_layer.putalpha(51) + if self._value != "golf_course": + tmp_layer.putalpha(51) + layer.alpha_composite(tmp_layer) mstr_msg("layergen", "Layer image generated") @@ -442,8 +453,7 @@ class mstr_layergen: # Add a white-ish border around pitches if self._tag == "leisure" and self._value == "pitch": - pitch_edge = osm_edge - pitch_edge = pitch_edge.filter(ImageFilter.GaussianBlur(radius=0.5)) + pitch_edge = mask.filter(ImageFilter.FIND_EDGES) pitch_mask = pitch_edge.load() # ImageOps.invert does not like RGBA images for inversion. So I need to do it. @@ -509,7 +519,7 @@ class mstr_layergen: # Generate an edge mask from the original osm_edge = mask.filter(ImageFilter.FIND_EDGES) - osm_edge = osm_edge.filter(ImageFilter.MaxFilter) + #osm_edge = osm_edge.filter(ImageFilter.MaxFilter) mstr_msg("layergen", "Edge mask generated") # As above, we will apply the blur as noted in the defines @@ -587,7 +597,7 @@ class mstr_layergen: if self._tag == "natural" and self._value == "tree_row": trees = Image.new("RGBA", (self._imgsize, self._imgsize)) treespx = trees.load() - for t in range(80001): + for t in range(450001): lx = randrange(self._imgsize) ly = randrange(self._imgsize) a = mask_pix[lx,ly] @@ -614,7 +624,7 @@ class mstr_layergen: # Find a suitable color w = randrange(125, 156) a=mask_pix[x,y] - layer_comp_pix[x, y] = ( w,w,w,a[3] ) + layer_comp_pix[x, y] = ( w,w,w,int(a[3]/3) ) if self._tag == "highway" and self._value == "residential": osm_edge = mask.filter(ImageFilter.FIND_EDGES) @@ -802,8 +812,13 @@ class mstr_layergen: 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 + spx = 8 + spy = 5 + if self._zoomlevel == 16: + spx = 2 + spy = 1 + if x + spx < self._imgsize and y + spy < self._imgsize: + shadow_pix[x + spx, y + spy] = sc tree_shadow = tree_shadow.filter(ImageFilter.GaussianBlur(radius=2)) tree_shadow.alpha_composite(trees) diff --git a/photogen.py b/photogen.py index df32899..d503e5b 100644 --- a/photogen.py +++ b/photogen.py @@ -238,8 +238,7 @@ class mstr_photogen: nrmimg.alpha_composite(wtrimg) # Save - nrmfln = mstr_datafolder + "z_orthographic/normals/" + self._latlngfld + "/" + str(self._ty) + "_" + str( - self._tx) + ".png" + nrmfln = mstr_datafolder + "z_orthographic/normals/" + self._latlngfld + "/" + str(self._ty) + "_" + str(self._tx) + ".png" nrmimg.save(nrmfln) @@ -403,8 +402,13 @@ class mstr_photogen: 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 + spx = 8 + spy = 5 + if self._zoomlevel == 16: + spx = 2 + spy = 1 + if x + spx < self._imgsize and y + spy < self._imgsize: + shadow_pix[x + spx, y + spy] = sc tree_shadow = tree_shadow.filter(ImageFilter.GaussianBlur(radius=2)) tree_shadow.alpha_composite(trees) self._tile.alpha_composite(tree_shadow)