Conversation
| else: | ||
| var splat_images : Array[Image] | ||
| for file : String in splat_map_paths: | ||
| var splat : Image = Terrain3DUtil.load_raw_image(file, r16_size.x, r16_size.y) |
There was a problem hiding this comment.
var texture : Texture2D = ResourceLoader.load(file)
var splat : Image = texture.get_image()
if splat.is_compressed():
splat.decompress()
splat_images.append(splat)
This works for me for splat maps exported as png from WorldMaschine, and should work with all image formats supported by godot.
Maybe it would make sense to implement your raw format using an EditorImportPlugin?
There was a problem hiding this comment.
I'm glad that it works for you! What do you mean by implementing my raw format with an editorimportplugin?:)
There was a problem hiding this comment.
I loaded the image using the default ResourceLoader instead of the load_raw_image method, as WorldMachine does not do raw image export as far as I can tell. This way I can import as PNG.
If you implement a EditorImportPlugin for your raw format you should be able import it using the ResourceLoader as well, so the same splat map importer can be used for both.
There was a problem hiding this comment.
Thank you for the advice. I have now fixed so that the ResourceLoader is used instead so you should be able to use it for your stuff, as well as the clear settings that you mentioned. I also fixed a bug in the noise value in compute_control_ids_and_blend that you might want to fix as well if you're using the code:)
Also, I'm just curious, are your splats RGB or RGBA? Mine are RGBA and I noticed that I had to change the import setting Fix alpha border for the splats to work correctly.
I only changed the importer using the ResourceLoader instead of load_raw_image as seen in #907 (comment) |
b9719f7 to
7f1d5e0
Compare
| weights[w_i + 2] = 0.f; | ||
| weights[w_i + 3] = 0.f; | ||
| } else { | ||
| Color color = splat->get_pixel(x, y); |
There was a problem hiding this comment.
ERROR: Can't get_pixel() on compressed image, sorry. at: _get_color_at_ofs (core/io/image.cpp:3257) GDScript backtrace (most recent call first): [0] start_import (res://addons/terrain_3d/tools/importer.gd:120)
I get this error because the image is not decompressed.
There was a problem hiding this comment.
I tried using VRAM compressed splats and changing the code in importer.gd to this. Does it work for you?
for file : String in splat_map_paths:
var splat : Texture2D = ResourceLoader.load(file, "Texture2D", ResourceLoader.CACHE_MODE_IGNORE)
var splat_img : Image = splat.get_image()
if splat_img.is_compressed():
splat_img.decompress()
splat_images.append(splat_img)
| color_file_name = "" | ||
| import_splat_maps = false | ||
| splat_map_paths.clear() | ||
| material_ids.clear() |
| else: | ||
| var splat_images : Array[Image] | ||
| for file : String in splat_map_paths: | ||
| var splat : CompressedTexture2D = ResourceLoader.load(file, "CompressedTexture2D", ResourceLoader.CACHE_MODE_IGNORE) |
There was a problem hiding this comment.
Is it necessary to use CompressedTexture2D here? I think Godot will import all image textures as CompressedTexture3D but this will fail for other texture types such as NoiseTexture2D.
SCRIPT ERROR: Trying to assign value of type 'NoiseTexture2D' to a variable of type 'CompressedTexture2D'. at: start_import (res://addons/terrain_3d/tools/importer.gd:117) GDScript backtrace (most recent call first): [0] start_import (res://addons/terrain_3d/tools/importer.gd:117)
I think procedural textures could be useful.
And only the base Texture2D get_image method is needed.
65bd024 to
8fdafa3
Compare
…splat import settings. Now works if texture is compressed.
8fdafa3 to
7fc06b3
Compare
|
This would be incredibly helpful for my Gaea -> Terrain3D workflow! Great work! PNG8 and PNG16 splat support would be nice. That's what I primarily use, although I can use raw too. With this PR, the terrain software -> godot workflow is pretty much fully supported. Since really, all Terrain3D needs is a heightmap and splat maps for texturing. |
Op used RGBA8 which is PNG8.
PNG16 is not an option until Godot supports it, or someone writes a format loader, or an external library is bundled. |


I have created this first draft to import splat maps in the Terrain3D importer.
I have tested this for my use case, where I used 3 splat images (raw RGBA8) with the same size as the terrain/heightmap/colormap. Each splat image uses the 4 color channels to map to a detail texture like described here:
You also have to specify a list that maps the index of each color channel to the corresponding texture asset list ids. If you have for example 3 splat images the list needs to be 12 for all color channels (so splat_count * 4), even if you don't use all of them (mark -1 for unused).
The splat maps should be able to be imported as PNGs as well, but I started with raw because it's what my team uses. I can't share the splats we use unfortunately.
I'm of course open to try to make this more usable for others if you have any advice, I don't have much knowledge about the usual formats of other terrain generators.