Flickering in unrelated hair strands when deleting hair #99054

Open
opened 2022-06-21 14:46:13 +02:00 by Dalai Felinto · 5 comments

System Information
Operating system: Linux-5.13.0-48-generic-x86_64-with-glibc2.31 64 Bits
Graphics card: NVIDIA GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 510.73.05

Blender Version
Broken: version: 3.3.0 Alpha, branch: master, commit date: 2022-06-21 08:10, hash: ee78c860b8
Worked: n/a

Short description of error
When I delete the hair, the rest of the hair flickers. This doesn't happen when adding hair, changing their length, combing, ...

Note it also happens when deleting hair with the density brush.

Exact steps for others to reproduce the error

  • Open this file and delete some hair.

hair_flicker.blend

Video:

flicker-2022-06-21_14.38.51.mp4

**System Information** Operating system: Linux-5.13.0-48-generic-x86_64-with-glibc2.31 64 Bits Graphics card: NVIDIA GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 510.73.05 **Blender Version** Broken: version: 3.3.0 Alpha, branch: master, commit date: 2022-06-21 08:10, hash: `ee78c860b8` Worked: n/a **Short description of error** When I delete the hair, the rest of the hair flickers. This doesn't happen when adding hair, changing their length, combing, ... Note it also happens when deleting hair with the density brush. **Exact steps for others to reproduce the error** * Open this file and delete some hair. [hair_flicker.blend](https://archive.blender.org/developer/F13212171/hair_flicker.blend) Video: [flicker-2022-06-21_14.38.51.mp4](https://archive.blender.org/developer/F13212174/flicker-2022-06-21_14.38.51.mp4)
Author
Owner

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Author
Owner

Added subscriber: @dfelinto

Added subscriber: @dfelinto
Member

Added subscriber: @HooglyBoogly

Added subscriber: @HooglyBoogly
Member

This happens because the normals and material values are randomized by the curve index.
The proper solution would be using some sort of per-curve id attribute in the shader.
That should be optional though, because it would have a performance cost, and it wouldn't matter for sculpting outside of workbench.

The randomness could also be made optional with a shader uniform. Here's a patch for testing the affect of that: P3119: Turn of workbench curve drawing randomness

diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl
index 04fef8d8b32..4bccd3a970f 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl
@@ -51,34 +51,45 @@ void main()
                               drw_view.viewinv- [x].xyz,
                               drw_view.viewinv- [x].xyz,
                               world_pos,
                               tan,
                               binor,
                               time,
                               thickness,
                               thick_time);
 
   gl_Position = point_world_to_ndc(world_pos);
+  
+  bool USE_RANDOM_NORMAL = false;
+  bool USE_RANDOM_MATERIAL = false;
 
   float hair_rand = integer_noise(hair_get_strand_id());
-  vec3 nor = workbench_hair_random_normal(tan, binor, hair_rand);
+  vec3 nor;
+  if (USE_RANDOM_NORMAL) {
+    nor = workbench_hair_random_normal(tan, binor, hair_rand);
+  }
+  else {
+    nor = workbench_hair_random_normal(tan, binor, 0.0);
+  }
 
   view_clipping_distances(world_pos);
 
   uv_interp = hair_get_customdata_vec2(au);
 
   normal_interp = normalize(normal_world_to_view(nor));
 
   workbench_material_data_get(resource_handle, color_interp, alpha_interp, _roughness, metallic);
 
   if (materialIndex == 0) {
     color_interp = hair_get_customdata_vec3(ac);
   }
 
   /* Hairs have lots of layer and can rapidly become the most prominent surface.
    * So we lower their alpha artificially. */
   alpha_interp *= 0.3;
 
-  workbench_hair_random_material(hair_rand, color_interp, _roughness, metallic);
+  if (USE_RANDOM_MATERIAL) {
+    workbench_hair_random_material(hair_rand, color_interp, _roughness, metallic);
+  }
 
   object_id = int(uint(resource_handle) & 0xFFFFu) + 1;
 }
