Glitching in Compositor with "Depth" value of .EXR #36745

Closed
opened 2013-09-17 04:23:35 +02:00 by David Brennan · 13 comments

%%%--- Operating System, Graphics card ---
Windows 7
Intel Integrated Graphics, i7-3770 (No GPU)

- Blender version with error, and version that worked ---

Blender 2.68 is being used

- Short description of error ---

I rendered out a 225-frame Cycles animation into .EXR files, with the plan of then doing the Compositing effects later on. This worked great....except for "Defocus Node". When I plugged in the "Depth" socket from the .EXR file (the same as the "Z" value from a Render Layer), the blur was NOT the correct Depth-of-Field, but was instead just a uniform blur.

The Z-value did indeed transfer properly into the .EXR file, though. But it simply was not registering properly in Blender's Compositor.

However, occasionally and randomly, sometimes it WOULD render properly. Perhaps 1 out of 10 times, it would render with the proper Depth of Field.

I started a thread about this at BA and Bartek Skroupa, who seems to be an expert on .EXR and Blender Compositing, never indicated that he had any problems like this.

So it is just a glitch, and might be unique to non-GPU rendering. I don't know. But it was very, very aggravating to have to count on getting lucky to get the proper compositing effects.

- Steps for others to reproduce the error (preferably based on attached .blend file) ---

I have attached a .Blend file with one .EXR file Packed into it. You just have to hit F12. (Note: the "Normalize" Node is in there so that you can easily confirm that the "Depth" values are properly saved in the .EXRs.)%%%

%%%--- Operating System, Graphics card --- Windows 7 Intel Integrated Graphics, i7-3770 (No GPU) - Blender version with error, and version that worked --- Blender 2.68 is being used - Short description of error --- I rendered out a 225-frame Cycles animation into .EXR files, with the plan of then doing the Compositing effects later on. This worked great....except for "Defocus Node". When I plugged in the "Depth" socket from the .EXR file (the same as the "Z" value from a Render Layer), the blur was NOT the correct Depth-of-Field, but was instead just a uniform blur. The Z-value did indeed transfer properly into the .EXR file, though. But it simply was not registering properly in Blender's Compositor. However, occasionally and randomly, sometimes it WOULD render properly. Perhaps 1 out of 10 times, it would render with the proper Depth of Field. I started a thread about this at BA and Bartek Skroupa, who seems to be an expert on .EXR and Blender Compositing, never indicated that he had any problems like this. So it is just a glitch, and might be unique to non-GPU rendering. I don't know. But it was very, very aggravating to have to count on getting lucky to get the proper compositing effects. - Steps for others to reproduce the error (preferably based on attached .blend file) --- I have attached a .Blend file with one .EXR file Packed into it. You just have to hit F12. (Note: the "Normalize" Node is in there so that you can easily confirm that the "Depth" values are properly saved in the .EXRs.)%%%
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

%%%Here's a .Blend at PasteAll: http://www.pasteall.org/blend/24116%%%

%%%Here's a .Blend at PasteAll: http://www.pasteall.org/blend/24116%%%
Author
%%%And here is a thread on the subject at BlenderArtists: http://blenderartists.org/forum/showthread.php?307274-Can-You-Use-Defocus-Nodes-on-EXR-Files%%%
Member

