Workbench Next: Hair and Curves support #109456

Merged
Miguel Pozo merged 16 commits from pragma37/blender:pull-workbench-next-curves into main 2023-06-30 19:11:24 +02:00
Member
  • Add Hair and Curves support to the new Draw Manager. The sub_pass_setup functions bind the required data to an already created sub-pass and return the batches needed for drawing.

  • Add Hair and Curves rendering to Workbench Next:

    • Refactor MeshPasses so it's possible to retrieve the pass instead of letting the class handle the drawing itself.
    • Refactor object_sync so the emitter handle can be passed to the hair_sync function (needed to avoid outlines between hair and emitter).
    • Refactor the ObjectState constructor so it's easier to add support for other object types.
    • Update get_material so the slot index starts from 1, to match BKE_object_material_get_eval.

Notes:

  • Curves don't support the Texture and Attribute modes. This matches the current Workbench behavior, but I'm not sure if that's the right thing to do.
  • Maybe MeshPasses should be renamed to ObjectPasses?
* Add Hair and Curves support to the new Draw Manager. The `sub_pass_setup` functions bind the required data to an already created sub-pass and return the batches needed for drawing. * Add Hair and Curves rendering to Workbench Next: * Refactor MeshPasses so it's possible to retrieve the pass instead of letting the class handle the drawing itself. * Refactor object_sync so the emitter handle can be passed to the hair_sync function (needed to avoid outlines between hair and emitter). * Refactor the ObjectState constructor so it's easier to add support for other object types. * Update get_material so the slot index starts from 1, to match BKE_object_material_get_eval. Notes: * Curves don't support the Texture and Attribute modes. This matches the current Workbench behavior, but I'm not sure if that's the right thing to do. * Maybe MeshPasses should be renamed to ObjectPasses?
Miguel Pozo added 10 commits 2023-06-28 17:38:59 +02:00
Miguel Pozo added this to the EEVEE & Viewport project 2023-06-28 17:39:56 +02:00
Miguel Pozo requested review from Clément Foucault 2023-06-28 17:40:08 +02:00
Miguel Pozo added the
Module
EEVEE & Viewport
label 2023-06-28 17:40:24 +02:00
Miguel Pozo added 1 commit 2023-06-28 18:00:17 +02:00
Clément Foucault requested changes 2023-06-29 17:21:05 +02:00
Clément Foucault left a comment
Member

Looks good and quite safe. So will accept once my comments are addressed.

Looks good and quite safe. So will accept once my comments are addressed.
@ -135,3 +136,3 @@
}
if (ob->type == OB_MESH && ob->modifiers.first != nullptr) {
bool render_ob_data = DRW_object_visibility_in_active_context(ob) & OB_VISIBLE_SELF;

Prefer using is_ and do_ prefix for boolean to describe what state they describe. In this case it is the object visibility so is_object_data_visible.

Prefer using `is_` and `do_` prefix for boolean to describe what state they describe. In this case it is the object visibility so `is_object_data_visible`.
pragma37 marked this conversation as resolved
@ -138,0 +138,4 @@
bool render_ob_data = DRW_object_visibility_in_active_context(ob) & OB_VISIBLE_SELF;
render_ob_data = render_ob_data && (ob->dt >= OB_SOLID || DRW_state_is_scene_render());
if (!(ob->base_flag & BASE_FROM_DUPLI)) {

Split this block to a separate function called Instance::object_visibility_get.

Split this block to a separate function called `Instance::object_visibility_get`.
Author
Member

volume_ps.object_sync_modifier is called from this block of code.
It would be pretty bad to hide that inside a seemingly unrelated helper function, IMO.

`volume_ps.object_sync_modifier` is called from this block of code. It would be pretty bad to hide that inside a seemingly unrelated helper function, IMO.

Oops I missed that. Forget my comment then.

Oops I missed that. Forget my comment then.
fclem marked this conversation as resolved
@ -370,0 +383,4 @@
PassMain::Sub &pass = get_mesh_pass(ob_ref, mat.is_transparent())
.get_subpass(eGeometryType::CURVES, image, sampler_state, iuser)
.sub(ob_ref.object->id.name);

This is pretty volatile! ob_ref.object could be the same pointer for many duplis instances. It could also be allocated on the stack for the duration of the sync process. It is not advisable to reference any of the data inside an object.

This is pretty volatile! `ob_ref.object` could be the same pointer for many duplis instances. It could also be allocated on the stack for the duration of the sync process. It is not advisable to reference any of the data inside an object.
pragma37 marked this conversation as resolved
@ -107,0 +103,4 @@
return *passes_[int(geometry_type)][int(eShaderType::MATERIAL)];
}
void MeshPass::draw(ObjectRef &ref,

Remove this. It would make it easier to understand if there is less functions to a class that do almost the same thing.

Remove this. It would make it easier to understand if there is less functions to a class that do almost the same thing.
pragma37 marked this conversation as resolved
@ -540,0 +630,4 @@
sub_ps.bind_ubo("drw_curves", curves_infos);
sub_ps.push_constant("hairStrandsRes", &curves_cache->final[subdiv].strands_res, 1);

I would be tempted to ask for bundling these into one UBO for each Curve object, but that's better left to another PR.

I would be tempted to ask for bundling these into one UBO for each Curve object, but that's better left to another PR.
Author
Member

Yep, there was a TODO on the original draw_hair shader info too.
However, as long as we need to bind a separate hairPointBuffer for each call, I don't think is going to make a huge difference?

Yep, there was a TODO on the original `draw_hair` shader info too. However, as long as we need to bind a separate `hairPointBuffer` for each call, I don't think is going to make a huge difference?

It could make a difference for some backends depending on how we update that. Also it would clean the global namespace.

It could make a difference for some backends depending on how we update that. Also it would clean the global namespace.
fclem marked this conversation as resolved
Miguel Pozo added 2 commits 2023-06-29 18:18:06 +02:00
Clément Foucault approved these changes 2023-06-29 19:12:27 +02:00
Miguel Pozo added 3 commits 2023-06-30 19:03:53 +02:00
Miguel Pozo merged commit a639ec3afa into main 2023-06-30 19:11:24 +02:00
Miguel Pozo deleted branch pull-workbench-next-curves 2023-06-30 19:11:25 +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 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#109456
No description provided.