WIP: Compositor: add aspect ratio display in node viewer #106338

Draft
Habib Gahbiche wants to merge 3 commits from zazizizou/blender:com-backdrop-aspect-ratio into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

Node viewer can now show the image with desired aspect ratio (does not affect render).

Attached gif shows how the UI looks like. Existing functionalities like backdrop offset and scaling through backdrop gizmo still behave the same as before.

WIP: defaults are not working / Might need tweeks to UI depending on feedback / Code style

Node viewer can now show the image with desired aspect ratio (does not affect render). Attached gif shows how the UI looks like. Existing functionalities like backdrop offset and scaling through backdrop gizmo still behave the same as before. WIP: defaults are not working / Might need tweeks to UI depending on feedback / Code style
Habib Gahbiche added 1 commit 2023-03-30 21:18:44 +02:00
f7739310a5 Compositor: add aspect ratio display in node viewer
Node viewer can now show the image with desired aspect ratio (does not affect render).

WIP: defaults are not working, might need tweeks to UI depending on feedback.
Author
Member

@SteffenD behavior of aspect ratio is the same as in image and movie clip editors. Is that also how you would expect it to behave (see attached gif)?

@Jeroen-Bakker I'm having a hard time setting default values for the new values. I tried the following:

  1. RNA_def_property_float_default(prop, 1.0f); in rna_space.c
  2. setting snode->xasp = 1.0f; in node_create() in space_node.c
  3. defining a new struct in DNA_space_defaults.h

But Blender still sets values to 0.0f on start. Could you help me by pointing out where defaults get set?

@SteffenD behavior of aspect ratio is the same as in image and movie clip editors. Is that also how you would expect it to behave (see attached gif)? @Jeroen-Bakker I'm having a hard time setting default values for the new values. I tried the following: 1. ` RNA_def_property_float_default(prop, 1.0f);` in `rna_space.c` 2. setting `snode->xasp = 1.0f;` in `node_create()` in `space_node.c` 3. defining a new struct in `DNA_space_defaults.h` But Blender still sets values to `0.0f` on start. Could you help me by pointing out where defaults get set?
First-time contributor

@SteffenD behavior of aspect ratio is the same as in image and movie clip editors. Is that also how you would expect it to behave (see attached gif)?

Awesome! The behaviour in the GIF is perfect :)

> @SteffenD behavior of aspect ratio is the same as in image and movie clip editors. Is that also how you would expect it to behave (see attached gif)? Awesome! The behaviour in the GIF is perfect :)
Author
Member

@SteffenD ok thanks!

After some investigation I found out that creating a new compositor space will have the correct defaults (from step 2 above). RNA_def_property_float_default is called when user clicks "Reset to Default Value". So the only way of starting blender with the desired values is to edit the startup blend file startup.blend. Is this correct?

@SteffenD ok thanks! After some investigation I found out that creating a new compositor space will have the correct defaults (from step 2 above). `RNA_def_property_float_default` is called when user clicks "Reset to Default Value". So the only way of starting blender with the desired values is to edit the startup blend file `startup.blend`. Is this correct?
Habib Gahbiche added 2 commits 2023-04-02 22:27:32 +02:00
Member

Another approach would be to pass the aspect ratio via the meta data and use it. Might be better than adding an option. But requires more work as nodes can alter the aspect ratio.

I can imagine that the in the proposed solution the user has to alter the aspect ratio based on what they are looking at and that is adding more work towards the user. Although we might want the user to tweak final values, I do think this should be made as automatically as much as possible.

Another approach would be to pass the aspect ratio via the meta data and use it. Might be better than adding an option. But requires more work as nodes can alter the aspect ratio. I can imagine that the in the proposed solution the user has to alter the aspect ratio based on what they are looking at and that is adding more work towards the user. Although we might want the user to tweak final values, I do think this should be made as automatically as much as possible.
Author
Member

@Jeroen-Bakker but this is how the movie clip editor and the image editor change display ratio. The user has to alter the aspect ratio manually there also. So this patch addresses the consistency problem.

I agree this should be done as automatically as possible, but is it possible to do that as a next step after this patch?

@Jeroen-Bakker but this is how the movie clip editor and the image editor change display ratio. The user has to alter the aspect ratio manually there also. So this patch addresses the consistency problem. I agree this should be done as automatically as possible, but is it possible to do that as a next step after this patch?
Member

In the image editor the aspect ratio is stored inside the image, so when switching the image the correct aspect ratio is used. Same for movie clip editor.

This patch stored the aspect ratio as node attribute, which in case you're switching inputs the aspect ratio will that of the node. This is different (from user point of view) compared to the other editors.

The display aspect inside the image/movie clip editor is read from the next locations.

Even render results have aspect ratios. There might be issues when mixing or other ways where aspect ratios cannot be decided. In these cases I can expect that the node will have an aspect ratio.
These limitations might require a different UI as there are quite a few options already:

  • Use aspect ratio from node (this patch)
  • Use aspect ratio from input.
  • Use aspect ratio from render layer.
  • Use aspect ratio from scene.

So to find out the correct location we should collect user feedback.

@eyecandy do you have any ideas about viewer node display aspect ratios? and how you would use them

In the image editor the aspect ratio is stored inside the image, so when switching the image the correct aspect ratio is used. Same for movie clip editor. This patch stored the aspect ratio as node attribute, which in case you're switching inputs the aspect ratio will that of the node. This is different (from user point of view) compared to the other editors. The display aspect inside the image/movie clip editor is read from the next locations. - https://docs.blender.org/api/current/bpy.types.Image.html#bpy.types.Image.display_aspect - https://docs.blender.org/api/current/bpy.types.MovieClip.html#bpy.types.MovieClip.display_aspect Even render results have aspect ratios. There might be issues when mixing or other ways where aspect ratios cannot be decided. In these cases I can expect that the node will have an aspect ratio. These limitations might require a different UI as there are quite a few options already: - Use aspect ratio from node (this patch) - Use aspect ratio from input. - Use aspect ratio from render layer. - Use aspect ratio from scene. So to find out the correct location we should collect user feedback. @eyecandy do you have any ideas about viewer node display aspect ratios? and how you would use them
Author
Member

@eyecandy I was wondering if you had a chance to look at this? I have time to work on this next week...

@eyecandy I was wondering if you had a chance to look at this? I have time to work on this next week...
Member

I checked with @eyecandy and we are struggling with finding the usage/benefit of this patch. I still believe that this should be collected from the input of the node tree where the viewer is connected to and not being a setting on the viewer node.

Can someone clarify what actual issue this solves and why adding the aspect rations in the viewer node is needed.

I checked with @eyecandy and we are struggling with finding the usage/benefit of this patch. I still believe that this should be collected from the input of the node tree where the viewer is connected to and not being a setting on the viewer node. Can someone clarify what actual issue this solves and why adding the aspect rations in the viewer node is needed.
Author
Member

@Jeroen-Bakker / @eyecandy I see, thanks for looking into this.

For me it's just a problem of consistent viewing across the different editors. If you work with anamorphic input then you will be able to display the correct aspect in movie clip editor and image editor but not in node editor (see attachment). I am not aware of a solution to this, that's why I submitted the patch.

As for implementation I don't have a strong opinion, I would go with Jeroen's suggestion if we agree backdrop must consider aspect ratio.

@Jeroen-Bakker / @eyecandy I see, thanks for looking into this. For me it's just a problem of consistent viewing across the different editors. If you work with anamorphic input then you will be able to display the correct aspect in movie clip editor and image editor but not in node editor (see attachment). I am not aware of a solution to this, that's why I submitted the patch. As for implementation I don't have a strong opinion, I would go with Jeroen's suggestion if we agree backdrop must consider aspect ratio.

We discussed this in the VFX meeting, and I thought we might as well add the option here for those working with anamorphic video files. But I changed my mind after looking at this more closely.

The issue is that compositing in general doesn't work correctly on anamorphic video, filters and transforms will give wrong results. The workflow in a few other compositing apps seems to be to desqueeze the image with a node before processing it, rather than having viewer options for aspect ratio. I think that's what we should recommend too, rather than going in the direction of a workflow where we will hit limitations at some point anyway.

We discussed this in the VFX meeting, and I thought we might as well add the option here for those working with anamorphic video files. But I changed my mind after looking at this more closely. The issue is that compositing in general doesn't work correctly on anamorphic video, filters and transforms will give wrong results. The workflow in a few other compositing apps seems to be to desqueeze the image with a node before processing it, rather than having viewer options for aspect ratio. I think that's what we should recommend too, rather than going in the direction of a workflow where we will hit limitations at some point anyway.

You indeed need to "unsquish" the input, otherwise things like lens distortion will not work (as it is in the non-squished space, and caibraiton can not be mapped form one to another).

What I am not sure is whether you "squish" the image back before writing it to disk. You probably don't for the final output, if you're creating a clean plate maybe there are some benefits for squishing things back.

But now when I think of it, you probably will not use the viewer node to look into the squished result, as it will be at the end. And if the output image is to be squished, and you still want to see it, you can use the aspect ratio in the image editor.

There are couple of things I am wondering though.

  • I think @sebastian_k worked on anamorphic videos before and can share his experience and help prioritizing changes.
  • Habib, is it something coming from a discussion on devtalk where we can read-up a bit and understand if the "unsquish" workflow is not desirable there?
You indeed need to "unsquish" the input, otherwise things like lens distortion will not work (as it is in the non-squished space, and caibraiton can not be mapped form one to another). What I am not sure is whether you "squish" the image back before writing it to disk. You probably don't for the final output, if you're creating a clean plate maybe there are some benefits for squishing things back. But now when I think of it, you probably will not use the viewer node to look into the squished result, as it will be at the end. And if the output image is to be squished, and you still want to see it, you can use the aspect ratio in the image editor. There are couple of things I am wondering though. - I think @sebastian_k worked on anamorphic videos before and can share his experience and help prioritizing changes. - Habib, is it something coming from a discussion on devtalk where we can read-up a bit and understand if the "unsquish" workflow is not desirable there?
Author
Member

Thanks for looking into this patch.

I approached this as a bug after fixing #105590, not as a direct user request, so I don't have a strong opinion on how anamorphic input should be handled.

The idea of the patch #106121 is indeed to "squish" the mask before applying it to the image in order to have correct results. So I see 2 options on how to proceed here:

  1. Do nothing: leave it to the user to un-squish the input image and squish it back before saving
  2. Let Blender handle aspect ratio implicitly, e.g.
    • add node "set aspect ratio" that un-squishes the input or read aspect ratio from render settings
    • change all output nodes to scale the output before displaying or saving
Thanks for looking into this patch. I approached this as a bug after fixing #105590, not as a direct user request, so I don't have a strong opinion on how anamorphic input should be handled. The idea of the patch #106121 is indeed to "squish" the mask before applying it to the image in order to have correct results. So I see 2 options on how to proceed here: 1) Do nothing: leave it to the user to un-squish the input image and squish it back before saving 2) Let Blender handle aspect ratio implicitly, e.g. - add node "set aspect ratio" that un-squishes the input or read aspect ratio from render settings - change all output nodes to scale the output before displaying or saving

I think that if you're doing any non trivial compositing, your camera input may be anamorphic but there's no good reason to output it anamorphic again. It's a quirk that cameras work this way, and it's good to get raw data from the camera without scaling so that you have as much control as possible in compositing. But for the final output, I don't see the point.

A utility node to scale anamorphic footage could be nice. Or even an option for image reading also available in the sequencer.

I think that if you're doing any non trivial compositing, your camera input may be anamorphic but there's no good reason to output it anamorphic again. It's a quirk that cameras work this way, and it's good to get raw data from the camera without scaling so that you have as much control as possible in compositing. But for the final output, I don't see the point. A utility node to scale anamorphic footage could be nice. Or even an option for image reading also available in the sequencer.
This pull request has changes conflicting with the target branch.
  • release/datafiles/startup.blend
  • source/blender/makesrna/intern/rna_space.c

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u com-backdrop-aspect-ratio:zazizizou-com-backdrop-aspect-ratio
git checkout zazizizou-com-backdrop-aspect-ratio
Sign in to join this conversation.
No reviewers
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
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#106338
No description provided.