]> marstr Code Repo - marstr/orthographic.git/commitdiff
Re-enabled normal map generator, but only for water bodies. Likely commit for stable...
authorMarcus Str. <marcus@marstr.online>
Sat, 1 Feb 2025 16:28:35 +0000 (17:28 +0100)
committerMarcus Str. <marcus@marstr.online>
Sat, 1 Feb 2025 16:28:35 +0000 (17:28 +0100)
defines.py
photogen.py
xp_normalmap.py
xp_scenery.py

index 6494065857a1a033834741264606df140bc3edd4..9ed3a8e001bdb8199fe647b897a28e54c1387f36 100644 (file)
@@ -71,7 +71,7 @@ mstr_xp_genscenery = True
 \r
 # Generate normal maps for X-Plane scenery?\r
 # Strong recommendation: yes\r
-mstr_xp_scn_normalmaps = False\r
+mstr_xp_scn_normalmaps = True\r
 \r
 # Paths to required X-Plane scenery tools\r
 #mstr_xp_meshtool = "/home/marcus/Developer/Projects/orthographic/bin/MeshTool"\r
index 6fb969840bf03601151bec555ba700cc9faaa318..7535edb6fa72970e61dfc15bc88785cf64b48ee1 100644 (file)
@@ -215,7 +215,6 @@ class mstr_photogen:
         # Now we convert this into a DDS\r
         _tmpfn = mstr_datafolder + "z_orthographic/orthos/" + self._latlngfld + "/" + str(self._ty) + "_" + str(self._tx)\r
         os.system(mstr_xp_ddstool + " --png2dxt1 " + _tmpfn + ".png " + _tmpfn + ".dds" )\r
-        \r
         os.remove(mstr_datafolder + "z_orthographic/orthos/" + self._latlngfld + "/" + str(self._ty) + "_" + str(self._tx) + ".png")\r
 \r
         # Now generate the normal map for this ortho.\r
@@ -223,21 +222,21 @@ class mstr_photogen:
         if mstr_xp_genscenery and mstr_xp_scn_normalmaps:\r
             # Generate the normal normal map first (hah)\r
             nrm = mstr_xp_normalmap()\r
-            nrmimg = nrm.generate_normal_map_for_layer(self._tile, False)\r
+            #nrmimg = nrm.generate_normal_map_for_layer(self._tile, False)\r
 \r
             # Now we need to walk through the water layers and generate a combined normal map\r
             wtrlyr = Image.new("RGBA", (self._imgsize, self._imgsize))\r
             for w in waterlayers:\r
                 wtrlyr.alpha_composite(w)\r
-            wtrlyr = wtrlyr.resize((int(mstr_photores/4), int(mstr_photores/4)), Image.Resampling.BILINEAR)\r
+            wtrlyr = wtrlyr.resize((int(mstr_photores/2), int(mstr_photores/2)), Image.Resampling.BILINEAR)\r
             wtrimg = nrm.generate_normal_map_for_layer(wtrlyr, True)\r
 \r
             # Blend\r
-            nrmimg.alpha_composite(wtrimg)\r
+            #nrmimg.alpha_composite(wtrimg)\r
 \r
             # Save\r
-            nrmfln = mstr_datafolder + "z_orthographic/normals/" + self._latlngfld + "/" + str(self._ty) + "_" + str(self._tx) + ".png"\r
-            nrmimg.save(nrmfln)\r
+            nrmfln = mstr_datafolder + "z_orthographic/normals/" + self._latlngfld + "/" + str(self._ty) + "_" + str(self._tx) \r
+            wtrimg.save(nrmfln + ".png")\r
 \r
 \r
     # Generates some random tree.\r
index 9f39266209b9183c164dbed3cbcef7925df91bda..d40134d7271baac60ea64b2d414acbd78d91b375 100644 (file)
@@ -72,7 +72,7 @@ class mstr_xp_normalmap:
         # Blue (reflectivity) and alpha (specularity) need to be 1 - but can be adjusted as needed\r
 \r
         # Resize original\r
-        image = image.resize((int(mstr_photores/4), int(mstr_photores/4)), Image.Resampling.BILINEAR)\r
+        #image = image.resize((int(mstr_photores/4), int(mstr_photores/4)), Image.Resampling.BILINEAR)\r
 \r
         nmp = Image.new("RGBA", (image.width, image.height), (128,128,0,0))\r
 \r
@@ -112,7 +112,8 @@ class mstr_xp_normalmap:
                         # Sobel filter\r
                         dx = (it_tr + 2.0 * it_r + it_br) - (it_tl + 2.0 * it_l + it_bl)\r
                         dy = (it_bl + 2.0 * it_b + it_br) - (it_tl + 2.0 * it_t + it_tr)\r
-                        dz = 10 # This is usually a good value for strength\r
+                        dz = 3\r
+                        #dz = 10 # This is usually a good value for strength\r
                         v = (dx, dy, dz)\r
                         nrm = self.normalize_vector(v)\r
 \r
index 5660e5fb6a243d886be31d40efbc3b1fbe81ee88..6bcb150398f107d2110235096bcc94245889d0ed 100644 (file)
@@ -186,8 +186,8 @@ class mstr_xp_scenery:
                 terstr = terstr + "\r\n"
                 terstr = terstr + "LOAD_CENTER " + str(cnt_x) + " " + str(cnt_y) + " " + str(dmt) + " 2048\r\n"
                 terstr = terstr + "BASE_TEX_NOWRAP ../../orthos/" + self._latlngfld + "/" + str(lat)+"_"+str(lng)+".dds\r\n"
-                #if mstr_xp_scn_normalmaps:
-                #    terstr = terstr + "NORMAL_TEX 1.0 ../../normals/" + self._latlngfld + "/" + str(lat)+"_"+str(lng)+".png\r\n"
+                if mstr_xp_scn_normalmaps:
+                    terstr = terstr + "NORMAL_TEX 1.0 ../../normals/" + self._latlngfld + "/" + str(lat)+"_"+str(lng)+".dds\r\n"
 
                 terfln = mstr_datafolder + "z_orthographic/terrain/" + self._latlngfld + "/" + str(lat)+"_"+str(lng)+".ter"