Hair even distribution is not even #62891

Closed
opened 2019-03-24 10:12:45 +01:00 by Eneko Castresana Vara · 8 comments

System Information
Operating system: Ubuntu 18.04.2 LTS
Graphics card: GeForce GTX 950M

Blender Version
Broken: 2.80, 9105e1d084, 2019-03-20 22:53

Short description of error
Hair even distribution is not even.
Apologies in case. I'm unsure if this is a duplicate of https://developer.blender.org/T50536

Exact steps for others to reproduce the error
Please open attached .blend and switch even distribution.

Note how with even distribution disabled, each face emits 8 hair objects, which roughly matches the total of 50 particles set: 8x6 faces= 48 objects.

Now enable even distribution. The top and bottom faces emit 16 objects each, whereas the side faces emit 4 objects each: 16x2 + 4x4 = 48 objects.

EDIT: tl;dr: With even distribution on, it is expected (among other things, perhaps, such as similar distance between particles) the number of emitted particles should be proportional to face area. Currently it isn't proportional, and bigger faces are getting so many more particles than they should and smaller faces fewer! (Sorry about the next nonsense paragraph, I was in a rush).

Note that the emitter object has scaling applied and its side faces' areas are half of its top/bottom faces' areas. Therefore proper even distribution should work like this: Top and bottom faces have an area of 1 unit each. Side faces have an area of 0.5 units each. For every two side faces there should be the same number of particles than for any top/bottom face. Target is 50 total particles. 50/4 (every two side faces have the same area as 1 top/bottom face. So we're dividing by 4 area units) = 12.5 whose floor is 12. 12x4= 48. Therefore the top and bottom faces should emit 12 particles each, and the side faces should emit 6 particles each: 12x2 + 6x4 = 48.

hair-even-distribution.blend

**System Information** Operating system: Ubuntu 18.04.2 LTS Graphics card: GeForce GTX 950M **Blender Version** Broken: 2.80, 9105e1d08467, 2019-03-20 22:53 **Short description of error** Hair even distribution is not even. Apologies in case. I'm unsure if this is a duplicate of https://developer.blender.org/T50536 **Exact steps for others to reproduce the error** Please open attached .blend and switch even distribution. Note how with even distribution disabled, each face emits 8 hair objects, which roughly matches the total of 50 particles set: 8x6 faces= 48 objects. Now enable even distribution. The top and bottom faces emit 16 objects each, whereas the side faces emit 4 objects each: 16x2 + 4x4 = 48 objects. **EDIT: tl;dr:** With even distribution on, it is expected (among other things, perhaps, such as similar distance between particles) the number of emitted particles should be proportional to face area. Currently it isn't proportional, and bigger faces are getting so many more particles than they should and smaller faces fewer! (Sorry about the next nonsense paragraph, I was in a rush). Note that the emitter object has **scaling applied** and its side faces' areas are **half** of its top/bottom faces' areas. Therefore proper even distribution should work like this: Top and bottom faces have an area of 1 unit each. Side faces have an area of 0.5 units each. For every two side faces there should be the same number of particles than for any top/bottom face. Target is 50 total particles. 50/4 (every two side faces have the same area as 1 top/bottom face. So we're dividing by 4 area units) = 12.5 whose floor is 12. 12x4= 48. Therefore the top and bottom faces should emit 12 particles each, and the side faces should emit 6 particles each: 12x2 + 6x4 = 48. [hair-even-distribution.blend](https://archive.blender.org/developer/F6875241/hair-even-distribution.blend)

Added subscriber: @ecv

Added subscriber: @ecv
Member

Added subscribers: @Sergey, @brecht, @JacquesLucke

Added subscribers: @Sergey, @brecht, @JacquesLucke
Member

The issue is that in psys_thread_context_init_distribute all the vertex positions are transformed with BKE_mesh_orco_verts_transform.
In the example file, this multiplies the z coordinate of every vertex with 0.5.
This is because mesh->size is (1, 1, 0.5).
This seems to be used for texture scaling or so, but I don't understand why the vertices are transformed like that before the area is calculated.

diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index dd0a4a24d7b..8d0e25dcc07 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -969,12 +969,8 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
 				copy_v3_v3(co1, orcodata[mf->v1]);
 				copy_v3_v3(co2, orcodata[mf->v2]);
 				copy_v3_v3(co3, orcodata[mf->v3]);
-				BKE_mesh_orco_verts_transform(ob->data, &co1, 1, 1);
-				BKE_mesh_orco_verts_transform(ob->data, &co2, 1, 1);
-				BKE_mesh_orco_verts_transform(ob->data, &co3, 1, 1);
 				if (mf->v4) {
 					copy_v3_v3(co4, orcodata[mf->v4]);
-					BKE_mesh_orco_verts_transform(ob->data, &co4, 1, 1);
 				}
 			}
 			else {

@Sergey or @brecht, can you tell me, why this is done?

The issue is that in `psys_thread_context_init_distribute` all the vertex positions are transformed with `BKE_mesh_orco_verts_transform`. In the example file, this multiplies the z coordinate of every vertex with `0.5`. This is because `mesh->size` is `(1, 1, 0.5)`. This seems to be used for texture scaling or so, but I don't understand why the vertices are transformed like that before the area is calculated. ``` diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c index dd0a4a24d7b..8d0e25dcc07 100644 --- a/source/blender/blenkernel/intern/particle_distribute.c +++ b/source/blender/blenkernel/intern/particle_distribute.c @@ -969,12 +969,8 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti copy_v3_v3(co1, orcodata[mf->v1]); copy_v3_v3(co2, orcodata[mf->v2]); copy_v3_v3(co3, orcodata[mf->v3]); - BKE_mesh_orco_verts_transform(ob->data, &co1, 1, 1); - BKE_mesh_orco_verts_transform(ob->data, &co2, 1, 1); - BKE_mesh_orco_verts_transform(ob->data, &co3, 1, 1); if (mf->v4) { copy_v3_v3(co4, orcodata[mf->v4]); - BKE_mesh_orco_verts_transform(ob->data, &co4, 1, 1); } } else { ``` @Sergey or @brecht, can you tell me, why this is done?

This issue was referenced by 489c015e70

This issue was referenced by 489c015e706cf3bcfd246a2a081664d290ec7096

Undeformed / orco texture coordinates are supposed to be stored normalized to a 0..1 range. So particle distribution then transforms them back.

There's a case here where they are stored incorrectly, I'll fix that.

Undeformed / orco texture coordinates are supposed to be stored normalized to a 0..1 range. So particle distribution then transforms them back. There's a case here where they are stored incorrectly, I'll fix that.
Member

It's funny that CD_ORCO coordinates (I guess that means "original coordinates"?) are actually deformed.

Maybe a comment next to the definition of CD_ORCO could help here (or a better name).

It's funny that `CD_ORCO` coordinates (I guess that means "original coordinates"?) are actually deformed. Maybe a comment next to the definition of `CD_ORCO` could help here (or a better name).

Yes, it's old Blender Internal terminology for original coordinations. We should rename that once.

Yes, it's old Blender Internal terminology for original coordinations. We should rename that once.

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
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
4 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#62891
No description provided.