Unity-Technologies / com.unity.demoteam.hair

An integrated solution for authoring / importing / simulating / rendering strand-based hair in Unity.
Other
719 stars 97 forks source link

How to create a colour gradient from the root to the tip of the hair strand? #22

Open DanielaAuroch opened 1 year ago

DanielaAuroch commented 1 year ago

Unity version: 2021.3.8f1 Render Pipeline: HDRP

Hi there, I've been using the hair system and I'm trying to create pieces of hair with three different colours, from the hair root to the tip. Like this: image

However, I've been unsuccessful in creating this effect. The closest I got was the image below, using the hair vertex position, but it's not the effect desired: image

Could you give me some insight on how to achieve the effect I'm looking for? I'm using Shader Graph and this is the graph I currently have: image

qlee01 commented 1 year ago

I managed to do so just using UV1; the x value gives you the 0-1 value per strand.

DanielaAuroch commented 1 year ago

I managed to do so just using UV1; the x value gives you the 0-1 value per strand.

I was always using either strandUV or rootUV and it didn't occur to me to check the other UV channels. Thanks, that worked great :)

qlee01 commented 1 year ago

Yes, not intuitive. Documentation would help a lot.

fuglsang commented 1 year ago

Hi. I will indeed be adding documentation soon (as soon as time allows). Have you tried using "strandUV.y" ? -- this value should be 0 at the root, and 1 at the tip of the longest strand in the particular strand group that the strand is in.

TCKingCeryn commented 1 year ago

Question, I'm relatively new to Shader Graph, but I've got a rough gradient working using the UV1 set, how can i access the strandUV.y value?

DanielaAuroch commented 1 year ago

Question, I'm relatively new to Shader Graph, but I've got a rough gradient working using the UV1 set, how can i access the strandUV.y value?

You can access it by getting the HairVertex node and then splitting the output. strandUV.y should be the "G" value when split. image