Fix #109254: Voronoi Distance Output Clamps at 8.0 with low Minkowski Exponents #109286

Merged
Omar Emara merged 10 commits from Hoshinova/blender:db into main 2023-07-10 17:42:35 +02:00
Member

This fixes #109254 for F1 and F2, the fix doesn't work for Smooth F1.

This fixes #109254 for F1 and F2, the fix doesn't work for Smooth F1.
Hoshinova added 1 commit 2023-06-23 13:09:43 +02:00
Hoshinova requested review from Omar Emara 2023-06-23 13:09:58 +02:00
Iliya Katushenock added the
Interest
Render & Cycles
label 2023-06-23 13:10:40 +02:00
Author
Member

The problem with Smooth F1 is that the 8.0 seems to be the only constant where the smooth interpolation works correctly. So I thought you might know how to change the interpolation logic to make it work with the analytically computed max_distance.

And to be sure were on the same page params.max_distance is calculated like this:
params.max_distance = voronoi_distance(vec3(0.0), vec3(0.5 + 0.5 * params.randomness), params);

The problem with Smooth F1 is that the 8.0 seems to be the only constant where the smooth interpolation works correctly. So I thought you might know how to change the interpolation logic to make it work with the analytically computed max_distance. And to be sure were on the same page `params.max_distance` is calculated like this: `params.max_distance = voronoi_distance(vec3(0.0), vec3(0.5 + 0.5 * params.randomness), params);`
Hans Goudey changed title from WIP: Fix #109254 to WIP: Fix #109254: Voronoi Distance Output Clamps at 8.0 with low Minkowski Exponents 2023-06-23 13:29:21 +02:00
Hoshinova added 2 commits 2023-06-24 21:34:42 +02:00
Author
Member

@OmarEmaraDev I narrowed down the problem a bit.

Changing float smoothDistance = 8.0; to float smoothDistance = params.max_distance; fixes the problem for most cases... except for the 1D Smooth F1 and 2D Smooth F1 + Chebychev Color and Position outputs for some reason.

I only applied the Smooth F1 fix to the EEVEE (GLSL) version to make it easier to compare to the original version, which is still used in Cylces.

Test file demonstrating differences:
Voronoi_Test_File.blend

As can be seen in the test file there is a slight difference between the output in EEVEE and Cycles for the 1D Smooth F1 and 2D Smooth F1 + Chebychev Color and Position outputs.

@OmarEmaraDev I narrowed down the problem a bit. Changing `float smoothDistance = 8.0;` to `float smoothDistance = params.max_distance;` fixes the problem for most cases... except for the `1D Smooth F1` and `2D Smooth F1 + Chebychev` `Color` and `Position` outputs for some reason. I only applied the Smooth F1 fix to the EEVEE (GLSL) version to make it easier to compare to the original version, which is still used in Cylces. Test file demonstrating differences: [Voronoi_Test_File.blend](/attachments/e2ae5177-ece5-443c-a5ce-985cd5a59afd) As can be seen in the test file there is a slight difference between the output in EEVEE and Cycles for the `1D Smooth F1` and `2D Smooth F1 + Chebychev` `Color` and `Position` outputs.
Hoshinova reviewed 2023-06-24 21:41:20 +02:00
@ -157,3 +157,3 @@
float localPosition = coord - cellPosition;
float smoothDistance = 8.0;
float smoothDistance = params.max_distance;
Author
Member

Slightly changes Color and Position outputs for 1D Smooth F1 and 2D Smooth F1 + Chebychev for some reason.

Slightly changes `Color` and `Position` outputs for `1D Smooth F1` and `2D Smooth F1 + Chebychev` for some reason.
Author
Member

Changing it further to float smoothDistance = params.max_distance + 8.0; also fixes it for those cases.

Changing it further to `float smoothDistance = params.max_distance + 8.0;` also fixes it for those cases.
Hoshinova marked this conversation as resolved
Hoshinova added 1 commit 2023-06-25 19:31:15 +02:00
Author
Member