%%%Disabling the "Use Z-Buffer" option on the Defocus node helps. When enabled, this option will determine the "Z-Scale" setting from the active scene camera. Problem is that since you made an entirely new scene for use with the EXR image composite, the scene camera settings are likely not matching the ones used for the original render (can't say with certainty without the original render file). So "Use Z-Buffer" setting is pretty much useless in this setup and should be avoided.

If "Use Z-Buffer" is disabled the node will use a somewhat arbitrary default DoF distance value of 10, so i guess you just have to tweak the Z buffer to get a usable value. I have attached a modified file that contains a "Z Focus Adjust" node group (simply a subtract really) to shift the focus onto the character. You can use the Z-Scale value to further control the strength of the defocus.

http://www.pasteall.org/blend/24120%%%

%%%Disabling the "Use Z-Buffer" option on the Defocus node helps. When enabled, this option will determine the "Z-Scale" setting from the active scene camera. Problem is that since you made an entirely new scene for use with the EXR image composite, the scene camera settings are likely not matching the ones used for the original render (can't say with certainty without the original render file). So "Use Z-Buffer" setting is pretty much useless in this setup and should be avoided. If "Use Z-Buffer" is disabled the node will use a somewhat arbitrary default DoF distance value of 10, so i guess you just have to tweak the Z buffer to get a usable value. I have attached a modified file that contains a "Z Focus Adjust" node group (simply a subtract really) to shift the focus onto the character. You can use the Z-Scale value to further control the strength of the defocus. http://www.pasteall.org/blend/24120%%%
Author

%%%Lukas,

Please don't close this up.

What if a user has an animation - not a still image - and so the Z-value is constantly changing? Then it would be nearly impossible to constantly tweak the Math Node that you used, and so that work-around would not be applicable.

Then, you say, to simply use the Camera Data from the 3D Scene. This means that the EXR files basically don't even contain any useful Depth Value! Isn't the whole purpose of .EXR files to AVOID rendering and data from 3D Scenes, so that simple files can be shared from user to user?

Of course, most people don't use EXR files, but just commit to their Compositing effects at the time of rendering. But so long as Blender is generating these EXRs, I think their values should actually be useful. The Z-Value for Defocus Nodes is nearly useless. I believe this should be corrected.%%%

%%%Lukas, Please don't close this up. What if a user has an animation - not a still image - and so the Z-value is constantly changing? Then it would be nearly impossible to constantly tweak the Math Node that you used, and so that work-around would not be applicable. Then, you say, to simply use the Camera Data from the 3D Scene. This means that the EXR files basically don't even contain any useful Depth Value! Isn't the whole purpose of .EXR files to AVOID rendering and data from 3D Scenes, so that simple files can be shared from user to user? Of course, most people don't use EXR files, but just commit to their Compositing effects at the time of rendering. But so long as Blender is generating these EXRs, I think their values should actually be useful. The Z-Value for Defocus Nodes is nearly useless. I believe this should be corrected.%%%

%%%In that case, why not just link your camera and DOF target object from your 3D scene into the comp scene, and use them as the active camera there? That way the DOF settings for your comp scene always will match the 3D scene.%%%

%%%In that case, why not just link your camera and DOF target object from your 3D scene into the comp scene, and use them as the active camera there? That way the DOF settings for your comp scene always will match the 3D scene.%%%
Author

%%%Two reasons:

  1. I did this, and it STILL glitched frequently. (See the BlenderArtists thread for the sequence.) So using a dummy Camera for the Z values works unreliably, anyway.
  2. The purpose of .EXR files is to move PAST the 3D View and focus on compositing. If one is still slaved to the 3D Scene, then that defeats the purpose of .EXR files, which are supposed to be for compositing. (And what if one plans on sending the .EXR file to another user, for another program. Depth of Field would then be all-but-impossible, as you'd have to re-do the entire Camera and camera-target movement.)

%%%

%%%Two reasons: 1) I did this, and it STILL glitched frequently. (See the BlenderArtists thread for the sequence.) So using a dummy Camera for the Z values works unreliably, anyway. 2) The purpose of .EXR files is to move PAST the 3D View and focus on compositing. If one is still slaved to the 3D Scene, then that defeats the purpose of .EXR files, which are supposed to be for compositing. (And what if one plans on sending the .EXR file to another user, for another program. Depth of Field would then be all-but-impossible, as you'd have to re-do the entire Camera and camera-target movement.) %%%
Member

%%%The Z buffer itself is just that: the distance of each point from the camera. What the Defocus node does internally is calculate "focus distance" values from the Z values such that the focus is at 0. This process can be automated by using the camera, but if you want to use Defocus without the camera info you'll need to get the focus somehow. One way would be to store the focus distance as a separate image, after doing the aforementioned subtract. It can probably be done more accurately, but i have to look up the math tomorrow to check this. Maybe we need a specialized node for this part of the Defocus calculation to provide the value for EXR storage, or perhaps it can be done with drivers. Reopening in the meantime.%%%

%%%The Z buffer itself is just that: the distance of each point from the camera. What the Defocus node does internally is calculate "focus distance" values from the Z values such that the focus is at 0. This process can be automated by using the camera, but if you want to use Defocus without the camera info you'll need to get the focus somehow. One way would be to store the focus distance as a separate image, after doing the aforementioned subtract. It can probably be done more accurately, but i have to look up the math tomorrow to check this. Maybe we need a specialized node for this part of the Defocus calculation to provide the value for EXR storage, or perhaps it can be done with drivers. Reopening in the meantime.%%%
Author

%%%I appreciate the concentrated thought, and re-opening of this. I believe the way it is now, where .EXRs do not contain the Camera values necessary for Defocus Nodes, is a considerable issue (especially if one is rendering an animation, where the value is constantly influx; for a still image, it is easy to just approximate the needed value with a Math Node.)%%%

%%%I appreciate the concentrated thought, and re-opening of this. I believe the way it is now, where .EXRs do not contain the Camera values necessary for Defocus Nodes, is a considerable issue (especially if one is rendering an animation, where the value is constantly influx; for a still image, it is easy to just approximate the needed value with a Math Node.)%%%
Member

%%%I've been trying to come up with a good patch for this, but the fact remains that the defocus node just doesn't fit into a scene-less workflow. I've tried making the focus distance, lens and sensor size values explicit inputs of Defocus, but this only shifts the problem a bit. It's an effect that is directly tied to the way a camera works, so in order to apply it in a meaningful way having a camera is mandatory. You can fake the effect using the subtract method, but it will never work as nicely as a true camera.

At the core of this is a design conflict: what is the compositor supposed to do? Effects such as Defocus are a result of using a camera and are in fact not a post-processing feature. Ideally it should be part of the renderer rather than the compositor. So you may want to consider splitting the workflow into 2 parts, doing the defocus in your original file right after rendering, then exporting to EXR and doing actual postprocessing effects in a separate file. Alternatively just link the camera into your file to get the necessary animation data.

I've added this to our ToDo list, so it can be reviewed later:
http://wiki.blender.org/index.php/Dev:2.5/Source/Development/Todo/Tools#Compositing%%%

%%%I've been trying to come up with a good patch for this, but the fact remains that the defocus node just doesn't fit into a scene-less workflow. I've tried making the focus distance, lens and sensor size values explicit inputs of Defocus, but this only shifts the problem a bit. It's an effect that is directly tied to the way a camera works, so in order to apply it in a meaningful way having a camera is mandatory. You can fake the effect using the subtract method, but it will never work as nicely as a true camera. At the core of this is a design conflict: what is the compositor supposed to do? Effects such as Defocus are a result of using a camera and are in fact not a post-processing feature. Ideally it should be part of the renderer rather than the compositor. So you may want to consider splitting the workflow into 2 parts, doing the defocus in your original file right after rendering, then exporting to EXR and doing actual postprocessing effects in a separate file. Alternatively just link the camera into your file to get the necessary animation data. I've added this to our ToDo list, so it can be reviewed later: http://wiki.blender.org/index.php/Dev:2.5/Source/Development/Todo/Tools#Compositing%%%
Member

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Author

%%%Lukas,

Again, I appreciate the thought and suggested work-arounds. (Although note that, for myself, I encountered heavy glitching even when I did use the Camera data directly for the Z-value on .EXRs, so that's by no means a foolproof work-around.)

I disagree with one sentiment. You wrote, "Effects such as Defocus are a result of using a camera and are in fact not a post-processing feature." Defocus is clearly a post-processing feature (and I don't just mean because it's in the Compositor!) It relies upon the gradient of the Z-Value, and it fluctuates. The Z-value gradient is created in post.

There might be a simple add-on that could be created: The Camera's distance to "Focus" target is merely one number, right? (Although that number changes as the Camera or its Focus target move.) Would it be possible to either (a) include a simply "Camera Focus" socket on .EXR exports which contains this number, along with the relevant frame? And/or, (b) could there be a simple add-on written that exports the Camera Focus figure, which could then be used as a "Value" in the Compositor?%%%

%%%Lukas, Again, I appreciate the thought and suggested work-arounds. (Although note that, for myself, I encountered heavy glitching even when I did use the Camera data directly for the Z-value on .EXRs, so that's by no means a foolproof work-around.) I disagree with one sentiment. You wrote, "Effects such as Defocus are a result of using a camera and are in fact not a post-processing feature." Defocus is clearly a post-processing feature (and I don't just mean because it's in the Compositor!) It relies upon the gradient of the Z-Value, and it fluctuates. The Z-value gradient is created in post. There might be a simple add-on that could be created: The Camera's distance to "Focus" target is merely one number, right? (Although that number changes as the Camera or its Focus target move.) Would it be possible to either (a) include a simply "Camera Focus" socket on .EXR exports which contains this number, along with the relevant frame? And/or, (b) could there be a simple add-on written that exports the Camera Focus figure, which could then be used as a "Value" in the Compositor?%%%
Author

%%%I just looked up ".EXR" on Wikipedia. Much of the technical side of things is over my head, honestly. However, the part about "Deep Image Buffers" being included in the 2.0 version of the format might be relevant here:

http://en.wikipedia.org/wiki/.exr#History%%%

%%%I just looked up ".EXR" on Wikipedia. Much of the technical side of things is over my head, honestly. However, the part about "Deep Image Buffers" being included in the 2.0 version of the format might be relevant here: http://en.wikipedia.org/wiki/.exr#History%%%
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
Interest: X11
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 project
No Assignees
3 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#36745
No description provided.