Open DanielaAuroch opened 1 year ago
I tried something similar using a texture for the colours and was able to use the rootUV property in Shader Graph. How does your shader work? Is the colour applied to the vertices, or is it generated at the fragment stage? If it's a vertex colour it might be possible to pass it to the fragment stage as a custom interpolator, then use it there.
Thank you, extremely simple and straightforward! This does work for 1 object with 1 material. The final object I'm working with has several materials targeting certain UVs so it doesn't work correctly with this solution. I'll have a think about how I'm approaching things to see if I really need several materials first. If I do still need them, I'll update here, otherwise this is what I was looking for so thanks again 😄
Glad I could help. The package really needs some documentation and demo scenes. I'm worried it's going to be abandoned.
A hair tutorial has been added to Unity Learn. Hopefully this repository will be updated soon.
Labeling as documentation request. :)
(Please let me know if there is a better place for this, as I wasn't able to find a section in the Unity forum for the Hair System). Unity version: 2021.3.8f1 Render Pipeline: HDRP
I have a cube with a texture with different colours, like so:![image](https://user-images.githubusercontent.com/93538914/197543983-d39c7139-a1e0-4657-903f-dbceed7153ea.png)
To this cube, I am applying a Hair Instance component and I give it a material. I would like to colour the hairs according to the coloured sections of the cube. So: white hair on the white sections, light brown hair on the light brown sections.
I have found solutions online that were on C# and used ray casting, but that doesn't seem like a good approach given the immense amount of hair strands that could exist. Nor was I able to find a way to iterate through said strands.
My idea was to do this in shader graph but I'm not sure how to accomplish that.
Another important note is that the cube colours are changed by a shader. So the cube could be any colour and I'd need to pick the colour of each hair strand based on the colour applied to the cube at a certain vertex.![image](https://user-images.githubusercontent.com/93538914/197545401-d4350157-ec3c-4cbf-8842-ea86f22d3654.png)