Re-enabled normal map generator, but only for water bodies. Likely commit for stable release.
This commit is contained in:
parent
88905ac509
commit
ec0dbe8cf1
@ -71,7 +71,7 @@ mstr_xp_genscenery = True
|
|||||||
|
|
||||||
# Generate normal maps for X-Plane scenery?
|
# Generate normal maps for X-Plane scenery?
|
||||||
# Strong recommendation: yes
|
# Strong recommendation: yes
|
||||||
mstr_xp_scn_normalmaps = False
|
mstr_xp_scn_normalmaps = True
|
||||||
|
|
||||||
# Paths to required X-Plane scenery tools
|
# Paths to required X-Plane scenery tools
|
||||||
#mstr_xp_meshtool = "/home/marcus/Developer/Projects/orthographic/bin/MeshTool"
|
#mstr_xp_meshtool = "/home/marcus/Developer/Projects/orthographic/bin/MeshTool"
|
||||||
|
11
photogen.py
11
photogen.py
@ -215,7 +215,6 @@ class mstr_photogen:
|
|||||||
# Now we convert this into a DDS
|
# Now we convert this into a DDS
|
||||||
_tmpfn = mstr_datafolder + "z_orthographic/orthos/" + self._latlngfld + "/" + str(self._ty) + "_" + str(self._tx)
|
_tmpfn = mstr_datafolder + "z_orthographic/orthos/" + self._latlngfld + "/" + str(self._ty) + "_" + str(self._tx)
|
||||||
os.system(mstr_xp_ddstool + " --png2dxt1 " + _tmpfn + ".png " + _tmpfn + ".dds" )
|
os.system(mstr_xp_ddstool + " --png2dxt1 " + _tmpfn + ".png " + _tmpfn + ".dds" )
|
||||||
|
|
||||||
os.remove(mstr_datafolder + "z_orthographic/orthos/" + self._latlngfld + "/" + str(self._ty) + "_" + str(self._tx) + ".png")
|
os.remove(mstr_datafolder + "z_orthographic/orthos/" + self._latlngfld + "/" + str(self._ty) + "_" + str(self._tx) + ".png")
|
||||||
|
|
||||||
# Now generate the normal map for this ortho.
|
# Now generate the normal map for this ortho.
|
||||||
@ -223,21 +222,21 @@ class mstr_photogen:
|
|||||||
if mstr_xp_genscenery and mstr_xp_scn_normalmaps:
|
if mstr_xp_genscenery and mstr_xp_scn_normalmaps:
|
||||||
# Generate the normal normal map first (hah)
|
# Generate the normal normal map first (hah)
|
||||||
nrm = mstr_xp_normalmap()
|
nrm = mstr_xp_normalmap()
|
||||||
nrmimg = nrm.generate_normal_map_for_layer(self._tile, False)
|
#nrmimg = nrm.generate_normal_map_for_layer(self._tile, False)
|
||||||
|
|
||||||
# Now we need to walk through the water layers and generate a combined normal map
|
# Now we need to walk through the water layers and generate a combined normal map
|
||||||
wtrlyr = Image.new("RGBA", (self._imgsize, self._imgsize))
|
wtrlyr = Image.new("RGBA", (self._imgsize, self._imgsize))
|
||||||
for w in waterlayers:
|
for w in waterlayers:
|
||||||
wtrlyr.alpha_composite(w)
|
wtrlyr.alpha_composite(w)
|
||||||
wtrlyr = wtrlyr.resize((int(mstr_photores/4), int(mstr_photores/4)), Image.Resampling.BILINEAR)
|
wtrlyr = wtrlyr.resize((int(mstr_photores/2), int(mstr_photores/2)), Image.Resampling.BILINEAR)
|
||||||
wtrimg = nrm.generate_normal_map_for_layer(wtrlyr, True)
|
wtrimg = nrm.generate_normal_map_for_layer(wtrlyr, True)
|
||||||
|
|
||||||
# Blend
|
# Blend
|
||||||
nrmimg.alpha_composite(wtrimg)
|
#nrmimg.alpha_composite(wtrimg)
|
||||||
|
|
||||||
# Save
|
# 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)
|
||||||
nrmimg.save(nrmfln)
|
wtrimg.save(nrmfln + ".png")
|
||||||
|
|
||||||
|
|
||||||
# Generates some random tree.
|
# Generates some random tree.
|
||||||
|
@ -72,7 +72,7 @@ class mstr_xp_normalmap:
|
|||||||
# Blue (reflectivity) and alpha (specularity) need to be 1 - but can be adjusted as needed
|
# Blue (reflectivity) and alpha (specularity) need to be 1 - but can be adjusted as needed
|
||||||
|
|
||||||
# Resize original
|
# Resize original
|
||||||
image = image.resize((int(mstr_photores/4), int(mstr_photores/4)), Image.Resampling.BILINEAR)
|
#image = image.resize((int(mstr_photores/4), int(mstr_photores/4)), Image.Resampling.BILINEAR)
|
||||||
|
|
||||||
nmp = Image.new("RGBA", (image.width, image.height), (128,128,0,0))
|
nmp = Image.new("RGBA", (image.width, image.height), (128,128,0,0))
|
||||||
|
|
||||||
@ -112,7 +112,8 @@ class mstr_xp_normalmap:
|
|||||||
# Sobel filter
|
# Sobel filter
|
||||||
dx = (it_tr + 2.0 * it_r + it_br) - (it_tl + 2.0 * it_l + it_bl)
|
dx = (it_tr + 2.0 * it_r + it_br) - (it_tl + 2.0 * it_l + it_bl)
|
||||||
dy = (it_bl + 2.0 * it_b + it_br) - (it_tl + 2.0 * it_t + it_tr)
|
dy = (it_bl + 2.0 * it_b + it_br) - (it_tl + 2.0 * it_t + it_tr)
|
||||||
dz = 10 # This is usually a good value for strength
|
dz = 3
|
||||||
|
#dz = 10 # This is usually a good value for strength
|
||||||
v = (dx, dy, dz)
|
v = (dx, dy, dz)
|
||||||
nrm = self.normalize_vector(v)
|
nrm = self.normalize_vector(v)
|
||||||
|
|
||||||
|
@ -186,8 +186,8 @@ class mstr_xp_scenery:
|
|||||||
terstr = terstr + "\r\n"
|
terstr = terstr + "\r\n"
|
||||||
terstr = terstr + "LOAD_CENTER " + str(cnt_x) + " " + str(cnt_y) + " " + str(dmt) + " 2048\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"
|
terstr = terstr + "BASE_TEX_NOWRAP ../../orthos/" + self._latlngfld + "/" + str(lat)+"_"+str(lng)+".dds\r\n"
|
||||||
#if mstr_xp_scn_normalmaps:
|
if mstr_xp_scn_normalmaps:
|
||||||
# terstr = terstr + "NORMAL_TEX 1.0 ../../normals/" + self._latlngfld + "/" + str(lat)+"_"+str(lng)+".png\r\n"
|
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"
|
terfln = mstr_datafolder + "z_orthographic/terrain/" + self._latlngfld + "/" + str(lat)+"_"+str(lng)+".ter"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user