Lens Distortion compositor node artifacts #37462

Closed
opened 2013-11-15 01:11:54 +01:00 by Anton Ilmyanov · 19 comments

System Information
Windows 7 64

Blender Version
Broken: Blender 2.69, 2.68, 2.67

Short description of error
Lens Distortion node produces blur artifacts looking like a grid. The size of the grid changes when you adjust Dispersion and/or Distortion parameters. It's most noticeable in darker and noisy areas, especially in animations as you play them fullscreen. It doesn't completely go away with higher sampling.

Exact steps for others to reproduce the error
Render the attached .blend and zoom in.
lens-distortion-test.blend

Screenshot lens-distortion-artifacts.png

**System Information** Windows 7 64 **Blender Version** Broken: Blender 2.69, 2.68, 2.67 **Short description of error** Lens Distortion node produces blur artifacts looking like a grid. The size of the grid changes when you adjust Dispersion and/or Distortion parameters. It's most noticeable in darker and noisy areas, especially in animations as you play them fullscreen. It doesn't completely go away with higher sampling. **Exact steps for others to reproduce the error** Render the attached .blend and zoom in. [lens-distortion-test.blend](https://archive.blender.org/developer/F27329/lens-distortion-test.blend) Screenshot ![lens-distortion-artifacts.png](https://archive.blender.org/developer/F27331/lens-distortion-artifacts.png)
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @AntonIlmyanov

Added subscriber: @AntonIlmyanov
Member

Added subscriber: @gandalf3

Added subscriber: @gandalf3

Added subscribers: @Jeroen-Bakker, @monique

Added subscribers: @Jeroen-Bakker, @monique

Added subscriber: @brecht

Added subscriber: @brecht

I can confirm the issue.

At first I thought this might have been because of the particular random number sequence cycles is using but it appears to be not the case, same happens for blender internal and other random noise.

I can confirm the issue. At first I thought this might have been because of the particular random number sequence cycles is using but it appears to be not the case, same happens for blender internal and other random noise.
Lukas Tönne was assigned by Sergey Sharybin 2013-12-04 16:28:34 +01:00

Added subscribers: @LukasTonne, @Sergey

Added subscribers: @LukasTonne, @Sergey

@LukasTonne, would you have any idea here? If not, re-assign to me and i'l ltry to find a clue :)

@LukasTonne, would you have any idea here? If not, re-assign to me and i'l ltry to find a clue :)
Member

I can't decipher the math of that node easily. Just from the effect it has i suspect there is a problem with accumulating pixel values: depending on the subpixel coordinates it could lead some smoothing-out of small scale noisy variations, then if these offsets in relation to the integer pixel coordinates change it could lead to the observed grid pattern. But that's little more than a gut feeling ...

Would be great to have references to papers or at least some topics/keywords in such code which would allow you to get an overview of what it is supposed to do. Otherwise understanding cryptic formulas with one-letter variables and no comments is close to impossible and makes it dead code that nobody will ever be able to fix or improve ...

I can't decipher the math of that node easily. Just from the effect it has i suspect there is a problem with accumulating pixel values: depending on the subpixel coordinates it could lead some smoothing-out of small scale noisy variations, then if these offsets in relation to the integer pixel coordinates change it could lead to the observed grid pattern. But that's little more than a gut feeling ... Would be great to have references to papers or at least some topics/keywords in such code which would allow you to get an overview of what it is *supposed* to do. Otherwise understanding cryptic formulas with one-letter variables and no comments is close to impossible and makes it dead code that nobody will ever be able to fix or improve ...
Member

I've been investigating the ScreenLensDistortionOperation and cleaning/restructuring the code to make it more understandable. Unfortunately it seems like the problem causing this bug is rooted in the accumulation method the algorithm uses to sum up color values for distorted pixels. This is done by evaluating the input image over a range of pixels defined by a non-linear factor, which i assume causes this sort of unequal noise smoothing. I don't know enough about the supposed sampling algorithm to fix this easily.

I've been investigating the ScreenLensDistortionOperation and cleaning/restructuring the code to make it more understandable. Unfortunately it seems like the problem causing this bug is rooted in the accumulation method the algorithm uses to sum up color values for distorted pixels. This is done by evaluating the input image over a range of pixels defined by a non-linear factor, which i assume causes this sort of unequal noise smoothing. I don't know enough about the supposed sampling algorithm to fix this easily.
Member

Compare this to artifacts you get when scaling a noise texture (open image to see the effect):
screen.png

This is just white noise, scaled (no power-of-2) and nearest-filtered. On a small scale the lens distortion does just that, it scales the image and the bad filtering produces these artifacts when applied to sharp per-pixel noise contrast.

Compare this to artifacts you get when scaling a noise texture (open image to see the effect): ![screen.png](https://archive.blender.org/developer/F72315/screen.png) This is just white noise, scaled (no power-of-2) and nearest-filtered. On a small scale the lens distortion does just that, it scales the image and the bad filtering produces these artifacts when applied to sharp per-pixel noise contrast.

Added subscriber: @NAD

Added subscriber: @NAD

It looks like this might be the result of the fact that it uses bilinear interpolation in the accumulation function (line 150 in COM_ScreenLensDistortionOperation.cpp). This could be what's causing discontinuities at the block boundaries. This seems like it might explain what's happening: http://libnoise.sourceforge.net/noisegen/index.html

@LukasTonne, could you send me your cleaned version of the ScreenLensDistortionOperation code? I'm new to Blender so it would help to have something more readable. Perhaps I might be able to help.

It looks like this might be the result of the fact that it uses bilinear interpolation in the accumulation function (line 150 in COM_ScreenLensDistortionOperation.cpp). This could be what's causing discontinuities at the block boundaries. This seems like it might explain what's happening: http://libnoise.sourceforge.net/noisegen/index.html @LukasTonne, could you send me your cleaned version of the ScreenLensDistortionOperation code? I'm new to Blender so it would help to have something more readable. Perhaps I might be able to help.
Member

@NAD: My cleanup changes are already in master, committed as part of 9c883a1. Before this it was basically one big clunky function with redundant code, i merely split it into smaller parts to clarify what is happening.

And yes, i believe the key to this issue is the accumulation method. Seems like some kind of aliasing issue, but i'm not an expert in sampling methods, so take that with a grain of salt. Thanks for looking into it anyway, hope you manage to find a solution. Let me know if i can help.

@NAD: My cleanup changes are already in master, committed as part of 9c883a1. Before this it was basically one big clunky function with redundant code, i merely split it into smaller parts to clarify what is happening. And yes, i believe the key to this issue is the accumulation method. Seems like some kind of aliasing issue, but i'm not an expert in sampling methods, so take that with a grain of salt. Thanks for looking into it anyway, hope you manage to find a solution. Let me know if i can help.

Thanks @lukastoenne. I'll start digging in this weekend. Will report back next week.

Thanks @lukastoenne. I'll start digging in this weekend. Will report back next week.

Added subscriber: @kevindietrich

Added subscriber: @kevindietrich
Member

Changed status from 'Open' to: 'Archived'

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

No solution in sight for this, putting it on the ToDo list.

No solution in sight for this, putting it on the ToDo list.

@LukasTonne: Unfortunately I've been swamped with work lately and haven't had time to get to this, but I did a quick pass. Perhaps this will be useful to whoever gets to this first:
It's worth noting that the size of the artifacts is inversely proportional to the amount of dispersion used -- so doubling dispersion halves the size of the artifacts. It seems like it might be an interpolation problem in COM_MemoryBuffer.cpp (readEWA line 255). I still think http://libnoise.sourceforge.net/noisegen/index.html might be the answer.

@LukasTonne: Unfortunately I've been swamped with work lately and haven't had time to get to this, but I did a quick pass. Perhaps this will be useful to whoever gets to this first: It's worth noting that the size of the artifacts is inversely proportional to the amount of dispersion used -- so doubling dispersion halves the size of the artifacts. It seems like it might be an interpolation problem in COM_MemoryBuffer.cpp (readEWA line 255). I still think http://libnoise.sourceforge.net/noisegen/index.html might be the answer.
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
7 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#37462
No description provided.