]> marstr Code Repo - orthographic/commitdiff
Corrections to shadow sharpness, made sure shadows of buildings appear below forests
authorMarcus Str. <marcus@marstr.online>
Wed, 9 Oct 2024 19:12:37 +0000 (21:12 +0200)
committerMarcus Str. <marcus@marstr.online>
Wed, 9 Oct 2024 19:12:37 +0000 (21:12 +0200)
defines.py
layergen.py
photogen.py

index 033d61bb7c74d4d4fd1361d757d6aaa652e1e200..baf0c4464d77ca44e7ce7111486d9fbe471775c2 100644 (file)
@@ -117,12 +117,12 @@ mstr_ortho_layers = [
     ("landuse", "residential", "landuse", "residential-boundary"),\r
     ("landuse", "grass", "landuse", "grass"),\r
     ("landuse", "cemetery", "landuse", "grass"),\r
+    ("landuse", "recreation_ground", "landuse", "meadow"),\r
+    ("leisure", "golf_course", "leisure", "golf_course"),\r
     ("landuse", "greenfield", "landuse", "grass"),\r
     ("landuse", "orchard", "landuse", "meadow"),\r
     ("landuse", "meadow", "landuse", "meadow"),\r
     ("natural", "grassland", "landuse", "meadow"),\r
-    ("landuse", "recreation_ground", "landuse", "meadow"),\r
-    ("leisure", "golf_course", "leisure", "golf_course"),\r
     ("barrier", "hedge", "natural", "heath"),\r
     ("landuse", "vineyard", "landuse", "meadow"),\r
     ("natural", "bare_rock", "natural", "bare_rock"),\r
@@ -419,4 +419,4 @@ mstr_completion_colors = [
         (137,137,107)\r
         ]\r
     )\r
-]
\ No newline at end of file
+]\r
index a2ae1525e6082491f4ca35f5715e9e048cedd7b6..a74b2347f201d920bdf2149cb284c5b2f9c279b6 100644 (file)
@@ -610,7 +610,7 @@ class mstr_layergen:
                                     if lp[3] >= 250:\r
                                         shadow_pix[x,y] = (0,0,0,0)\r
 \r
-                            shadow = shadow.filter(ImageFilter.GaussianBlur(radius=2))\r
+                            shadow = shadow.filter(ImageFilter.GaussianBlur(radius=1.5))\r
 \r
                             """\r
                             for y in range(self._imgsize-1):\r
index d5a581fc198c55628f3f56c41ed63ce695b207a9..38cc7c7fb387286585efa8216b125c84cbba2d85 100644 (file)
@@ -45,6 +45,9 @@ class mstr_photogen:
         # First, we walk through all layers and blend them on top of each other, in order\r
         mstr_msg("photogen", "Merging layers")\r
 \r
+        # Note if we added building shadows\r
+        bldg_shadow_added = False\r
+\r
         # Shadow merging\r
         bldg_shadow = Image.new("RGBA", (self._imgsize, self._imgsize))\r
         if mstr_shadow_enabled == True:\r
@@ -80,7 +83,7 @@ class mstr_photogen:
         # Merge the building layers\r
         bldg_final = Image.new("RGBA", (self._imgsize, self._imgsize))\r
         bldg_final.alpha_composite(bldg_details)\r
-        bldg_final.alpha_composite(bldg_shadow)\r
+        #bldg_final.alpha_composite(bldg_shadow)\r
         bldg_final.alpha_composite(tree_main)\r
         bldg_final.alpha_composite(bldg_main)\r
 \r
@@ -88,6 +91,18 @@ class mstr_photogen:
             if os.path.isfile(root_filename + l[0] + "-" + l[1] + "_layer.png"):\r
                 # Need to divert in case we have shadows\r
                 if mstr_shadow_enabled == True:\r
+\r
+                    # Make sure building shadows appear below forests\r
+                    shdc = False\r
+                    for s in mstr_shadow_casters:\r
+                        if s[0] == l[0] and s[1] == l[1]:\r
+                            shdc = True\r
+                            break\r
+                    if shdc == True:\r
+                        if bldg_shadow_added == False:\r
+                            self._tile.alpha_composite(bldg_shadow)\r
+                            bldg_shadow_added = True\r
+\r
                     if os.path.isfile(root_filename + l[0] + "-" + l[1] + "_layer_shadow.png"):\r
                         if l[0] != "building":\r
                             sn = root_filename + l[0] + "-" + l[1] + "_layer_shadow.png"\r
@@ -265,4 +280,4 @@ class mstr_photogen:
         if abs(numbers[1]) >= 10 and numbers[0] <= 99: fstr = fstr + "0" + str(numbers[1])\r
         if abs(numbers[1]) >= 100 : fstr = fstr + str(numbers[1])\r
 \r
-        return fstr
\ No newline at end of file
+        return fstr\r