Page MenuHome

When used inside a node group in multiple scenes, the defocus node does not refresh active camera data.
Closed, ResolvedPublic

Description

Version: 2.69 official (win 64)

How to reproduce: Render First Scene. The orange cube is in focus, as it is being used as the active camera's focal point. The defocus node is inside a node group used by both scenes. Now, render the second scene. Notice that the orange cube is out of focus even though the active camera is also using it as a focal point.

Expected behavior: Since both scenes are identical except for the cameras, and both cameras use the same focus, the orange cube should be in focus for both scenes. Instead, it seems that the defocus node persists in using the camera distance data from the first scene in which it was originally added.

Event Timeline

Sam Brubaker (rocketman) updated the task description. (Show Details)
Sam Brubaker (rocketman) raised the priority of this task from to Needs Triage by Developer.
Sam Brubaker (rocketman) set Type to Bug.

I think this was added intentionally so that you could do compositing of multiple scenes in one compositing node setup, or use a separate scene for compositing and rendering.

The node remembers the scene, and perhaps that value should be exposed to the user. If empty it uses the current scene, if not you can get the current camera from another scene? I'm not sure what the default should be, perhaps it's least confusing if it's empty and uses the current scene.

@Brecht Van Lommel (brecht), I wondered about that right after I reported this. That "feature" would be useful for just such a thing, but it seems wrong to make it ambiguous to the user.

I agree with your suggestion on how it could be fixed. That way, defocus can be used in one node group across all scenes if I want (I do want).

This scene-dependency of compositor is quite horrible IMO. It's a quick solution for getting scene info into nodes, but design is weak and it breaks really easy with changing contexts.

Similar issue, where compositing without a scene also doesn't work because of this dependency of the Defocus node: T36745

Just for the record, here is a list of nodes which afaict currently store a scene reference in node->id:

TypeComment
Render Layerscan be selected explicitly by user
Compositescene is identified by name during composite
Defocusused only for active camera object
File Outputnot used except for initializing output file format

@Lukas Toenne (lukastoenne) , That's a very good observation.

If you want to rectify this scene dependency of the Defocus Node, there could be an additional Input node called "Active Camera Data" which would feed DoF and Focus depth values into the Defocus Node.

That way, the Defocus Node would not need to reference any external scene data by itself. In a perfect system, only input nodes should do that.

I think the standard solution would be to include camera data in the EXR metadata, and in Blender it would also be in the RenderResult then. I couldn't quickly find a standard for this metadata, but if you Google for "exr camera metadata" you'll find a bunch of information about people doing similar things.

I agree, @Brecht Van Lommel (brecht) , but which scene's camera data would the output node use? You would still have the same issue as with the Defocus node, in that the node is taking invisible inputs (i.e., camera data) that are not exposed to the user.

If I have an EXR with camera data, but I'm compositing it with another scene with camera data, I would need to specify what camera data goes where. Currently, the Defocus node invisibly pulls the camera data from the scene in which it was first added. How can we unblock the user from choosing the relevant camera inputs for the Defocus and other output nodes?

I would suggest to only use scene (or other ID pointers) in node->id when they are real ID block references that can be selected by the user. These would then stay fixed across changing contexts as well, which avoids a lot of ugly code in blenkernel.

For cases where the node->id is actually context dependent (composite, defocus) it should not be used at all. Rather for these nodes the context (which is given for a compositor execution) then defines the actual scene from which to take camera data and output render data.

This should also fix issues where the hard scene pointer gets outdated, see T38473.

It would also allow for flexible behavior as suggested by @Brecht Van Lommel (brecht) above: If no ID is selected by the user, the context can be used instead.

So I think in practice that means:

  • Composite and File Output: remove node->id usage and get scene from context
  • Defocus node: make the node->id scene user editable, and if NULL get scene from the context.

Making camera data something you can read from EXR and pass along in the node editor would be nice but beyond the scope of a bugfix I think, the changes above should be relatively simple?

That sounds like a fine solution. Thanks, Everyone!