@@ -152,33 +152,42 @@ func save_image_as_png(img, inputPath):
152
152
153
153
func load_cache_filename (path ):
154
154
var fileName = path .get_file ().get_basename ().to_lower ()
155
- var cachePath = Settings .unearthdata .plus_file (fileName + ".png" )
155
+
156
+ if (not fileName .to_lower ().find ("tmapa" )):
157
+ return
158
+
159
+ var cachePathtmapa = Settings .unearthdata .plus_file (fileName + ".png" )
160
+ var cachePathtmapb = Settings .unearthdata .plus_file (fileName .replace ("tmapa" ,"tmapb" ) + ".png" )
156
161
var tmapaNumber = int (fileName .to_lower ().trim_prefix ("tmapa" )) # Get the specific position to create within the array
157
-
158
- if File .new ().file_exists (cachePath ) == true :
162
+
163
+ if File .new ().file_exists (cachePathtmapa ) == true :
159
164
# Need to call load() on an Image class if I want the save and load to work correctly (otherwise it saves too fast and doesn't load or something)
160
- var img = Image .new ()
161
- img .load (cachePath )
162
- load_image_into_cache (img , tmapaNumber )
165
+ var imgA = Image .new ()
166
+ imgA .load (cachePathtmapa )
167
+ var imgB = Image .new ()
168
+ imgB .load (cachePathtmapb )
169
+ load_image_into_cache (imgA ,imgB , tmapaNumber )
163
170
# print('Loaded cache file: ' + cachePath)
164
171
return OK
165
172
else :
166
- print ('Cache file not found: ' + cachePath )
173
+ print ('Cache file not found: ' + cachePathtmapa )
167
174
cachedTextures .clear ()
168
175
return FAILED
169
176
170
- func load_image_into_cache (img , tmapaNumber ):
177
+ func load_image_into_cache (imgA , imgB , tmapaNumber ):
171
178
tmapaNumber = int (tmapaNumber )
172
179
while cachedTextures .size () <= tmapaNumber : # Fill all array positions, in case a tmapa00#.dat file inbetween is deleted
173
180
cachedTextures .append ([null , null ])
174
- cachedTextures [tmapaNumber ] = convert_img_to_two_texture_arrays (img )
181
+ cachedTextures [tmapaNumber ] = convert_img_to_two_texture_arrays (imgA , imgB )
175
182
176
183
# SLICE COUNT being too high is the reason TextureArray doesn't work on old PC. (NOT IMAGE SIZE, NOT MIPMAPS EITHER)
177
184
# RES files might actually take longer to generate a TextureArray from than PNG, not sure.
178
- func convert_img_to_two_texture_arrays (img ):
179
- if img .get_format () != IMAGE_FORMAT :
180
- img .convert (IMAGE_FORMAT )
181
-
185
+ func convert_img_to_two_texture_arrays (imgA ,imgB ):
186
+ if imgA .get_format () != IMAGE_FORMAT :
187
+ imgA .convert (IMAGE_FORMAT )
188
+ if imgB .get_format () != IMAGE_FORMAT :
189
+ imgB .convert (IMAGE_FORMAT )
190
+
182
191
var twoTextureArrays = [
183
192
TextureArray .new (),
184
193
TextureArray .new (),
@@ -201,7 +210,11 @@ func convert_img_to_two_texture_arrays(img):
201
210
202
211
for y in ySlices :
203
212
for x in xSlices :
204
- var slice = img .get_rect (Rect2 (x * sliceWidth , (y + yOffset )* sliceHeight , sliceWidth , sliceHeight ))
213
+ var slice
214
+ if i > 2 :
215
+ slice = imgA .get_rect (Rect2 (x * sliceWidth , (y + yOffset )* sliceHeight , sliceWidth , sliceHeight ))
216
+ else :
217
+ slice = imgB .get_rect (Rect2 (x * sliceWidth , (y + yOffset )* sliceHeight , sliceWidth , sliceHeight ))
205
218
slice .generate_mipmaps () # Important otherwise it's black when zoomed out
206
219
twoTextureArrays [i ].set_layer_data (slice , (y * xSlices )+ x )
207
220
0 commit comments