diff --git a/project/addons/terrain_3d/editor/components/tool_settings.gd b/project/addons/terrain_3d/editor/components/tool_settings.gd index 93bc635c..e7ef1416 100644 --- a/project/addons/terrain_3d/editor/components/tool_settings.gd +++ b/project/addons/terrain_3d/editor/components/tool_settings.gd @@ -271,7 +271,6 @@ func add_setting(p_type: SettingType, p_name: StringName, value: Variant, parent func get_setting(p_setting: String) -> Variant: var object: Object = settings[p_setting] var value: Variant - if object is Range: value = object.get_value() elif object is DoubleSlider: @@ -283,8 +282,7 @@ func get_setting(p_setting: String) -> Variant: elif object is CheckBox: value = object.is_pressed() elif object is ColorPickerButton: - value = object.color.srgb_to_linear() - + value = object.color return value diff --git a/project/addons/terrain_3d/editor/components/ui.gd b/project/addons/terrain_3d/editor/components/ui.gd index 0081fa9d..92355764 100644 --- a/project/addons/terrain_3d/editor/components/ui.gd +++ b/project/addons/terrain_3d/editor/components/ui.gd @@ -213,7 +213,7 @@ func update_decal() -> void: _: decal.modulate = Color.WHITE Terrain3DEditor.COLOR: - decal.modulate = brush_data["color"] + decal.modulate = brush_data["color"].srgb_to_linear()*.5 Terrain3DEditor.ROUGHNESS: decal.modulate = COLOR_ROUGHNESS _: @@ -224,7 +224,6 @@ func update_decal() -> void: decal_timer.start() - func set_decal_rotation(rot: float) -> void: decal.rotation.y = rot diff --git a/project/addons/terrain_3d/tools/importer.gd b/project/addons/terrain_3d/tools/importer.gd index bbf8fa35..961b7b72 100644 --- a/project/addons/terrain_3d/tools/importer.gd +++ b/project/addons/terrain_3d/tools/importer.gd @@ -67,6 +67,7 @@ func start_import(value: bool) -> void: material.show_checkered = false material.show_colormap = true storage.import_images(imported_images, import_position, import_offset, import_scale) + print("Import finished") @export_group("Export File") diff --git a/src/shaders/main.glsl b/src/shaders/main.glsl index 4c89757e..19303543 100644 --- a/src/shaders/main.glsl +++ b/src/shaders/main.glsl @@ -11,7 +11,7 @@ uniform int _region_map[256]; uniform vec2 _region_offsets[256]; uniform sampler2DArray _height_maps : filter_linear_mipmap, repeat_disable; uniform sampler2DArray _control_maps : filter_linear_mipmap, repeat_disable; -uniform sampler2DArray _color_maps : filter_linear_mipmap, repeat_disable; +uniform sampler2DArray _color_maps : source_color, filter_linear, repeat_disable; uniform sampler2DArray _texture_array_albedo : source_color, filter_linear_mipmap_anisotropic, repeat_enable; uniform sampler2DArray _texture_array_normal : hint_normal, filter_linear_mipmap_anisotropic, repeat_enable; diff --git a/src/terrain_3d_material.cpp b/src/terrain_3d_material.cpp index 0f302e6e..4220f346 100644 --- a/src/terrain_3d_material.cpp +++ b/src/terrain_3d_material.cpp @@ -180,6 +180,7 @@ void Terrain3DMaterial::_update_regions(const Array &p_args) { } RS->material_set_param(_material, "_region_map", _region_map); RS->material_set_param(_material, "_region_map_size", Terrain3DStorage::REGION_MAP_SIZE); + RS->material_set_param(_material, "_region_uv_limit", Terrain3DStorage::REGION_MAP_SIZE / 2); if (Terrain3D::_debug_level >= DEBUG) { LOG(DEBUG, "Region map"); for (int i = 0; i < _region_map.size(); i++) { diff --git a/src/terrain_3d_storage.cpp b/src/terrain_3d_storage.cpp index b4326599..19c0cb15 100644 --- a/src/terrain_3d_storage.cpp +++ b/src/terrain_3d_storage.cpp @@ -377,7 +377,25 @@ void Terrain3DStorage::set_control_maps(const TypedArray &p_maps) { void Terrain3DStorage::set_color_maps(const TypedArray &p_maps) { LOG(INFO, "Setting color maps: ", p_maps.size()); - _color_maps = sanitize_maps(TYPE_COLOR, p_maps); + + TypedArray maps = p_maps; + // DEPRECATED 0.8.4 Remove 0.9 + // Convert colormap from linear <0.8.4 to srgb 0.8.41 + if (_version < CURRENT_VERSION && maps.size() > 0) { + LOG(WARN, "Color maps are being converted from linear to srgb. Upgrading: ", vformat("%.2f", _version), "->", vformat("%.2f", CURRENT_VERSION)); + for (int i = 0; i < maps.size(); i++) { + Ref img = maps[i]; + for (int x = 0; x < img->get_width(); x++) { + for (int y = 0; y < img->get_height(); y++) { + Color c = img->get_pixel(x, y); + img->set_pixel(x, y, c.linear_to_srgb()); + } + } + maps[i] = img; + } + _version = CURRENT_VERSION; // Prevent running again on focus + } + _color_maps = sanitize_maps(TYPE_COLOR, maps); force_update_maps(TYPE_COLOR); } diff --git a/src/terrain_3d_storage.h b/src/terrain_3d_storage.h index 8215cfde..f600dcc0 100644 --- a/src/terrain_3d_storage.h +++ b/src/terrain_3d_storage.h @@ -20,7 +20,7 @@ class Terrain3DStorage : public Resource { // Constants & Definitions - static inline const real_t CURRENT_VERSION = 0.84; + static inline const real_t CURRENT_VERSION = 0.841; static inline const int REGION_MAP_SIZE = 16; static inline const Vector2i REGION_MAP_VSIZE = Vector2i(REGION_MAP_SIZE, REGION_MAP_SIZE);