| … | … | @@ -11,7 +11,7 @@ Usage: |
| 11 | 11 | |
| 12 | 12 | import bpy |
| 13 | 13 | |
| 14 | ADDON_VERSION = "0.13.0" | |
| 14 | ADDON_VERSION = "0.13.1" | |
| 15 | 15 | |
| 16 | 16 | # Support hot-reload (F3 > Reload Scripts) |
| 17 | 17 | if "shm_protocol" in locals(): |
| … | … | @@ -2,7 +2,7 @@ schema_version = "1.0.0" |
| 2 | 2 | id = "blender_godot_bridge" |
| 3 | 3 | name = "Blender-Godot Bridge" |
| 4 | 4 | tagline = "Real-time bidirectional scene sync with Godot" |
| 5 | version = "0.13.0" | |
| 5 | version = "0.13.1" | |
| 6 | 6 | blender_version_min = "4.2.0" |
| 7 | 7 | type = "add-on" |
| 8 | 8 | maintainer = "blender-bridge <noreply@localhost>" |
| … | … | @@ -163,7 +163,7 @@ Error BlenderBridge::start_server(const String &socket_path) { |
| 163 | 163 | _known_instance_ids.clear(); |
| 164 | 164 | _next_object_id = 1; |
| 165 | 165 | |
| 166 | UtilityFunctions::print("BlenderBridge v0.13.0: Server started (shm=", _shm_name, ", sock=", socket_path, ", regions=2x", (int)_region_size, ")"); | |
| 166 | UtilityFunctions::print("BlenderBridge v0.13.1: Server started (shm=", _shm_name, ", sock=", socket_path, ", regions=2x", (int)_region_size, ")"); | |
| 167 | 167 | return OK; |
| 168 | 168 | } |
| 169 | 169 |
| … | … | @@ -3,6 +3,7 @@ |
| 3 | 3 | #include <godot_cpp/classes/image.hpp> |
| 4 | 4 | #include <godot_cpp/classes/rd_texture_format.hpp> |
| 5 | 5 | #include <godot_cpp/classes/rd_texture_view.hpp> |
| 6 | #include <godot_cpp/classes/resource_loader.hpp> | |
| 6 | 7 | #include <godot_cpp/variant/utility_functions.hpp> |
| 7 | 8 | |
| 8 | 9 | using namespace godot; |
| … | … | @@ -30,6 +31,9 @@ void VirtualTexture::_bind_methods() { |
| 30 | 31 | ClassDB::bind_method(D_METHOD("get_atlas_texture"), &VirtualTexture::get_atlas_texture); |
| 31 | 32 | ClassDB::bind_method(D_METHOD("get_page_table_texture"), &VirtualTexture::get_page_table_texture); |
| 32 | 33 | |
| 34 | // Material factory | |
| 35 | ClassDB::bind_method(D_METHOD("create_vt_material", "fallback_albedo", "roughness", "metallic"), &VirtualTexture::create_vt_material); | |
| 36 | ||
| 33 | 37 | // Feedback |
| 34 | 38 | ClassDB::bind_method(D_METHOD("submit_feedback", "feedback_data"), &VirtualTexture::submit_feedback); |
| 35 | 39 | |
| … | … | @@ -140,6 +144,32 @@ Ref<Texture2DRD> VirtualTexture::get_page_table_texture() const { |
| 140 | 144 | return _page_table_tex; |
| 141 | 145 | } |
| 142 | 146 | |
| 147 | // ── Material factory ────────────────────────────────────────────────────── | |
| 148 | ||
| 149 | Ref<ShaderMaterial> VirtualTexture::create_vt_material(const Color &fallback, float rough, float metal) { | |
| 150 | // Lazy-load the shader | |
| 151 | if (!_shader_loaded) { | |
| 152 | _vt_shader = ResourceLoader::get_singleton()->load("res://addons/blender_bridge/vt_lookup.gdshader"); | |
| 153 | _shader_loaded = true; | |
| 154 | } | |
| 155 | if (_vt_shader.is_null()) { | |
| 156 | UtilityFunctions::push_warning("VirtualTexture: vt_lookup.gdshader not found at res://addons/blender_bridge/"); | |
| 157 | return Ref<ShaderMaterial>(); | |
| 158 | } | |
| 159 | ||
| 160 | Ref<ShaderMaterial> mat; | |
| 161 | mat.instantiate(); | |
| 162 | mat->set_shader(_vt_shader); | |
| 163 | mat->set_shader_parameter("vt_atlas", _atlas_tex); | |
| 164 | mat->set_shader_parameter("vt_page_table", _page_table_tex); | |
| 165 | mat->set_shader_parameter("tile_size_uv", 1.0f / _cache_grid_size); | |
| 166 | mat->set_shader_parameter("page_table_size", (float)_page_table.tiles_at_mip(0)); | |
| 167 | mat->set_shader_parameter("albedo_color", fallback); | |
| 168 | mat->set_shader_parameter("roughness", rough); | |
| 169 | mat->set_shader_parameter("metallic", metal); | |
| 170 | return mat; | |
| 171 | } | |
| 172 | ||
| 143 | 173 | // ── Tile upload ─────────────────────────────────────────────────────────────── |
| 144 | 174 | |
| 145 | 175 | Error VirtualTexture::upload_tile(int texture_id, int tile_x, int tile_y, int mip, const PackedByteArray &rgba_data) { |
| … | … | @@ -3,8 +3,11 @@ |
| 3 | 3 | #include <godot_cpp/classes/node.hpp> |
| 4 | 4 | #include <godot_cpp/classes/rendering_device.hpp> |
| 5 | 5 | #include <godot_cpp/classes/rendering_server.hpp> |
| 6 | #include <godot_cpp/classes/shader.hpp> | |
| 7 | #include <godot_cpp/classes/shader_material.hpp> | |
| 6 | 8 | #include <godot_cpp/classes/texture2drd.hpp> |
| 7 | 9 | #include <godot_cpp/core/class_db.hpp> |
| 10 | #include <godot_cpp/variant/color.hpp> | |
| 8 | 11 | #include <godot_cpp/variant/dictionary.hpp> |
| 9 | 12 | #include <godot_cpp/variant/packed_byte_array.hpp> |
| 10 | 13 | #include <godot_cpp/variant/rid.hpp> |
| … | … | @@ -42,6 +45,9 @@ public: |
| 42 | 45 | Ref<Texture2DRD> get_atlas_texture() const; |
| 43 | 46 | Ref<Texture2DRD> get_page_table_texture() const; |
| 44 | 47 | |
| 48 | // ── Material factory ──────────────────────────────────────────────── | |
| 49 | Ref<ShaderMaterial> create_vt_material(const Color &fallback_albedo, float roughness, float metallic); | |
| 50 | ||
| 45 | 51 | // ── Configuration ─────────────────────────────────────────────────── |
| 46 | 52 | void set_tile_size(int size); |
| 47 | 53 | int get_tile_size() const; |
| … | … | @@ -102,6 +108,10 @@ private: |
| 102 | 108 | Ref<Texture2DRD> _page_table_tex; |
| 103 | 109 | bool _gpu_initialized = false; |
| 104 | 110 | |
| 111 | // ── Shader (lazy-loaded) ──────────────────────────────────────────── | |
| 112 | Ref<Shader> _vt_shader; | |
| 113 | bool _shader_loaded = false; | |
| 114 | ||
| 105 | 115 | // ── Frame tracking ────────────────────────────────────────────────── |
| 106 | 116 | uint64_t _frame_count = 0; |
| 107 | 117 | int _tiles_uploaded_this_frame = 0; |