EEVEE-Next: Add Inflate Bounds option #114200

Merged
Miguel Pozo merged 12 commits from pragma37/blender:pull-extend-bbox into main 2023-11-07 15:28:15 +01:00
Member

Add an Inflate Bounds option to Material settings, so frustum culling can work correctly with vertex displacement.

Add an Inflate Bounds option to Material settings, so frustum culling can work correctly with vertex displacement.
Miguel Pozo added the
Interest
EEVEE
Module
EEVEE & Viewport
labels 2023-10-27 16:57:51 +02:00
Miguel Pozo added 2 commits 2023-10-27 16:58:04 +02:00
Miguel Pozo requested review from Clément Foucault 2023-10-27 16:59:55 +02:00
Clément Foucault requested changes 2023-10-30 13:19:35 +01:00
Clément Foucault left a comment
Member

I am a bit unsure if we want this to be on the material. I think it depends much on the geometry. Cycles has a per object clipping property and other game engine consider the bounds a per object property.

I think it is more tedious to set up per material as you could forget one is set too high.

Not to mention this adds a bit more complexity compared to per object.

I am a bit unsure if we want this to be on the material. I think it depends much on the geometry. Cycles has a per object clipping property and other game engine consider the bounds a per object property. I think it is more tedious to set up per material as you could forget one is set too high. Not to mention this adds a bit more complexity compared to per object.
@ -299,7 +299,7 @@ class EEVEE_NEXT_MATERIAL_PT_settings_surface(MaterialButtonsPanel, Panel):
col.prop(mat, "use_backface_culling", text="Camera")
col.prop(mat, "use_backface_culling_shadow", text="Shadow")
# TODO(fclem): Displacement option

This is meant for the displacement type. Not the bounds.

This is meant for the displacement type. Not the bounds.
pragma37 marked this conversation as resolved
Author
Member

I am a bit unsure if we want this to be on the material. I think it depends much on the geometry.

The amount of displacement is always driven by the material itself (unless using an attribute node).
For the latter case, we can add the per-object property as well and just use the max value.

I think it is more tedious to set up per material as you could forget one is set too high.

Consider you have a material and change its displacement. Now you have to search all the objects that use it (across scenes and even blend files) for it to work properly.
There are also cases where it may not be even possible to set the property (GN instancing procedural geometry).

> I am a bit unsure if we want this to be on the material. I think it depends much on the geometry. The amount of displacement is always driven by the material itself (unless using an attribute node). For the latter case, we can add the per-object property as well and just use the max value. > I think it is more tedious to set up per material as you could forget one is set too high. Consider you have a material and change its displacement. Now you have to search all the objects that use it (across scenes and even blend files) for it to work properly. There are also cases where it may not be even possible to set the property (GN instancing procedural geometry).
Miguel Pozo force-pushed pull-extend-bbox from 104e54d1e3 to de2502b700 2023-10-30 18:53:27 +01:00 Compare

So had a lot of discussion with both artists and programmers. Here is some considerations:

In favor of per Object:

  • The object scale is what "can" influence the displacement after the material. Object attributes can also affect the final displacement.
  • This is only a setting when things fail and it is changing a per object behavior. So if an object has issues, you don't want to go through all materials to check which one is creating the issue.
  • If you have linked data, the object is the one you can easily override / localize.
  • Object granularity is what this is applied to.
  • Only one setting.

In favor of per material:

  • Discoverability. The setting is closer to the nodetree that produces the displacement.
  • Reusable. No need to set it per object.

This is kind of similar to the step size of cycles volume material where a two level control should be working.

Since it is quite unclear for me how the object propertie would influence the material one, I would just add the material one first in the end.

I think object space is fine for now. We can add a world space option if needed later.

