Commit: e37d254170c3ab2c54d4082926d9c685cafdfc45 Author: Jeroen Bakker Date: Fri Nov 11 14:53:21 2022 +0100 Branches: temp-xr-virtual-camera-experiment https://developer.blender.org/rBe37d254170c3ab2c54d4082926d9c685cafdfc45
Rename to virtual monitor. =================================================================== M source/blender/blenkernel/BKE_node.h M source/blender/blenkernel/intern/camera.c M source/blender/editors/space_node/drawnode.cc M source/blender/editors/space_view3d/view3d_draw.cc M source/blender/gpu/intern/gpu_node_graph.c M source/blender/makesdna/DNA_camera_types.h M source/blender/makesrna/intern/rna_nodetree.c M source/blender/nodes/NOD_static_types.h M source/blender/nodes/shader/CMakeLists.txt R055 source/blender/nodes/shader/nodes/node_shader_virtual_camera.cc source/blender/nodes/shader/nodes/node_shader_virtual_monitor.cc =================================================================== diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index cf78c954e44..b332f90ee83 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -1222,7 +1222,7 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, i #define SH_NODE_COMBINE_COLOR 711 #define SH_NODE_SEPARATE_COLOR 712 #define SH_NODE_MIX 713 -#define SH_NODE_VIRTUAL_CAMERA 714 +#define SH_NODE_VIRTUAL_MONITOR 714 /** \} */ diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 93be310b3b3..e3a72c5d69e 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -41,6 +41,8 @@ #include "DEG_depsgraph_query.h" +#include "GPU_viewport.h" + #include "MEM_guardedalloc.h" #include "BLO_read_write.h" @@ -83,10 +85,21 @@ static void camera_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, } /** Free (or release) any data used by this camera (does not free the camera itself). */ +static void camera_free_runtime_data(Camera *camera) +{ + if (camera->runtime.virtual_monitor_offscreen) { + GPU_offscreen_free(camera->runtime.virtual_monitor_offscreen); + camera->runtime.virtual_monitor_offscreen = NULL; + } + /* GPU texture is owned by the GPUOffscreen instance. */ + camera->runtime.offscreen_color_texture = NULL; +} + static void camera_free_data(ID *id) { Camera *cam = (Camera *)id; BLI_freelistN(&cam->bg_images); + camera_free_runtime_data(cam); } static void camera_foreach_id(ID *id, LibraryForeachIDData *data) @@ -137,8 +150,8 @@ static void camera_blend_read_data(BlendDataReader *reader, ID *id) bgpic->flag &= ~CAM_BGIMG_FLAG_OVERRIDE_LIBRARY_LOCAL; } } - ca->runtime.virtual_display_texture = NULL; - ca->runtime.gpu_texture = NULL; + ca->runtime.virtual_monitor_offscreen = NULL; + ca->runtime.offscreen_color_texture = NULL; } static void camera_blend_read_lib(BlendLibReader *reader, ID *id) diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index b713b225638..196726a2a14 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -432,7 +432,7 @@ static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, Poin node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr, false, true); } -static void node_shader_buts_virtual_camera(uiLayout *layout, bContext *C, PointerRNA *ptr) +static void node_shader_buts_virtual_monitor(uiLayout *layout, bContext *C, PointerRNA *ptr) { uiTemplateID(layout, C, @@ -513,8 +513,8 @@ static void node_shader_set_butfunc(bNodeType *ntype) ntype->draw_buttons = node_shader_buts_tex_environment; ntype->draw_buttons_ex = node_shader_buts_tex_environment_ex; break; - case SH_NODE_VIRTUAL_CAMERA: - ntype->draw_buttons = node_shader_buts_virtual_camera; + case SH_NODE_VIRTUAL_MONITOR: + ntype->draw_buttons = node_shader_buts_virtual_monitor; break; case SH_NODE_DISPLACEMENT: case SH_NODE_VECTOR_DISPLACEMENT: diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index 468de37a9a2..c06d0981cb0 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -1552,16 +1552,16 @@ static void view3d_virtual_camera_update(const bContext *C, ARegion *region, Obj int2 resolution(1920 / 2, 1080 / 2); RegionView3D *old_rv3d = static_cast<RegionView3D *>(region->regiondata); - RegionView3D rv3d = {*old_rv3d}; - region->regiondata = &rv3d; + RegionView3D rv3d; + memcpy(&rv3d, old_rv3d, sizeof(RegionView3D)); Object *old_camera = v3d->camera; v3d->camera = object; rv3d.persp = RV3D_CAMOB; Camera *camera = static_cast<Camera *>(object->data); - if (camera->runtime.virtual_display_texture == nullptr) { - camera->runtime.virtual_display_texture = GPU_offscreen_create( + if (camera->runtime.virtual_monitor_offscreen == nullptr) { + camera->runtime.virtual_monitor_offscreen = GPU_offscreen_create( UNPACK2(resolution), true, GPU_RGBA16F, nullptr); } @@ -1578,7 +1578,7 @@ static void view3d_virtual_camera_update(const bContext *C, ARegion *region, Obj BKE_camera_params_compute_matrix(¶ms); copy_m4_m4(winmat.ptr(), params.winmat); - GPUOffScreen *offscreen = camera->runtime.virtual_display_texture; + GPUOffScreen *offscreen = camera->runtime.virtual_monitor_offscreen; GPU_offscreen_bind(offscreen, true); ED_view3d_draw_offscreen(depsgraph, @@ -1597,8 +1597,8 @@ static void view3d_virtual_camera_update(const bContext *C, ARegion *region, Obj offscreen, nullptr); GPU_offscreen_unbind(offscreen, true); - camera->runtime.gpu_texture = GPU_offscreen_color_texture( - camera->runtime.virtual_display_texture); + camera->runtime.offscreen_color_texture = GPU_offscreen_color_texture( + camera->runtime.virtual_monitor_offscreen); v3d->camera = old_camera; region->regiondata = old_rv3d; @@ -1617,7 +1617,7 @@ static void view3d_draw_virtual_camera(const bContext *C, ARegion *region) } LISTBASE_FOREACH (bNode *, node, &material->nodetree->nodes) { - if (node->type != SH_NODE_VIRTUAL_CAMERA) { + if (node->type != SH_NODE_VIRTUAL_MONITOR) { continue; } Object *ob = static_cast<Object *>(static_cast<void *>(node->id)); diff --git a/source/blender/gpu/intern/gpu_node_graph.c b/source/blender/gpu/intern/gpu_node_graph.c index 153906675b0..837cb114ac3 100644 --- a/source/blender/gpu/intern/gpu_node_graph.c +++ b/source/blender/gpu/intern/gpu_node_graph.c @@ -639,8 +639,14 @@ GPUNodeLink *GPU_image_camera(GPUMaterial *mat, Camera *camera, eGPUSamplerState GPUNodeGraph *graph = gpu_material_node_graph(mat); GPUNodeLink *link = gpu_node_link_create(); link->link_type = GPU_NODE_LINK_IMAGE_CAMERA; - link->texture = gpu_node_graph_add_texture( - graph, NULL, NULL, NULL, NULL, &camera->runtime.gpu_texture, link->link_type, sampler_state); + link->texture = gpu_node_graph_add_texture(graph, + NULL, + NULL, + NULL, + NULL, + &camera->runtime.offscreen_color_texture, + link->link_type, + sampler_state); GPU_material_flag_set(mat, GPU_MATFLAG_VIRTUAL_CAMERA); return link; } diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h index 86a9e344b59..707f28e6c09 100644 --- a/source/blender/makesdna/DNA_camera_types.h +++ b/source/blender/makesdna/DNA_camera_types.h @@ -72,9 +72,9 @@ typedef struct Camera_Runtime { float drw_focusmat[4][4]; float drw_normalmat[4][4]; - struct GPUOffScreen *virtual_display_texture; + struct GPUOffScreen *virtual_monitor_offscreen; /* Local reference to not owning gpu texture. Used to have a reliable pointer to the texture. */ - struct GPUTexture *gpu_texture; + struct GPUTexture *offscreen_color_texture; } Camera_Runtime; typedef struct Camera { diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 1c903ce1dcd..21fb156cc29 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -5885,7 +5885,7 @@ static void def_sh_tex_coord(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } -static void def_sh_virtual_camera(StructRNA *srna) +static void def_sh_virtual_monitor(StructRNA *srna) { PropertyRNA *prop; @@ -5897,7 +5897,8 @@ static void def_sh_virtual_camera(StructRNA *srna) RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Camera", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - // TODO: add poll function show all cameras in active scene, excluding scene camera. + /* TODO: add poll function show all cameras in active scene and view layer, excluding scene + * camera. */ } static void def_sh_vect_transform(StructRNA *srna) diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h index 1a3311c6fe6..a9054d9d291 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -123,7 +123,7 @@ DefNode(ShaderNode, SH_NODE_CURVE_FLOAT, def_float_curve, "CUR DefNode(ShaderNode, SH_NODE_COMBINE_COLOR, def_sh_combsep_color, "COMBINE_COLOR", CombineColor, "Combine Color", "Create a color from individual components using multiple models") DefNode(ShaderNode, SH_NODE_SEPARATE_COLOR, def_sh_combsep_color, "SEPARATE_COLOR", SeparateColor, "Separate Color", "Split a color into its individual components using multiple models") DefNode(ShaderNode, SH_NODE_MIX, def_sh_mix, "MIX", Mix, "Mix", "Mix values by a factor") -DefNode(ShaderNode, SH_NODE_VIRTUAL_CAMERA, def_sh_virtual_camera, "VIRTUAL_CAMERA", VirtualCamera, "Virtual Camera", "Virtual Camera") +DefNode(ShaderNode, SH_NODE_VIRTUAL_MONITOR, def_sh_virtual_monitor, "VIRTUAL_MONITOR", VirtualMonitor, "Virtual Monitor", "Use the feed from a virtual camera (has to be in the same scene and view layer)") DefNode(CompositorNode, CMP_NODE_VIEWER, def_cmp_viewer, "VIEWER", Viewer, "Viewer", "" ) DefNode(CompositorNode, CMP_NODE_RGB, 0, "RGB", RGB, "RGB", "" ) diff --git a/source/blender/nodes/shader/CMakeLists.txt b/source/blender/nodes/shader/CMakeLists.txt index 9a42 @@ Diff output truncated at 10240 characters. @@ _______________________________________________ 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