Fix #127590: EEVEE: Wrong background motion vectors #127718

Merged
Miguel Pozo merged 3 commits from pragma37/blender:pull-fix-background-motion-vectors into main 2024-09-17 19:33:54 +02:00
Member

Compute the background plane position in world space and reproject it to the camera perspective matrices.
Remove outdated comments.

Note: The code uses points instead of directions. I've tested by offsetting the test scene 1000 units in every axis and it doesn't seem to cause troubles.
The code could be updated to use view directions projected into the far plane (since that's what I think the original intent was?), but I don't think the perspective matrix can be skipped.

Compute the background plane position in world space and reproject it to the camera perspective matrices. Remove outdated comments. Note: The code uses points instead of directions. I've tested by offsetting the test scene 1000 units in every axis and it doesn't seem to cause troubles. The code could be updated to use view directions projected into the far plane (since that's what I think the original intent was?), but I don't think the perspective matrix can be skipped.
Miguel Pozo added the
Interest
EEVEE
Module
Viewport & EEVEE
labels 2024-09-16 19:04:45 +02:00
Miguel Pozo added 1 commit 2024-09-16 19:04:57 +02:00
Miguel Pozo requested review from Clément Foucault 2024-09-16 19:06:06 +02:00
Miguel Pozo added 1 commit 2024-09-17 14:03:28 +02:00
Author
Member

I've updated the code to avoid the world space translation, but it requires extra matrix multiplications, so I'm not sure it's worth it.
It can be reverted.

I've updated the code to avoid the world space translation, but it requires extra matrix multiplications, so I'm not sure it's worth it. It can be reverted.
Clément Foucault approved these changes 2024-09-17 18:45:26 +02:00
Clément Foucault left a comment
Member

I think I may have think that winmat was persmat.

This new iteration of the patch is the correct fix.
We should not transform the background as points as it would interact during translation of the camera (where the background should have no velocity).

I think I may have think that `winmat` was `persmat`. This new iteration of the patch is the correct fix. We should not transform the background as points as it would interact during translation of the camera (where the background should have no velocity).
@ -53,4 +52,1 @@
{
/* Only transform direction to avoid losing precision. */
vec3 V = transform_direction(camera_curr.viewinv, vV);
/* NOTE: We don't use the drw_view.winmat to avoid adding the TAA jitter to the velocity. */

I don't see why this is outdated? It is an explanation to why we use camera_curr.winmat instead of drw_view.winmat.

I don't see why this is outdated? It is an explanation to why we use `camera_curr.winmat` instead of `drw_view.winmat`.
Author
Member

I misread what the comment meant. I've added it back with a small clarification.

I misread what the comment meant. I've added it back with a small clarification.
@ -46,3 +45,3 @@
/**
* Given a view space view vector \a vV, compute the previous and next motion vectors for
* Given a background view space point \a vP, compute the previous and next motion vectors for

I am not sure this does any difference. In fact, I prefer keeping the transform on the normalized version vV. It makes more sense to transform vV as a direction than vP.

Also keeps the patch smaller for back-porting.

I am not sure this does any difference. In fact, I prefer keeping the transform on the normalized version `vV`. It makes more sense to transform `vV` as a direction than `vP`. Also keeps the patch smaller for back-porting.
Author
Member

It skips one normalization, but other than that it's the same. I've reverted the change.

It skips one normalization, but other than that it's the same. I've reverted the change.
pragma37 marked this conversation as resolved
@ -57,3 +53,1 @@
vec2 prev_uv = project_point(camera_prev.winmat, V).xy;
vec2 curr_uv = project_point(camera_curr.winmat, V).xy;
vec2 next_uv = project_point(camera_next.winmat, V).xy;
/** NOTE: Transform as a direction to avoid imprecision if camera is far from origin. */

Nitpick: Reminder that /** is only for multiline comments.

Nitpick: Reminder that `/**` is only for multiline comments.
pragma37 marked this conversation as resolved

BTW it is better for precision to use 2 matrix transform instead of persmat. I think this is fine as is.

BTW it is better for precision to use 2 matrix transform instead of `persmat`. I think this is fine as is.
Miguel Pozo added 1 commit 2024-09-17 19:17:22 +02:00
Author
Member

I think I may have think that winmat was persmat.

I get confused about this all the time as well. I always have to check what each one means.
I wish we had something like view_mat, projection_mat and view_projection_mat or something along those lines.

> I think I may have think that `winmat` was `persmat`. I get confused about this all the time as well. I always have to check what each one means. I wish we had something like `view_mat`, `projection_mat` and `view_projection_mat` or something along those lines.
Miguel Pozo merged commit 9c54ddff69 into main 2024-09-17 19:33:54 +02:00
Miguel Pozo deleted branch pull-fix-background-motion-vectors 2024-09-17 19:33:57 +02:00

I wish we had something like view_mat, projection_mat and view_projection_mat or something along those lines.

I think we can make a todo about this mass renaming.

> I wish we had something like view_mat, projection_mat and view_projection_mat or something along those lines. I think we can make a todo about this mass renaming.
Author
Member

Done! #127806

Done! #127806
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
2 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#127718
No description provided.