Rename to virtual monitor.
This commit is contained in:
parent
3da5748787
commit
e37d254170
|
@ -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
|
||||
|
||||
/** \} */
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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", "" )
|
||||
|
|
|
@ -113,7 +113,7 @@ set(SRC
|
|||
nodes/node_shader_vector_rotate.cc
|
||||
nodes/node_shader_vector_transform.cc
|
||||
nodes/node_shader_vertex_color.cc
|
||||
nodes/node_shader_virtual_camera.cc
|
||||
nodes/node_shader_virtual_monitor.cc
|
||||
nodes/node_shader_volume_absorption.cc
|
||||
nodes/node_shader_volume_info.cc
|
||||
nodes/node_shader_volume_principled.cc
|
||||
|
|
|
@ -7,20 +7,20 @@
|
|||
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
namespace blender::nodes::node_shader_virtual_camera_cc {
|
||||
namespace blender::nodes::node_shader_virtual_monitor_cc {
|
||||
|
||||
static void sh_node_virtual_camera_declare(NodeDeclarationBuilder &b)
|
||||
static void sh_node_virtual_monitor_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_input<decl::Vector>(N_("Vector")).implicit_field(implicit_field_inputs::position);
|
||||
b.add_output<decl::Color>(N_("Color")).no_muted_links();
|
||||
b.add_output<decl::Float>(N_("Alpha")).no_muted_links();
|
||||
}
|
||||
|
||||
static int node_shader_gpu_virtual_camera(GPUMaterial *mat,
|
||||
bNode *node,
|
||||
bNodeExecData * /*execdata*/,
|
||||
GPUNodeStack *in,
|
||||
GPUNodeStack *out)
|
||||
static int node_shader_gpu_virtual_monitor(GPUMaterial *mat,
|
||||
bNode *node,
|
||||
bNodeExecData * /*execdata*/,
|
||||
GPUNodeStack *in,
|
||||
GPUNodeStack *out)
|
||||
{
|
||||
Object *object = (Object *)node->id;
|
||||
if (object == nullptr || object->type != OB_CAMERA) {
|
||||
|
@ -36,17 +36,17 @@ static int node_shader_gpu_virtual_camera(GPUMaterial *mat,
|
|||
mat, node, "node_virtual_camera", in, out, GPU_image_camera(mat, cam, GPU_SAMPLER_DEFAULT));
|
||||
}
|
||||
|
||||
} // namespace blender::nodes::node_shader_virtual_camera_cc
|
||||
} // namespace blender::nodes::node_shader_virtual_monitor_cc
|
||||
|
||||
void register_node_type_sh_virtual_camera()
|
||||
{
|
||||
namespace file_ns = blender::nodes::node_shader_virtual_camera_cc;
|
||||
namespace file_ns = blender::nodes::node_shader_virtual_monitor_cc;
|
||||
|
||||
static bNodeType ntype;
|
||||
|
||||
sh_node_type_base(&ntype, SH_NODE_VIRTUAL_CAMERA, "Virtual Camera", NODE_CLASS_TEXTURE);
|
||||
ntype.declare = file_ns::sh_node_virtual_camera_declare;
|
||||
node_type_gpu(&ntype, file_ns::node_shader_gpu_virtual_camera);
|
||||
sh_node_type_base(&ntype, SH_NODE_VIRTUAL_MONITOR, "Virtual Monitor", NODE_CLASS_INPUT);
|
||||
ntype.declare = file_ns::sh_node_virtual_monitor_declare;
|
||||
node_type_gpu(&ntype, file_ns::node_shader_gpu_virtual_monitor);
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
Loading…
Reference in New Issue