This happens because the normals and material values are randomized by the curve index. The proper solution would be using some sort of per-curve id attribute in the shader. That should be optional though, because it would have a performance cost, and it wouldn't matter for sculpting outside of workbench. The randomness could also be made optional with a shader uniform. Here's a patch for testing the affect of that: [P3119: Turn of workbench curve drawing randomness](https://archive.blender.org/developer/P3119.txt) ```diff diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl index 04fef8d8b32..4bccd3a970f 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl @@ -51,34 +51,45 @@ void main() drw_view.viewinv- [x].xyz, drw_view.viewinv- [x].xyz, world_pos, tan, binor, time, thickness, thick_time); gl_Position = point_world_to_ndc(world_pos); + + bool USE_RANDOM_NORMAL = false; + bool USE_RANDOM_MATERIAL = false; float hair_rand = integer_noise(hair_get_strand_id()); - vec3 nor = workbench_hair_random_normal(tan, binor, hair_rand); + vec3 nor; + if (USE_RANDOM_NORMAL) { + nor = workbench_hair_random_normal(tan, binor, hair_rand); + } + else { + nor = workbench_hair_random_normal(tan, binor, 0.0); + } view_clipping_distances(world_pos); uv_interp = hair_get_customdata_vec2(au); normal_interp = normalize(normal_world_to_view(nor)); workbench_material_data_get(resource_handle, color_interp, alpha_interp, _roughness, metallic); if (materialIndex == 0) { color_interp = hair_get_customdata_vec3(ac); } /* Hairs have lots of layer and can rapidly become the most prominent surface. * So we lower their alpha artificially. */ alpha_interp *= 0.3; - workbench_hair_random_material(hair_rand, color_interp, _roughness, metallic); + if (USE_RANDOM_MATERIAL) { + workbench_hair_random_material(hair_rand, color_interp, _roughness, metallic); + } object_id = int(uint(resource_handle) & 0xFFFFu) + 1; } ```
Author
Owner

I had to tweak the patch to apply: P3125: Masterwork From Distant Lands

diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl
index 04fef8d8b32..3627be1e2d1 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl
@@ -59,8 +59,18 @@ void main()
 
   gl_Position = point_world_to_ndc(world_pos);
 
+  bool USE_RANDOM_NORMAL = false;
+  bool USE_RANDOM_MATERIAL = false;
+
   float hair_rand = integer_noise(hair_get_strand_id());
-  vec3 nor = workbench_hair_random_normal(tan, binor, hair_rand);
+  vec3 nor;
+
+  if (USE_RANDOM_NORMAL) {
+    nor = workbench_hair_random_normal(tan, binor, hair_rand);
+  }
+  else {
+    nor = workbench_hair_random_normal(tan, binor, 0.0);
+  }
 
   view_clipping_distances(world_pos);
 
@@ -68,7 +78,9 @@ void main()
 
   normal_interp = normalize(normal_world_to_view(nor));
 
-  workbench_material_data_get(resource_handle, color_interp, alpha_interp, _roughness, metallic);
+  if (USE_RANDOM_MATERIAL) {
+    workbench_material_data_get(resource_handle, color_interp, alpha_interp, _roughness, metallic);
+  }
 
   if (materialIndex == 0) {
     color_interp = hair_get_customdata_vec3(ac);

I had to tweak the patch to apply: [P3125: Masterwork From Distant Lands](https://archive.blender.org/developer/P3125.txt) ``` diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl index 04fef8d8b32..3627be1e2d1 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl @@ -59,8 +59,18 @@ void main() gl_Position = point_world_to_ndc(world_pos); + bool USE_RANDOM_NORMAL = false; + bool USE_RANDOM_MATERIAL = false; + float hair_rand = integer_noise(hair_get_strand_id()); - vec3 nor = workbench_hair_random_normal(tan, binor, hair_rand); + vec3 nor; + + if (USE_RANDOM_NORMAL) { + nor = workbench_hair_random_normal(tan, binor, hair_rand); + } + else { + nor = workbench_hair_random_normal(tan, binor, 0.0); + } view_clipping_distances(world_pos); @@ -68,7 +78,9 @@ void main() normal_interp = normalize(normal_world_to_view(nor)); - workbench_material_data_get(resource_handle, color_interp, alpha_interp, _roughness, metallic); + if (USE_RANDOM_MATERIAL) { + workbench_material_data_get(resource_handle, color_interp, alpha_interp, _roughness, metallic); + } if (materialIndex == 0) { color_interp = hair_get_customdata_vec3(ac); ```
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
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#99054
No description provided.