Add Active Camera geometry node #106065
Open
dbsc
wants to merge 15 commits from
When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
dbsc/blender:active_camera_geo_node
into main
pull from: dbsc/blender:active_camera_geo_node
merge into: blender:main
blender:main
blender:blender-v4.0-release
blender:temp-sculpt-dyntopo
blender:blender-v3.6-release
blender:universal-scene-description
blender:blender-v3.3-release
blender:asset-browser-frontend-split
blender:brush-assets-project
blender:asset-shelf
blender:anim/armature-drawing-refactor-3
blender:temp-sculpt-dyntopo-hive-alloc
blender:tmp-usd-python-mtl
blender:tmp-usd-3.6
blender:blender-v3.5-release
blender:blender-projects-basics
blender:blender-v2.93-release
blender:temp-sculpt-attr-api
blender:realtime-clock
blender:sculpt-dev
blender:gpencil-next
blender:bevelv2
blender:microfacet_hair
blender:xr-dev
blender:principled-v2
When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Reviewers
Request review
No reviewers
Labels
Clear labels
This issue affects/is about backward or forward compatibility
Issues relating to security: https://wiki.blender.org/wiki/Process/Vulnerability_Reports
Apply labels
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
This issue affects/is about backward or forward compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest: Wayland
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Issues relating to security: https://wiki.blender.org/wiki/Process/Vulnerability_Reports
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest: Wayland
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
Milestone
Set milestone
Clear milestone
No items
No Milestone
Projects
Set Project
Clear projects
No project
Assignees
Assign users
Clear assignees
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#106065
Reference in New Issue
There is no content yet.
Delete Branch "dbsc/blender:active_camera_geo_node"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
This adresses #105761
The implemented 'Active Camera' node outputs an object that can be plugged into 'Object Info' node to extract transformation information on the active scene's camera.
Currently there is a problem with the camera changes using markers since they don't share a common 'set camera' function with
VIEW3D_OT_object_as_camera
. Is there a way to just listen to global changes on the scene's camera somehow, or do we need tamper around the individual functions that set the camera? Feels like I'm missing something here. I would be happy to hear suggestions on this 😁.Yes, there is some difficulty here.
In theory, it seems that we need to add a new update tag, which would be called when the active camera is changed in the scene properties. You can detect this, most likely, in the place in the code where it happens.
40bef4a134
to199979cab2
WIP: Add Active Camera geometry nodeto Add Active Camera geometry node@ -286,6 +286,8 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_node_tree_output_relation(ctx->node, nmd->node_group, "Nodes Modifier");
add_object_relation(ctx, *ctx->scene->camera);
Do we really want to be addicted forever? It is better to have an analogue of
node_needs_own_transform_relation
Indeed, this should do something like
needs_own_transform_relation
to only add the dependency when the new node is used.Also, this crashes when there is no active object.
I made changes that hopefully solve both issues.
@dbsc as proposed in original request task, i believe this node interface could be greatly improved and could provide other very useful information to the user. Poke me if interested.
To be clear, we'd like to add a separate node after this one that retrieves information from a camera object. But we want to separate retrieving the active camera object from retrieving camera data from any object.
@ -278,6 +278,7 @@ class NODE_MT_geometry_node_GEO_INPUT_SCENE(Menu):
node_add_menu.add_node_type(layout, "GeometryNodeObjectInfo")
node_add_menu.add_node_type(layout, "GeometryNodeSelfObject")
node_add_menu.add_node_type(layout, "GeometryNodeInputSceneTime")
node_add_menu.add_node_type(layout, "GeometryNodeActiveCamera")
This needs alphabetical sorting within this category
Unless I'm mistaken the other nodes are not in alphabetical order. Should they be ordered as well?
@ -1750,6 +1750,8 @@ void ED_update_for_newframe(Main *bmain, Depsgraph *depsgraph)
BKE_screen_view3d_scene_sync(screen, scene);
}
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
DEG_id_tag_update(&scene->camera->id, ID_RECALC_TRANSFORM);
ID_RECALC_TRANSFORM
doesn't really sound right here, since the camera didn't move. DoesID_RECALC_COPY_ON_WRITE
work instead?Actually... I'd imagine this second tag of
camera->id
isn't necessary, since the geometry nodes modifier will also add a relation to the scene in this case, and the relations update should handle finding a new camera.From what I understand, DEG_id_tag_update forces an update on the values on the depsgraph or something like that, and DEG_tag_relations_update modifies the depsgraph. Since the marker changes the camera, a modification on the depsgraph is needed. However, I empirically found that without the DEG_id_tag_update, the active camera node is not updated, and don't understand why this is (even if it is put before the relations tag update).
@ -281,6 +281,7 @@ DefNode(FunctionNode, FN_NODE_STRING_LENGTH, 0, "STRING_LENGTH", StringLength, "
DefNode(FunctionNode, FN_NODE_VALUE_TO_STRING, 0, "VALUE_TO_STRING", ValueToString, "Value to String", "")
DefNode(GeometryNode, GEO_NODE_ACCUMULATE_FIELD, def_geo_accumulate_field, "ACCUMULATE_FIELD", AccumulateField, "Accumulate Field", "Add the values of an evaluated field together and output the running total for each element")
DefNode(GeometryNode, GEO_NODE_ACTIVE_CAMERA, 0, "ACTIVE_CAMERA", ActiveCamera, "Active Camera", "Retrieve the active camera")
I'd suggest being more specific:
Retrieve the scene's active camera
Add Active Camera geometry nodeto WIP: Add Active Camera geometry nodeHi @dbsc any updates on this patch?
199979cab2
toc69c573aa2
d102c3d483
to34ec2bf529
WIP: Add Active Camera geometry nodeto Add Active Camera geometry node@ -0,0 +12,4 @@
static void node_geo_exec(GeoNodeExecParams params)
{
Scene *scene = DEG_get_evaluated_scene(params.depsgraph());
If you expect this scene to be evaluate (a copy must be created and initialized) before the geometry nodes work, then the modifier must also create a dependency on the scene and its copy-write component.
It's better to take the original scene (also, do this const). From it to get the original camera. And return it evaluated version (~
gel_eval_for_id
...). We are already dependent on camera update anyway, its cow copy should be already evaluated.b71168a649
tob8ef2e73ec
There's currently a crash that happens when using markers and the proposed node. The crash happens on
simulation_state.cc
, because of this assert:BLI_assert(frame > states_at_frames_.last()->frame);
. I don't know exactly how to fix it. The attached project shows a minimal setup where the crash happens (you must move the frame counter back and forth).Reviewers