Mesh to Volume: Changes in Fog Volume #107279

Merged
Erik Abrahamsson merged 4 commits from erik85/blender:mesh-to-vol-update1 into main 2023-04-25 21:56:20 +02:00

This patch fixes a few problems with the current implementation of Mesh to Volume.

Main Problem

Currently Mesh to Volume creates a volume using openvdb::tools::meshToVolume which is then filled with the specified density and the class set to Fog Volume.
This is wrong because meshToVolume creates a signed distance field by default that then needs to be converted to a Fog Volume with openvdb::tools::sdfToFogVolume to get a proper Fog volume. Here is the description of what that function does:

The active and negative-valued interior half of the narrow band becomes a linear ramp from 0 to 1; the inactive interior becomes active with a constant value of 1; and the exterior, including the background and the active exterior half of the narrow band, becomes inactive with a constant value of 0. The interior, though active, remains sparse.

This means with this change old files will no longer look the same. I don't see any way around that as the options for external band width and not filling the volume is removed (they don't make any sense for a fog volume).

Before

The current behavior, visualized with a Volume to Mesh node to the left and the volume to the right.

bild

After

The most noticable difference is the gradient looks better and is adjustable using the interior band width.
Scrubbing the Volume to Mesh Threshold between 0 and 1 shows the size of the gradient.

bild

This patch fixes a few problems with the current implementation of `Mesh to Volume`. ### Main Problem Currently `Mesh to Volume` creates a volume using `openvdb::tools::meshToVolume` which is then filled with the specified density and the class set to Fog Volume. This is wrong because `meshToVolume` creates a signed distance field by default that then needs to be converted to a Fog Volume with `openvdb::tools::sdfToFogVolume` to get a proper Fog volume. Here is the description of what that function does: > The active and negative-valued interior half of the narrow band becomes a linear ramp from 0 to 1; the inactive interior becomes active with a constant value of 1; and the exterior, including the background and the active exterior half of the narrow band, becomes inactive with a constant value of 0. The interior, though active, remains sparse. This means with this change old files will no longer look the same. I don't see any way around that as the options for external band width and not filling the volume is removed (they don't make any sense for a fog volume). #### Before The current behavior, visualized with a Volume to Mesh node to the left and the volume to the right. ![bild](/attachments/646ccccf-2757-47b3-bba1-9cc1444578fe) #### After The most noticable difference is the gradient looks better and is adjustable using the interior band width. Scrubbing the Volume to Mesh `Threshold` between 0 and 1 shows the size of the gradient. ![bild](/attachments/2dba0f6d-26ee-4d40-9f08-6b3f574a433e)
383 KiB
322 KiB
Erik Abrahamsson added 1 commit 2023-04-24 03:55:58 +02:00
Erik Abrahamsson requested review from Hans Goudey 2023-04-24 21:53:28 +02:00
Hans Goudey requested changes 2023-04-25 04:05:03 +02:00
Hans Goudey left a comment
Member

It's not clear why the sdf volume function is changing in this commit-- it's getting a new option and a new transform argument. Both of which seem reasonable, but again don't really need to be part of this PR. Sorry if it feels like I'm playing dumb, but I think it will be helpful/important to resolve this process thing so we're on the same page.

It's not clear why the sdf volume function is changing in this commit-- it's getting a new option and a new transform argument. Both of which seem reasonable, but again don't really need to be part of this PR. Sorry if it feels like I'm playing dumb, but I think it will be helpful/important to resolve this process thing so we're on the same page.
@ -96,3 +96,1 @@
const float voxel_size = approximate_volume_side_length / res.settings.voxel_amount /
volume_simplify;
return voxel_size;
const float voxel_size =
Member

There's a lot going on in this statement. Do you think it could be split into two, with a descriptive variable name?

There's a lot going on in this statement. Do you think it could be split into two, with a descriptive variable name?
Erik Abrahamsson added 1 commit 2023-04-25 19:24:03 +02:00
Erik Abrahamsson requested review from Hans Goudey 2023-04-25 19:28:20 +02:00
Hans Goudey approved these changes 2023-04-25 20:22:08 +02:00
Hans Goudey left a comment
Member

Looks good now, thanks for following up. For the commit title, I'd suggest something like "Volumes: Generate proper fog volume in Mesh to Volume node" to be a bit more specific.

Looks good now, thanks for following up. For the commit title, I'd suggest something like "Volumes: Generate proper fog volume in Mesh to Volume node" to be a bit more specific.
@ -75,2 +77,2 @@
const float volume_simplify = BKE_volume_simplify_factor(depsgraph);
if (volume_simplify == 0.0f) {
const float simplify_factor = BKE_volume_simplify_factor(depsgraph);
if (simplify_factor <= 0.0f) {
Member

Feel free to commit volume_simplify -> simplify_factor and 0 -> 0.0f separately without more review, but let's avoid combining the cleanups with a patch with functional changes.

Feel free to commit `volume_simplify` -> `simplify_factor` and `0` -> `0.0f` separately without more review, but let's avoid combining the cleanups with a patch with functional changes.
Erik Abrahamsson added 1 commit 2023-04-25 21:40:13 +02:00
Erik Abrahamsson added 1 commit 2023-04-25 21:51:02 +02:00
Erik Abrahamsson merged commit 700d168a5c into main 2023-04-25 21:56:20 +02:00
Erik Abrahamsson deleted branch mesh-to-vol-update1 2023-04-25 21:56:21 +02:00
Member

It seems like the processing time of the mesh to volume has doubled in the given example above

It seems like the processing time of the mesh to volume has doubled in the given example above
Howard Trickey referenced this issue from a commit 2023-05-29 02:51:44 +02:00
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
3 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#107279
No description provided.