Hair Particles Not Adopting The Colour Of The Surface They Are On (when named UVMap node is used) #71532

Closed
opened 2019-11-13 07:47:37 +01:00 by Muhammad Ahmed · 13 comments

System Information
Operating system: Windows 10
Graphics card: AMD Radeon R5 M335

Blender Version
Broken: version: 2.81 (sub 16), branch: master, commit date: 2019-11-12 13:28, hash: 1252577580, type: Release build date: 2019-11-13, 00:02:33
Worked: version: 2.80 (sub 75), branch: master, commit date: 2019-07-29 14:47, hash: f6cb5f5449, type: build date: 2019-07-29, 09:44 AM

Short description of error
Hair particles do not adopt the colour of the portion of the surface they are on. I am using an image texture with 2 colours on a plane, but they are not shaded with the colour of the portion they are on. This is only happening on Eevee. It works fine on cycles. It also works fine on blender 2.80, even on Eevee. This problem is only in blender 2.81. Thank You for reviewing my bug report.

Exact steps for others to reproduce the error
I have attached the blend file, along with two images, one rendered in blender 2.81 which shows the problem, & the other in blender 2.80 which works correctly. Thank You.

Steps:
1- Create a plane
2- Add a material with an Image texture with multiple colours using a UV map, plugged into a principled shader node
3- Add a Hair Particle system
4- Under Render tab of particle system, select the material that was created
5 -Render the Image

Thank You
HairBugDemonstration.blend
Blender 2-80 render.png
Blender 2-81 render.png

**System Information** Operating system: Windows 10 Graphics card: AMD Radeon R5 M335 **Blender Version** Broken: version: 2.81 (sub 16), branch: master, commit date: 2019-11-12 13:28, hash: 125257758007, type: Release build date: 2019-11-13, 00:02:33 Worked: version: 2.80 (sub 75), branch: master, commit date: 2019-07-29 14:47, hash: f6cb5f54494e, type: build date: 2019-07-29, 09:44 AM **Short description of error** Hair particles do not adopt the colour of the portion of the surface they are on. I am using an image texture with 2 colours on a plane, but they are not shaded with the colour of the portion they are on. This is only happening on Eevee. It works fine on cycles. It also works fine on blender 2.80, even on Eevee. This problem is only in blender 2.81. Thank You for reviewing my bug report. **Exact steps for others to reproduce the error** I have attached the blend file, along with two images, one rendered in blender 2.81 which shows the problem, & the other in blender 2.80 which works correctly. Thank You. Steps: 1- Create a plane 2- Add a material with an Image texture with multiple colours using a UV map, plugged into a principled shader node 3- Add a Hair Particle system 4- Under Render tab of particle system, select the material that was created 5 -Render the Image Thank You [HairBugDemonstration.blend](https://archive.blender.org/developer/F8056829/HairBugDemonstration.blend) ![Blender 2-80 render.png](https://archive.blender.org/developer/F8056835/Blender_2-80_render.png) ![Blender 2-81 render.png](https://archive.blender.org/developer/F8056845/Blender_2-81_render.png)
Author

Added subscriber: @awo

Added subscriber: @awo

#72395 was marked as duplicate of this issue

#72395 was marked as duplicate of this issue

#72183 was marked as duplicate of this issue

#72183 was marked as duplicate of this issue
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Confirmed, checking...

Confirmed, checking...
Member

This is an Eevee only problem.
This has to do with the UVMap node.

  • if you use a Texture Coordinate Node (use the UV output) instead it works
  • if you use the UVMap node (without specifiying an actual UV layer -- leave it empty) it also works

checking further...

This is an Eevee only problem. This has to do with the `UVMap` node. - if you use a `Texture Coordinate` Node (use the UV output) instead it works - if you use the UVMap node (without specifiying an actual UV layer -- leave it empty) it also works checking further...
Philipp Oeser self-assigned this 2019-11-14 14:02:35 +01:00
Member

Caused by deb5416a1a, think I can fix.

Caused by deb5416a1a, think I can fix.
Philipp Oeser removed their assignment 2019-11-14 15:02:16 +01:00
Clément Foucault was assigned by Philipp Oeser 2019-11-14 15:02:16 +01:00
Member

Added subscriber: @fclem

Added subscriber: @fclem
Member

@fclem: I thought I was on the right path with the following, but spoke too soon...

P1163: T71532_snippet



diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c
index 3c586e6daec..4b5173a8d17 100644
--- a/source/blender/draw/intern/draw_cache_impl_particles.c
+++ b/source/blender/draw/intern/draw_cache_impl_particles.c
@@ -894,11 +894,13 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit
     GPU_vertbuf_data_alloc(cache->proc_uv_buf- [x], cache->strands_len);
     GPU_vertbuf_attr_get_raw_data(cache->proc_uv_buf- [x], uv_id, &uv_step[i]);
 
-    const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i);
-    uint hash = BLI_ghashutil_strhash_p(name);
+    char attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME];
+    const char *layer_name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i);
+    GPU_vertformat_safe_attrib_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME);
+
     int n = 0;