So had a lot of discussion with both artists and programmers. Here is some considerations: #### In favor of per Object: - The object scale is what "can" influence the displacement after the material. Object attributes can also affect the final displacement. - This is only a setting when things fail and it is changing a per object behavior. So if an object has issues, you don't want to go through all materials to check which one is creating the issue. - If you have linked data, the object is the one you can easily override / localize. - Object granularity is what this is applied to. - Only one setting. #### In favor of per material: - Discoverability. The setting is closer to the nodetree that produces the displacement. - Reusable. No need to set it per object. This is kind of similar to the step size of cycles volume material where a two level control should be working. Since it is quite unclear for me how the object propertie would influence the material one, I would just add the material one first in the end. I think object space is fine for now. We can add a world space option if needed later.
Clément Foucault requested changes 2023-10-30 20:07:25 +01:00
@ -225,0 +227,4 @@
if (is_drawable_type) {
for (auto i : IndexRange(DRW_cache_object_material_count_get(ob))) {
if (::Material *material = BKE_object_material_get(ob, i + 1)) {
inflate_bounds = math::max(inflate_bounds, material->inflate_bounds);

This is a bit annoying because this can make material that have no displacement inflate the bounding box for no reason.

I'm wondering if we could amend the bounds after the drawcall loop instead of trying to compute it upfront. This way, we would know if there is displacement based on the GPU material flag and the material flag.

Moreover that would avoid one loop over materials that are scattered across memory.

This is a bit annoying because this can make material that have no displacement inflate the bounding box for no reason. I'm wondering if we could amend the bounds after the drawcall loop instead of trying to compute it upfront. This way, we would know if there is displacement based on the GPU material flag and the material flag. Moreover that would avoid one loop over materials that are scattered across memory.
pragma37 marked this conversation as resolved
@ -160,3 +160,3 @@
}
inline void ObjectBounds::sync(Object &ob)
inline void ObjectBounds::sync(Object &ob, float inflate_bounds /* = 0.0f*/)

I don't think writing the default parameter is part of the code style.

I don't think writing the default parameter is part of the code style.
pragma37 marked this conversation as resolved
Miguel Pozo added 5 commits 2023-11-02 17:04:48 +01:00
Clément Foucault requested changes 2023-11-02 18:28:15 +01:00
@ -260,0 +269,4 @@
BKE_pbvh_bounding_box(ob_ref.object->sculpt->pbvh, min, max);
float3 center = (min + max) * 0.5;
float3 half_extent = max - center;
half_extent += float3(inflate_bounds);

No need to cast to float3. VecBase &operator+=(const T &b) is defined.

No need to cast to `float3`. `VecBase &operator+=(const T &b)` is defined.
pragma37 marked this conversation as resolved
@ -955,6 +955,15 @@ void RNA_def_material(BlenderRNA *brna)
"Determines which inner part of the mesh will produce volumetric effect");
RNA_def_property_update(prop, 0, "rna_Material_draw_update");
prop = RNA_def_property(srna, "inflate_bounds", PROP_FLOAT, PROP_NONE);

Since this is related to displacement, I would name it accordingly. Maybe call it Max Vertex Displacement Distance ("max_vertex_displacement") but I wouldn't clamp the displacement (at least not yet and definitively not in this commit).

Also this should be a PROP_DISTANCE.

Since this is related to displacement, I would name it accordingly. Maybe call it `Max Vertex Displacement Distance` (`"max_vertex_displacement"`) but I wouldn't clamp the displacement (at least not yet and definitively not in this commit). Also this should be a `PROP_DISTANCE`.
Author
Member

Done, but I've renamed the UI text to just "Max Displacement", so it can fit in the default panel width.

Done, but I've renamed the UI text to just "Max Displacement", so it can fit in the default panel width.
@ -957,1 +957,4 @@
prop = RNA_def_property(srna, "inflate_bounds", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, nullptr, "inflate_bounds");
RNA_def_property_range(prop, 0.0f, 1000.0f);

Max should be FLT_MAX

Max should be FLT_MAX
pragma37 marked this conversation as resolved
Miguel Pozo added 1 commit 2023-11-03 15:37:26 +01:00
Miguel Pozo added 2 commits 2023-11-06 15:56:15 +01:00
Miguel Pozo added 1 commit 2023-11-06 16:09:08 +01:00
Clément Foucault approved these changes 2023-11-06 20:52:32 +01:00
@ -967,0 +969,4 @@
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_text(prop,
"Max Vertex Displacement",
"Extends the bounds used for frustum culling. "

This needs to be updated. I'm not sure if we should refer to the frustum culling which is a technical details in EEVEE and not even a feature.

This needs to be updated. I'm not sure if we should refer to the frustum culling which is a technical details in EEVEE and not even a feature.
Miguel Pozo added 1 commit 2023-11-07 15:26:46 +01:00
Miguel Pozo merged commit b4316445a8 into main 2023-11-07 15:28:15 +01:00
Miguel Pozo deleted branch pull-extend-bbox 2023-11-07 15:28:17 +01: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
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#114200
No description provided.