@OmarEmaraDev
Changing float smoothDistance = params.max_distance; to float smoothDistance = params.max_distance + 8.0; fixes the issues for the 1D Smooth F1 and 2D Smooth F1 + Chebychev Color and Position outputs now.
I'm not sure why it works, my guess is that the smooth interpolation logic only works when the initial value of smoothDistance is significantly larger than params.max_distance.

It works now from a user perspective, the question is whether it makes sense regarding the whole Smooth F1 calculation logic or if it's just mere coincidence that it works.

@OmarEmaraDev Changing `float smoothDistance = params.max_distance;` to `float smoothDistance = params.max_distance + 8.0;` fixes the issues for the `1D Smooth F1` and `2D Smooth F1 + Chebychev` `Color` and `Position` outputs now. I'm not sure why it works, my guess is that the smooth interpolation logic only works when the initial value of `smoothDistance ` is significantly larger than `params.max_distance`. It works now from a user perspective, the question is whether it makes sense regarding the whole Smooth F1 calculation logic or if it's just mere coincidence that it works.
Hoshinova added 1 commit 2023-07-06 19:01:56 +02:00
-- Initialize h to 1 for first iteration in Smooth F1
Omar Emara requested changes 2023-07-06 19:18:26 +02:00
@ -8,6 +8,7 @@
#include "vector4.h"
#define vector3 point
#define FLT_MAX 3.402823466e+38 // max value
Member

Move that to stdcycles.h.

Move that to `stdcycles.h`.
Hoshinova marked this conversation as resolved
@ -130,3 +130,3 @@
float localPosition = coord - cellPosition;
float minDistance = 8.0;
float minDistance = FLT_MAX;
Member

Add at the top:

#pragma BLENDER_REQUIRE(gpu_shader_utildefines_lib.glsl)
Add at the top: ``` #pragma BLENDER_REQUIRE(gpu_shader_utildefines_lib.glsl) ```
Hoshinova marked this conversation as resolved
Hoshinova added 1 commit 2023-07-06 19:27:16 +02:00
BLENDER_SOURCE_CODE_COMMIT commit message number: 9
Some checks reported errors
buildbot/vexp-code-patch-coordinator Build done.
e60f786b9b
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR109286) when ready.
Hoshinova added 2 commits 2023-07-06 19:44:57 +02:00
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR109286) when ready.
Hoshinova changed title from WIP: Fix #109254: Voronoi Distance Output Clamps at 8.0 with low Minkowski Exponents to Fix #109254: Voronoi Distance Output Clamps at 8.0 with low Minkowski Exponents 2023-07-06 21:18:09 +02:00
Omar Emara requested changes 2023-07-06 21:48:52 +02:00
Omar Emara left a comment
Member

This produces artifacts for the smooth version.

20230706-224700.png

This produces artifacts for the smooth version. ![20230706-224700.png](/attachments/43eb029a-c193-4cfe-b070-f82fcd2ef3ec)
Hoshinova added 1 commit 2023-07-07 18:21:55 +02:00
-- Fix Smooth F1 artifacts
Some checks failed
buildbot/vexp-code-patch-coordinator Build done.
1261c01800

@blender-bot package

@blender-bot package
Author
Member

@OmarEmaraDev The artifacts are fixed now.

@OmarEmaraDev The artifacts are fixed now.
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR109286) when ready.
Hoshinova added 1 commit 2023-07-07 22:04:20 +02:00
Merge branch 'main' into db
All checks were successful
buildbot/vexp-code-patch-coordinator Build done.
21711eb95f
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR109286) when ready.
Omar Emara approved these changes 2023-07-10 17:38:12 +02:00
Omar Emara merged commit 41335edf22 into main 2023-07-10 17:42:35 +02:00
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
Code Documentation
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
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#109286
No description provided.