-    BLI_snprintf(cache->uv_layer_names- [x][n++], MAX_LAYER_NAME_LEN, "u%u", hash);
-    BLI_snprintf(cache->uv_layer_names- [x][n++], MAX_LAYER_NAME_LEN, "a%u", hash);
+    BLI_snprintf(cache->uv_layer_names- [x][n++], MAX_LAYER_NAME_LEN, "u%s", attr_safe_name);
+    BLI_snprintf(cache->uv_layer_names- [x][n++], MAX_LAYER_NAME_LEN, "a%s", attr_safe_name);
 
     if (i == active_uv) {
       BLI_strncpy(cache->uv_layer_names- [x][n++], "au", MAX_LAYER_NAME_LEN);
@@ -913,14 +915,16 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit
     GPU_vertbuf_data_alloc(cache->proc_col_buf- [x], cache->strands_len);
     GPU_vertbuf_attr_get_raw_data(cache->proc_col_buf- [x], col_id, &col_step[i]);
 
-    const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPCOL, i);
-    uint hash = BLI_ghashutil_strhash_p(name);
+    char attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME];
+    const char *layer_name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPCOL, i);
+    GPU_vertformat_safe_attrib_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME);
+
     int n = 0;
-    BLI_snprintf(cache->col_layer_names- [x][n++], MAX_LAYER_NAME_LEN, "c%u", hash);
+    BLI_snprintf(cache->col_layer_names- [x][n++], MAX_LAYER_NAME_LEN, "c%s", attr_safe_name);
 
     /* We only do vcols auto name that are not overridden by uvs */
-    if (CustomData_get_named_layer_index(&psmd->mesh_final->ldata, CD_MLOOPUV, name) == -1) {
-      BLI_snprintf(cache->col_layer_names- [x][n++], MAX_LAYER_NAME_LEN, "a%u", hash);
+    if (CustomData_get_named_layer_index(&psmd->mesh_final->ldata, CD_MLOOPUV, layer_name) == -1) {
+      BLI_snprintf(cache->col_layer_names- [x][n++], MAX_LAYER_NAME_LEN, "a%s", attr_safe_name);
     }
 
     if (i == active_col) {
@@ -1176,23 +1180,26 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit,
     col_id = MEM_mallocN(sizeof(*col_id) * num_col_layers, "Col attr format");
 
     for (int i = 0; i < num_uv_layers; i++) {
-      const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i);
-      char uuid[32];
+      const char *layer_name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i);
+      char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME];
+      GPU_vertformat_safe_attrib_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME);
 
-      BLI_snprintf(uuid, sizeof(uuid), "u%u", BLI_ghashutil_strhash_p(name));
-      uv_id- [x] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+      BLI_snprintf(attr_name, sizeof(attr_name), "u%s", attr_safe_name);
+      uv_id- [x] = GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
 
       if (i == active_uv) {
         GPU_vertformat_alias_add(&format, "u");
       }
     }
 
-    for (int i = 0; i < num_uv_layers; i++) {
-      const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i);
-      char uuid[32];
+    // shouldnt this be vcols?
+    for (int i = 0; i < num_col_layers; i++) {
+      const char *layer_name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPCOL, i);
+      char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME];
+      GPU_vertformat_safe_attrib_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME);
 
