Add Active Camera geometry node #105761

Open
opened 2023-03-14 13:04:53 +01:00 by Hans Goudey · 19 comments
Member

Since geometry nodes is always processed in the context of a scene (at least it is now), there is typically a single camera object that's currently used for rendering. It can be useful to extract information from it, and the first step is just being able to access its transform.

https://blender.community/c/rightclickselect/VQ2W/

Add a node that outputs the active camera object. Users can then use the object info node to retrieve data about the object's transform. The task includes investigating and adding dependencies between the two objects so that geometry nodes reevaluates when the active camera is moved. That is done in process_nodes_for_depsgraph.

Since geometry nodes is always processed in the context of a scene (at least it is now), there is typically a single camera object that's currently used for rendering. It can be useful to extract information from it, and the first step is just being able to access its transform. https://blender.community/c/rightclickselect/VQ2W/ Add a node that outputs the active camera object. Users can then use the object info node to retrieve data about the object's transform. The task includes investigating and adding dependencies between the two objects so that geometry nodes reevaluates when the active camera is moved. That is done in `process_nodes_for_depsgraph`.
Hans Goudey added this to the Nodes & Physics project 2023-03-14 13:04:55 +01:00

Still, how to handle cases when there are several cameras and they switch?

Still, how to handle cases when there are several cameras and they switch?
First-time contributor

I would like to pick up this issue! Just a heads up though, I have college exams from tomorrow till friday, ie, from 15th to 17th March.
Will it be okay if I can submit a PR by the 20th?

I would like to pick up this issue! Just a heads up though, I have college exams from tomorrow till friday, ie, from 15th to 17th March. Will it be okay if I can submit a PR by the 20th?

@Piyush-Aniruddha-Udhao Whenever you want, it's not urgent.

@Piyush-Aniruddha-Udhao Whenever you want, it's not urgent.
First-time contributor

That is done in process_nodes_for_depsgraph.

Doubt 1: Does it imply that we have to make changes in process_nodes_for_depsgraph, or use this function in our node implementation?

The task includes investigating and adding dependencies between the two objects so that geometry nodes reevaluates when the active camera is moved.

Doubt 2: What two objects, is it the camera and the node object?

> That is done in `process_nodes_for_depsgraph`. Doubt 1: Does it imply that we have to make changes in `process_nodes_for_depsgraph`, or use this function in our node implementation? > The task includes investigating and adding dependencies between the two objects so that geometry nodes reevaluates when the active camera is moved. Doubt 2: What two objects, is it the camera and the node object?

You need at least basic knowledge of the dependency graph, this task has become more difficult
But to simplify, take a look at node_needs_own_transform_relation and add analog for new node

You need at least basic knowledge of the dependency graph, this task has become more difficult But to simplify, take a look at `node_needs_own_transform_relation` and add analog for new node
First-time contributor

Okay, I will research dependency graph properly.

take a look at node_needs_own_transform_relation and add analog for new node

Understood! Thank you :>

Okay, I will research dependency graph properly. > take a look at node_needs_own_transform_relation and add analog for new node Understood! Thank you :>
First-time contributor

Hey @mod_moder, do you know any closed issue that had to create a new geometry node? I'm trying to find one, so that I can see how new nodes are built.

Hey @mod_moder, do you know any closed issue that had to create a new geometry node? I'm trying to find one, so that I can see how new nodes are built.

@Piyush-Aniruddha-Udhao An example of the simplest node: #104602

@Piyush-Aniruddha-Udhao An example of the simplest node: https://projects.blender.org/blender/blender/pulls/104602
First-time contributor

thanks a lot!

thanks a lot!
First-time contributor

@mod_moder could you please explain what NODE_STORAGE_FUNCS() does? I see that it is used before node_declare() by nodes whose structs were declared in DNA_node_types.h. Is it required to call it for the active camera node? Could you explain the difference between the nodes that use it and the nodes that don't?

@mod_moder could you please explain what `NODE_STORAGE_FUNCS()` does? I see that it is used before `node_declare()` by nodes whose structs were declared in `DNA_node_types.h`. Is it required to call it for the active camera node? Could you explain the difference between the nodes that use it and the nodes that don't?

Define the definition of the data structure to use for bnode.storage, you don't need this if you don't want to have any properties for the node. For me, it's better to use custom1 if that's enough

Define the definition of the data structure to use for bnode.storage, you don't need this if you don't want to have any properties for the node. For me, it's better to use custom1 if that's enough
Member

I'll keep an eye on this too.

