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

Accessing position vertices #40

Closed TumiJourdan closed 1 year ago

TumiJourdan commented 1 year ago

I would like to access the mesh data of the strands in cpu, but I can't seem to find a way forward. I can find the mesh and the mesh filter but no position data.

The closest I have managed is : vertices = hairInstance.strandGroupInstances[0].sceneObjects.strandMeshFilter.mesh.vertices; But this returns an empty array.

Capture

In the above image I can see that the Mesh has no position data. Just 2 UV channels. As far as I know the data exists because of the unique hair node used in shader-graph has a position attribute.

Truly stumped, any suggestions?

fuglsang commented 1 year ago

Hi there,

I can see why this may be confusing. The mesh that you mention (named "X-Lines:[strandGroupIndex]" when rendering lines) indeed does not store any position data, but only topology and metadata used during rendering.

The actual position data of the strands sits elsewhere: Take a look at the SolverData struct (HairSimData.cs) where the various buffers are annotated.