-      BLI_snprintf(uuid, sizeof(uuid), "c%u", BLI_ghashutil_strhash_p(name));
-      col_id- [x] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+      BLI_snprintf(attr_name, sizeof(attr_name), "c%s", attr_safe_name);
+      col_id- [x] = GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
 
       if (i == active_col) {
         GPU_vertformat_alias_add(&format, "c");

could you takke over?

@fclem: I thought I was on the right path with the following, but spoke too soon... [P1163: T71532_snippet](https://archive.blender.org/developer/P1163.txt) ``` diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index 3c586e6daec..4b5173a8d17 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -894,11 +894,13 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit GPU_vertbuf_data_alloc(cache->proc_uv_buf- [x], cache->strands_len); GPU_vertbuf_attr_get_raw_data(cache->proc_uv_buf- [x], uv_id, &uv_step[i]); - const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i); - uint hash = BLI_ghashutil_strhash_p(name); + char attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME]; + const char *layer_name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i); + GPU_vertformat_safe_attrib_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME); + int n = 0; - BLI_snprintf(cache->uv_layer_names- [x][n++], MAX_LAYER_NAME_LEN, "u%u", hash); - BLI_snprintf(cache->uv_layer_names- [x][n++], MAX_LAYER_NAME_LEN, "a%u", hash); + BLI_snprintf(cache->uv_layer_names- [x][n++], MAX_LAYER_NAME_LEN, "u%s", attr_safe_name); + BLI_snprintf(cache->uv_layer_names- [x][n++], MAX_LAYER_NAME_LEN, "a%s", attr_safe_name); if (i == active_uv) { BLI_strncpy(cache->uv_layer_names- [x][n++], "au", MAX_LAYER_NAME_LEN); @@ -913,14 +915,16 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit GPU_vertbuf_data_alloc(cache->proc_col_buf- [x], cache->strands_len); GPU_vertbuf_attr_get_raw_data(cache->proc_col_buf- [x], col_id, &col_step[i]); - const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPCOL, i); - uint hash = BLI_ghashutil_strhash_p(name); + char attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME]; + const char *layer_name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPCOL, i); + GPU_vertformat_safe_attrib_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME); + int n = 0; - BLI_snprintf(cache->col_layer_names- [x][n++], MAX_LAYER_NAME_LEN, "c%u", hash); + BLI_snprintf(cache->col_layer_names- [x][n++], MAX_LAYER_NAME_LEN, "c%s", attr_safe_name); /* We only do vcols auto name that are not overridden by uvs */ - if (CustomData_get_named_layer_index(&psmd->mesh_final->ldata, CD_MLOOPUV, name) == -1) { - BLI_snprintf(cache->col_layer_names- [x][n++], MAX_LAYER_NAME_LEN, "a%u", hash); + if (CustomData_get_named_layer_index(&psmd->mesh_final->ldata, CD_MLOOPUV, layer_name) == -1) { + BLI_snprintf(cache->col_layer_names- [x][n++], MAX_LAYER_NAME_LEN, "a%s", attr_safe_name); } if (i == active_col) { @@ -1176,23 +1180,26 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit, col_id = MEM_mallocN(sizeof(*col_id) * num_col_layers, "Col attr format"); for (int i = 0; i < num_uv_layers; i++) { - const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i); - char uuid[32]; + const char *layer_name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i); + char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME]; + GPU_vertformat_safe_attrib_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME); - BLI_snprintf(uuid, sizeof(uuid), "u%u", BLI_ghashutil_strhash_p(name)); - uv_id- [x] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + BLI_snprintf(attr_name, sizeof(attr_name), "u%s", attr_safe_name); + uv_id- [x] = GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (i == active_uv) { GPU_vertformat_alias_add(&format, "u"); } } - for (int i = 0; i < num_uv_layers; i++) { - const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i); - char uuid[32]; + // shouldnt this be vcols? + for (int i = 0; i < num_col_layers; i++) { + const char *layer_name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPCOL, i); + char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME]; + GPU_vertformat_safe_attrib_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME); - BLI_snprintf(uuid, sizeof(uuid), "c%u", BLI_ghashutil_strhash_p(name)); - col_id- [x] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + BLI_snprintf(attr_name, sizeof(attr_name), "c%s", attr_safe_name); + col_id- [x] = GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (i == active_col) { GPU_vertformat_alias_add(&format, "c"); ``` could you takke over?
Philipp Oeser changed title from Hair Particles Not Adopting The Colour Of The Surface They Are On to Hair Particles Not Adopting The Colour Of The Surface They Are On (when named UVMap node is used) 2019-11-14 15:02:53 +01:00
Member

Added subscriber: @rayshin

Added subscriber: @rayshin
Member

Added subscribers: @An_Zi, @mano-wii

Added subscribers: @An_Zi, @mano-wii

This issue was referenced by ba5bbf14f9

This issue was referenced by ba5bbf14f92bfb87d8d42b5e4c68a2b7864c90cf

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' 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#71532
No description provided.