update addons
This commit is contained in:
parent
ed3ec686b8
commit
70f00bdee2
4 changed files with 53 additions and 114 deletions
|
@ -478,79 +478,6 @@ It can also be done using [packed texture importers](packed-texture-importers),
|
||||||
Because Godot would strip out the alpha channel if a packed texture was imported as a normal map, you should not make your texture import as "Normal Map" in the importer dock.
|
Because Godot would strip out the alpha channel if a packed texture was imported as a normal map, you should not make your texture import as "Normal Map" in the importer dock.
|
||||||
|
|
||||||
|
|
||||||
### Packed texture importers
|
|
||||||
|
|
||||||
In order to support the [import tool](#using-the-import-tool), this plugin defines two special texture importers, which allow to pack multiple input textures into one. They otherwise behave the same as Godot's default importers.
|
|
||||||
|
|
||||||
The type of file they import are JSON files, which refer to the source image files you wish to pack together, along with a few other options.
|
|
||||||
|
|
||||||
#### Packed textures
|
|
||||||
|
|
||||||
File extension: `.packed_tex`
|
|
||||||
|
|
||||||
Example for an albedo+bump texture:
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"contains_albedo": true,
|
|
||||||
"src": {
|
|
||||||
"rgb": "res://textures/src/grass_albedo.png",
|
|
||||||
"a": "res://textures/src/grass_bump.png",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Example for a normal+roughness texture, with conversion from DirectX to OpenGL (optional):
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"src": {
|
|
||||||
"rgb": "res://textures/src/rocks_normal.png",
|
|
||||||
"a": "res://textures/src/rocks_roughness.png",
|
|
||||||
"normalmap_flip_y": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also specify a plain color instead of a path, if you don't need a texture. It will act as if the source texture was filled with this color. The expected format is ARGB.
|
|
||||||
|
|
||||||
```
|
|
||||||
"rgb": "#ff888800"
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Packed texture arrays
|
|
||||||
|
|
||||||
File extension: `.packed_texarr`
|
|
||||||
|
|
||||||
This one requires you to specify a `resolution`, because each layer of the texture array must have the same size and be square. The resolution is a single integer number.
|
|
||||||
What you can put in each layer is the same as for [packed textures](#packed-textures).
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"contains_albedo": true,
|
|
||||||
"resolution": 1024,
|
|
||||||
"layers": [
|
|
||||||
{
|
|
||||||
"rgb": "res://textures/src/grass_albedo.png",
|
|
||||||
"a": "res://textures/src/grass_bump.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"rgb": "res://textures/src/rocks_albedo.png",
|
|
||||||
"a": "res://textures/src/rocks_bump.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"rgb": "res://textures/src/sand_albedo.png",
|
|
||||||
"a": "res://textures/src/sand_bump.png"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Limitations
|
|
||||||
|
|
||||||
Such importers support most of the features needed for terrain textures, however some features found in Godot's importers are not implemented. This is because Godot does not have any API to extend the existing importers, so they had to be re-implemented from scratch in GDScript. For example, lossy compression to save disk space is not supported, because it requires access to WebP compression API which is not exposed.
|
|
||||||
|
|
||||||
See [Godot proposal](https://github.com/godotengine/godot-proposals/issues/1943)
|
|
||||||
|
|
||||||
|
|
||||||
### Depth blending
|
### Depth blending
|
||||||
|
|
||||||
`Bump` textures holds a particular usage in this plugin:
|
`Bump` textures holds a particular usage in this plugin:
|
||||||
|
|
|
@ -433,7 +433,7 @@ func _on_ClearNormal_pressed():
|
||||||
|
|
||||||
|
|
||||||
func _on_ModeSelector_item_selected(index: int):
|
func _on_ModeSelector_item_selected(index: int):
|
||||||
var id = _mode_selector.get_selected_id()
|
var id := _mode_selector.get_selected_id()
|
||||||
if id == _texture_set.get_mode():
|
if id == _texture_set.get_mode():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -446,13 +446,13 @@ func _on_ModeSelector_item_selected(index: int):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if _texture_set.get_mode() == HTerrainTextureSet.MODE_TEXTURES:
|
if _texture_set.get_mode() == HTerrainTextureSet.MODE_TEXTURES:
|
||||||
_mode_confirmation_dialog.window_title = "Switch to TextureArrays"
|
_mode_confirmation_dialog.title = "Switch to TextureArrays"
|
||||||
_mode_confirmation_dialog.dialog_text = \
|
_mode_confirmation_dialog.dialog_text = \
|
||||||
"This will unload all textures currently setup. Do you want to continue?"
|
"This will unload all textures currently setup. Do you want to continue?"
|
||||||
_mode_confirmation_dialog.popup_centered()
|
_mode_confirmation_dialog.popup_centered()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
_mode_confirmation_dialog.window_title = "Switch to Textures"
|
_mode_confirmation_dialog.title = "Switch to Textures"
|
||||||
_mode_confirmation_dialog.dialog_text = \
|
_mode_confirmation_dialog.dialog_text = \
|
||||||
"This will unload all textures currently setup. Do you want to continue?"
|
"This will unload all textures currently setup. Do you want to continue?"
|
||||||
_mode_confirmation_dialog.popup_centered()
|
_mode_confirmation_dialog.popup_centered()
|
||||||
|
|
|
@ -212,20 +212,26 @@ func set_texture_set(texture_set: HTerrainTextureSet):
|
||||||
if texture == null or texture.resource_path == "":
|
if texture == null or texture.resource_path == "":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not texture.resource_path.ends_with(".packed_tex"):
|
# In Godot 3 we used a custom format to store and composite source images
|
||||||
continue
|
# with a custom importer. It was removed during the port to Godot 4 because it
|
||||||
|
# was too hard to maintain a custom texture importer (too much logic to replicate
|
||||||
|
# from Godot's builtin importer, which wasn't exposed).
|
||||||
|
# For now the import tool won't remember source images between editor sessions.
|
||||||
|
|
||||||
var import_data := _parse_json_file(texture.resource_path)
|
# if not texture.resource_path.ends_with(".packed_tex"):
|
||||||
if import_data.is_empty() or not import_data.has("src"):
|
# continue
|
||||||
continue
|
#
|
||||||
|
# var import_data := _parse_json_file(texture.resource_path)
|
||||||
var src_types = HTerrainTextureSet.get_src_types_from_type(type)
|
# if import_data.is_empty() or not import_data.has("src"):
|
||||||
|
# continue
|
||||||
var src_data = import_data["src"]
|
#
|
||||||
if src_data.has("rgb"):
|
# var src_types = HTerrainTextureSet.get_src_types_from_type(type)
|
||||||
slot.texture_paths[src_types[0]] = src_data["rgb"]
|
#
|
||||||
if src_data.has("a"):
|
# var src_data = import_data["src"]
|
||||||
slot.texture_paths[src_types[1]] = src_data["a"]
|
# if src_data.has("rgb"):
|
||||||
|
# slot.texture_paths[src_types[0]] = src_data["rgb"]
|
||||||
|
# if src_data.has("a"):
|
||||||
|
# slot.texture_paths[src_types[1]] = src_data["a"]
|
||||||
|
|
||||||
_slots_data.append(slot)
|
_slots_data.append(slot)
|
||||||
|
|
||||||
|
@ -238,30 +244,36 @@ func set_texture_set(texture_set: HTerrainTextureSet):
|
||||||
if texture_array == null or texture_array.resource_path == "":
|
if texture_array == null or texture_array.resource_path == "":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not texture_array.resource_path.ends_with(".packed_texarr"):
|
# In Godot 3 we used a custom format to store and composite source images
|
||||||
continue
|
# with a custom importer. It was removed during the port to Godot 4 because it
|
||||||
|
# was too hard to maintain a custom texture importer (too much logic to replicate
|
||||||
|
# from Godot's builtin importer, which wasn't exposed).
|
||||||
|
# For now the import tool won't remember source images between editor sessions.
|
||||||
|
|
||||||
var import_data := _parse_json_file(texture_array.resource_path)
|
# if not texture_array.resource_path.ends_with(".packed_texarr"):
|
||||||
if import_data.is_empty() or not import_data.has("layers"):
|
# continue
|
||||||
continue
|
#
|
||||||
|
# var import_data := _parse_json_file(texture_array.resource_path)
|
||||||
var layers_data = import_data["layers"]
|
# if import_data.is_empty() or not import_data.has("layers"):
|
||||||
|
# continue
|
||||||
for slot_index in len(layers_data):
|
#
|
||||||
var src_data = layers_data[slot_index]
|
# var layers_data = import_data["layers"]
|
||||||
|
#
|
||||||
var src_types = HTerrainTextureSet.get_src_types_from_type(type)
|
# for slot_index in len(layers_data):
|
||||||
|
# var src_data = layers_data[slot_index]
|
||||||
while slot_index >= len(_slots_data):
|
#
|
||||||
var slot = HT_TextureSetImportEditorSlot.new()
|
# var src_types = HTerrainTextureSet.get_src_types_from_type(type)
|
||||||
_slots_data.append(slot)
|
#
|
||||||
|
# while slot_index >= len(_slots_data):
|
||||||
var slot : HT_TextureSetImportEditorSlot = _slots_data[slot_index]
|
# var slot = HT_TextureSetImportEditorSlot.new()
|
||||||
|
# _slots_data.append(slot)
|
||||||
if src_data.has("rgb"):
|
#
|
||||||
slot.texture_paths[src_types[0]] = src_data["rgb"]
|
# var slot : HT_TextureSetImportEditorSlot = _slots_data[slot_index]
|
||||||
if src_data.has("a"):
|
#
|
||||||
slot.texture_paths[src_types[1]] = src_data["a"]
|
# if src_data.has("rgb"):
|
||||||
|
# slot.texture_paths[src_types[0]] = src_data["rgb"]
|
||||||
|
# if src_data.has("a"):
|
||||||
|
# slot.texture_paths[src_types[1]] = src_data["a"]
|
||||||
|
|
||||||
# TODO If the set doesn't have a file, use terrain path by default?
|
# TODO If the set doesn't have a file, use terrain path by default?
|
||||||
if texture_set.resource_path != "":
|
if texture_set.resource_path != "":
|
||||||
|
|
|
@ -74,7 +74,7 @@ static func _add_texture_filters(file_dialog):
|
||||||
# Godot
|
# Godot
|
||||||
file_dialog.add_filter("*.ctex ; CompressedTexture files")
|
file_dialog.add_filter("*.ctex ; CompressedTexture files")
|
||||||
# Packed textures
|
# Packed textures
|
||||||
file_dialog.add_filter("*.packed_tex ; HTerrainPackedTexture files")
|
# file_dialog.add_filter("*.packed_tex ; HTerrainPackedTexture files")
|
||||||
|
|
||||||
|
|
||||||
static func _add_texture_array_filters(file_dialog):
|
static func _add_texture_array_filters(file_dialog):
|
||||||
|
@ -82,7 +82,7 @@ static func _add_texture_array_filters(file_dialog):
|
||||||
# Godot
|
# Godot
|
||||||
file_dialog.add_filter("*.ctexarray ; TextureArray files")
|
file_dialog.add_filter("*.ctexarray ; TextureArray files")
|
||||||
# Packed textures
|
# Packed textures
|
||||||
file_dialog.add_filter("*.packed_texarr ; HTerrainPackedTextureArray files")
|
# file_dialog.add_filter("*.packed_texarr ; HTerrainPackedTextureArray files")
|
||||||
|
|
||||||
|
|
||||||
# Tries to load a texture with the ResourceLoader, and if it fails, attempts
|
# Tries to load a texture with the ResourceLoader, and if it fails, attempts
|
||||||
|
|
Loading…
Reference in a new issue