Commit: 45bc00d298a71c77b73728c7e88995f05d070726 Author: Miguel Pozo Date: Fri Jan 27 16:20:39 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB45bc00d298a71c77b73728c7e88995f05d070726
Use the same object id across object submeshes =================================================================== M source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh M source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl M source/blender/draw/engines/workbench/workbench_defines.hh M source/blender/draw/engines/workbench/workbench_engine.cc M source/blender/draw/engines/workbench/workbench_mesh_passes.cc M source/blender/draw/engines/workbench/workbench_private.hh =================================================================== diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh index 92452eefed2..f0a89859c44 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh @@ -40,6 +40,7 @@ GPU_SHADER_CREATE_INFO(workbench_next_mesh) .vertex_in(2, Type::VEC4, "ac") .vertex_in(3, Type::VEC2, "au") .vertex_source("workbench_prepass_vert.glsl") + .storage_buf(WB_OBJECT_ID_SLOT, Qualifier::READ, "uint", "object_id_data[]") .additional_info("draw_modelmat_new") .additional_info("draw_resource_handle_new"); diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl index 7fcfb9b1c54..2f82cd2379d 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl @@ -19,5 +19,9 @@ void main() workbench_material_data_get( resource_handle, ac.rgb, color_interp, alpha_interp, _roughness, metallic); +#ifdef WORKBENCH_NEXT + object_id = int(uint(object_id_data[resource_handle]) & 0xFFFFu) + 1; +#else object_id = int(uint(resource_handle) & 0xFFFFu) + 1; +#endif } diff --git a/source/blender/draw/engines/workbench/workbench_defines.hh b/source/blender/draw/engines/workbench/workbench_defines.hh index 4dfd69d9d50..c69225b197a 100644 --- a/source/blender/draw/engines/workbench/workbench_defines.hh +++ b/source/blender/draw/engines/workbench/workbench_defines.hh @@ -5,6 +5,7 @@ #define WB_TILE_ARRAY_SLOT 2 #define WB_TILE_DATA_SLOT 3 #define WB_MATERIAL_SLOT 0 +#define WB_OBJECT_ID_SLOT 1 #define WB_WORLD_SLOT 4 #define WB_RESOLVE_GROUP_SIZE 8 diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index a04f61418f6..78ac2b2349f 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -80,6 +80,7 @@ class Instance { void end_sync() { resources.material_buf.push_update(); + resources.object_id_buf.push_update(); } void object_sync(Manager &manager, ObjectRef &ob_ref) @@ -202,6 +203,8 @@ class Instance { ResourceHandle _handle = i == 0 ? handle : manager.resource_handle(ob_ref); Material &mat = resources.material_buf.get_or_resize(_handle.resource_index()); + resources.object_id_buf.get_or_resize( + _handle.resource_index()) = handle.resource_index(); if (::Material *_mat = BKE_object_material_get_eval(ob_ref.object, i + 1)) { mat = Material(*_mat); @@ -242,6 +245,7 @@ class Instance { if (batch) { Material &mat = resources.material_buf.get_or_resize(handle.resource_index()); + resources.object_id_buf.get_or_resize(handle.resource_index()) = handle.resource_index(); if (object_state.color_type == V3D_SHADING_OBJECT_COLOR) { mat = Material(*ob_ref.object); diff --git a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc index bc90f26b33d..d926b0c015d 100644 --- a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc +++ b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc @@ -23,6 +23,7 @@ void MeshPass::init_pass(SceneResources &resources, DRWState state, int clip_pla state_set(state, clip_planes); bind_texture(WB_MATCAP_SLOT, resources.matcap_tx); bind_ssbo(WB_MATERIAL_SLOT, &resources.material_buf); + bind_ssbo(WB_OBJECT_ID_SLOT, &resources.object_id_buf); bind_ubo(WB_WORLD_SLOT, resources.world_buf); if (clip_planes > 0) { bind_ubo(DRW_CLIPPING_UBO_SLOT, resources.clip_planes_buf); diff --git a/source/blender/draw/engines/workbench/workbench_private.hh b/source/blender/draw/engines/workbench/workbench_private.hh index 086553ca5c1..b00202e3a69 100644 --- a/source/blender/draw/engines/workbench/workbench_private.hh +++ b/source/blender/draw/engines/workbench/workbench_private.hh @@ -148,6 +148,7 @@ struct SceneResources { TextureFromPool depth_in_front_tx = "wb_depth_in_front_tx"; StorageVectorBuffer<Material> material_buf = {"material_buf"}; + StorageVectorBuffer<uint> object_id_buf = {"object_id_buf"}; UniformBuffer<WorldData> world_buf = {}; UniformArrayBuffer<float4, 6> clip_planes_buf; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs