Realtime Compositor: Implement Movie Distortion node #108230
No reviewers
Labels
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
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#108230
Loading…
Reference in New Issue
No description provided.
Delete Branch "OmarEmaraDev/blender:compositor-movie-distortion"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This patch implements the Movie Distortion node for the realtime
compositor. The distorted coordinates are computed and cached for a
particular tracking camera distortion parameters. So for expensive
distortion models, the first run will take some time to compute, but
subsequent runs will be fast.
An alternative implementation would be to implement each of the
distortion modes in the shader, but that was decided against for a few
reasons:
since it is provided through an external library (Libmv).
quite slow to solve each time the shader runs.
the distortion parameters, rather, the parameters are computed during
camera calibration, so caching seems most fitting in that case.
This looks good to me. I think the approach is good as the tracking distortion doesn't usually change when previewing animation which is the primary goal.
I just added Sergey as reviewer so that he knows about the addition inside the tracking module. But thoses looks trivial.
Generally, it is probably indeed the best way of moving forward.
Thing is. Some of the implementation feels unideal and makes things like adding more distortion models even more complicated. Unfortunately, I can not think of an easy change to avoid this increased technical debt which will be good long-term. Part of the reason is that avoiding C-API and using things like
CameraIntrinsics
,PackedIntrinsics
etc is the ultimate way avoiding duplication, but we'll need a bigger refactor for that first.So for moving forward with the compositor we probably have to accept this technical debt, and solve it separately. There are few things which we need to do still though:
BKE_tracking_camera_equal
toBKE_tracking_camera_distortion_equal
Another thing I am wondering is the life time of the cached distortion grid. It is not very clear from the code when the memory is freed. Can you elaborate a bit about that?
@ -2198,6 +2202,62 @@ void BKE_tracking_camera_principal_point_pixel_set(struct MovieClip *clip,
principal_point_pixel, frame_width, frame_height, camera->principal_point);
}
bool BKE_tracking_camera_equal(const MovieTrackingCamera *a, const MovieTrackingCamera *b)
This is a bit confusing. Camera also defines sensor width, which is not compared here.
@ -2201,0 +2225,4 @@
return a->brown_k1 == b->brown_k1 && a->brown_k2 == b->brown_k2 &&
a->brown_k3 == b->brown_k3 && a->brown_k4 == b->brown_k4 &&
a->brown_p1 == b->brown_p1 && a->brown_p2 == b->brown_p2;
default:
Please do not add
default
unless absolutely needed, as it makes it very hard to see at compile time where enumerator value is forgotten to be checked when adding a new value.In this example it is as easy as moving the
BLI_assert_unreachable
past theswitch
statement.@ -2201,0 +2234,4 @@
uint64_t BKE_tracking_camera_hash(const MovieTrackingCamera *camera)
{
using namespace blender;
switch (camera->distortion_model) {
Is it intended to skip
distortion_model
,focal
and so on?@ -2201,0 +2253,4 @@
float2(camera->principal_point),
float4(camera->brown_k1 && camera->brown_k2 && camera->brown_k3 && camera->brown_k4),
float2(camera->brown_p1, camera->brown_p2));
default:
Same as above.
@ -0,0 +1,84 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
Please add copyright to the new files.
@Sergey This is documented in the header files of StaticCacheManager, CachedResources, and CachedResourceContainer classes. Start from here: https://projects.blender.org/blender/blender/src/branch/main/source/blender/compositor/realtime_compositor/COM_static_cache_manager.hh#L17
Thanks for the update and pointer to the docs.
Lets move of with this patch, and then I'll take care of some code de-duplication in the main branch from the motion tracking module :)