I'll keep an eye on this too.
First-time contributor

Hi everyone
This design was implemented as a plugin node by StrikeDigital, it could become a "camera info" node with a few more useful informations. If interested by an implementation please poke me, looks like a good node to learn blender source code

img

https://devtalk.blender.org/t/extra-nodes-for-geometrynodes/20942

Hi everyone This design was implemented as a plugin node by StrikeDigital, it could become a "camera info" node with a few more useful informations. If interested by an implementation please poke me, looks like a good node to learn blender source code ![img](https://projects.blender.org/attachments/47fa2805-f31a-467a-9420-60bf37b53aec) https://devtalk.blender.org/t/extra-nodes-for-geometrynodes/20942
First-time contributor

Wasted opportunity to have a Scene Info node
active camera is part of blender scene description

Wasted opportunity to have a Scene Info node active camera is part of blender scene description
Iliya Katueshenock self-assigned this 2023-06-13 14:22:22 +02:00
Iliya Katueshenock removed their assignment 2023-06-13 18:17:34 +02:00
First-time contributor

Is it possible also have vector conversions from world coords to camera and back?
Same conversion that is possible in material shaders "Vector convert" node

Is it possible also have vector conversions from world coords to camera and back? Same conversion that is possible in material shaders "Vector convert" node
Member

@IPv6 It is possible, however to convert into a camera will require more than two vectors (pos, dir), it can look clumsy for the know and a "camera type" will not have much of any use alone in the context of Geometry Node. I'm thinking maybe a "Edit active camera" node is more useful, which then allows you to plug in those arguments to affect the view of the final render.

I'm not sure if we can allow changing of FOV since it's hooked to the output dimension, this might be provided as a read only value.

@IPv6 It is possible, however to convert into a camera will require more than two vectors (pos, dir), it can look clumsy for the know and a "camera type" will not have much of any use alone in the context of Geometry Node. I'm thinking maybe a "Edit active camera" node is more useful, which then allows you to plug in those arguments to affect the view of the final render. I'm not sure if we can allow changing of FOV since it's hooked to the output dimension, this might be provided as a read only value.
First-time contributor

@IPv6 It is possible, however to convert into a camera will require more than two vectors (pos, dir), it can look clumsy for the know and a "camera type" will not have much of any use alone in the context of Geometry Node. I'm thinking maybe a "Edit active camera" node is more useful, which then allows you to plug in those arguments to affect the view of the final render.

I see. Just for the context - for my usecases vector-based conversions are more useful than affecting camera itself. Currently there is no way to alter mesh geometry relative to "screen" - but there is a lot of effects that would benefit from it. To name a few

  • "interface-like" elements in animation that stay (or smoothly attaching themselves) to top/side of camera frame
  • simple "cloth depenetration" to automaticaly fight easy cases of selfintersections when it is sufficient to move part of geometry toward camera (with respect to fov/ortho/etc, without changing visual position)
  • screen-spaced effects that "just works" without manual calculations and positional setups in scene

Some of this can be made via material, some via constraints, but all this add additional complications. Making this via GN would ease some indie devs pains

> @IPv6 It is possible, however to convert into a camera will require more than two vectors (pos, dir), it can look clumsy for the know and a "camera type" will not have much of any use alone in the context of Geometry Node. I'm thinking maybe a "Edit active camera" node is more useful, which then allows you to plug in those arguments to affect the view of the final render. I see. Just for the context - for my usecases vector-based conversions are more useful than affecting camera itself. Currently there is no way to alter mesh geometry relative to "screen" - but there is a lot of effects that would benefit from it. To name a few - "interface-like" elements in animation that stay (or smoothly attaching themselves) to top/side of camera frame - simple "cloth depenetration" to automaticaly fight easy cases of selfintersections when it is sufficient to move part of geometry toward camera (with respect to fov/ortho/etc, without changing visual position) - screen-spaced effects that "just works" without manual calculations and positional setups in scene Some of this can be made via material, some via constraints, but all this add additional complications. Making this via GN would ease some indie devs pains

@ChengduLittleA @IPv6 Global-Local transformation isn't related with this task.

@ChengduLittleA @IPv6 Global-Local transformation isn't related with this task.
Member

Global-Local transformation isn't related with this task.

No it doesn't need to have that. Here we could consider the value being always global.

> Global-Local transformation isn't related with this task. No it doesn't need to have that. Here we could consider the value being always global.
Sign in to join this conversation.
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
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
Overlay
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
Interest
Workbench
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
No Milestone
No Assignees
7 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#105761
No description provided.