From: Marcus Str. Date: Wed, 9 Oct 2024 19:12:37 +0000 (+0200) Subject: Corrections to shadow sharpness, made sure shadows of buildings appear below forests X-Git-Url: https://marstr.online/code/gitweb.cgi?a=commitdiff_plain;h=265197d295c33621d1ec633fea705e5d88849330;p=orthographic Corrections to shadow sharpness, made sure shadows of buildings appear below forests --- diff --git a/defines.py b/defines.py index 033d61b..baf0c44 100644 --- a/defines.py +++ b/defines.py @@ -117,12 +117,12 @@ mstr_ortho_layers = [ ("landuse", "residential", "landuse", "residential-boundary"), ("landuse", "grass", "landuse", "grass"), ("landuse", "cemetery", "landuse", "grass"), + ("landuse", "recreation_ground", "landuse", "meadow"), + ("leisure", "golf_course", "leisure", "golf_course"), ("landuse", "greenfield", "landuse", "grass"), ("landuse", "orchard", "landuse", "meadow"), ("landuse", "meadow", "landuse", "meadow"), ("natural", "grassland", "landuse", "meadow"), - ("landuse", "recreation_ground", "landuse", "meadow"), - ("leisure", "golf_course", "leisure", "golf_course"), ("barrier", "hedge", "natural", "heath"), ("landuse", "vineyard", "landuse", "meadow"), ("natural", "bare_rock", "natural", "bare_rock"), @@ -419,4 +419,4 @@ mstr_completion_colors = [ (137,137,107) ] ) -] \ No newline at end of file +] diff --git a/layergen.py b/layergen.py index a2ae152..a74b234 100644 --- a/layergen.py +++ b/layergen.py @@ -610,7 +610,7 @@ class mstr_layergen: if lp[3] >= 250: shadow_pix[x,y] = (0,0,0,0) - shadow = shadow.filter(ImageFilter.GaussianBlur(radius=2)) + shadow = shadow.filter(ImageFilter.GaussianBlur(radius=1.5)) """ for y in range(self._imgsize-1): diff --git a/photogen.py b/photogen.py index d5a581f..38cc7c7 100644 --- a/photogen.py +++ b/photogen.py @@ -45,6 +45,9 @@ class mstr_photogen: # First, we walk through all layers and blend them on top of each other, in order mstr_msg("photogen", "Merging layers") + # Note if we added building shadows + bldg_shadow_added = False + # Shadow merging bldg_shadow = Image.new("RGBA", (self._imgsize, self._imgsize)) if mstr_shadow_enabled == True: @@ -80,7 +83,7 @@ class mstr_photogen: # Merge the building layers bldg_final = Image.new("RGBA", (self._imgsize, self._imgsize)) bldg_final.alpha_composite(bldg_details) - bldg_final.alpha_composite(bldg_shadow) + #bldg_final.alpha_composite(bldg_shadow) bldg_final.alpha_composite(tree_main) bldg_final.alpha_composite(bldg_main) @@ -88,6 +91,18 @@ class mstr_photogen: if os.path.isfile(root_filename + l[0] + "-" + l[1] + "_layer.png"): # Need to divert in case we have shadows if mstr_shadow_enabled == True: + + # Make sure building shadows appear below forests + shdc = False + for s in mstr_shadow_casters: + if s[0] == l[0] and s[1] == l[1]: + shdc = True + break + if shdc == True: + if bldg_shadow_added == False: + self._tile.alpha_composite(bldg_shadow) + bldg_shadow_added = True + if os.path.isfile(root_filename + l[0] + "-" + l[1] + "_layer_shadow.png"): if l[0] != "building": sn = root_filename + l[0] + "-" + l[1] + "_layer_shadow.png" @@ -265,4 +280,4 @@ class mstr_photogen: if abs(numbers[1]) >= 10 and numbers[0] <= 99: fstr = fstr + "0" + str(numbers[1]) if abs(numbers[1]) >= 100 : fstr = fstr + str(numbers[1]) - return fstr \ No newline at end of file + return fstr