Giter Club home page Giter Club logo

Comments (15)

qlee01 avatar qlee01 commented on September 26, 2024 2

ok thanks for replay, i understand. I didn't know to modify that script before,but now understand. thanks agian. I would like to ask another question. The character uses abc file to generate a file and attach it to the character, but when the character moves, the hair is not correct and will fly around. I try many parameters settting , but there is no effect, but static objects will ok. thanks

we should not use the Github issues to discuss general use of the library, especially not in a thread with completely different topic, as this will be no help for the developers of the library. Your best bet would be to ask the question on Unity forum.

from com.unity.demoteam.hair.

qlee01 avatar qlee01 commented on September 26, 2024

After more investigation, changing the code to execute in "FixedUpdate" does resolve the issue.
Please, add an option to execute either in (Late)Update or in FixedUpdate, later is absolutely necessary to use the Hair in a Physics based environment.

from com.unity.demoteam.hair.

fingerx avatar fingerx commented on September 26, 2024

@qlee01 thanks job,want to know more detials for fixed this,thanks

from com.unity.demoteam.hair.

qlee01 avatar qlee01 commented on September 26, 2024

@qlee01 thanks job,want to know more detials for fixed this,thanks

can you explain better what you mean? What I describe in this issue is that the Hair does not play nicely if you update the position within FixedUpdate, as the class "HairInstance" does update on LateUpdate. In order to fix this, HairInstance.cs needs to be changed to make it switchable whether the hair gets updated during LateUpdate or FixedUpdate. This is a usual thing in many components / libraries for like animation, cloth, and hair simulation, as in some projects everything is driven by Physics, and in this case updated in FixedUpdate.

from com.unity.demoteam.hair.

fingerx avatar fingerx commented on September 26, 2024

ok thanks for replay, i understand. I didn't know to modify that script before,but now understand. thanks agian.
I would like to ask another question. The character uses abc file to generate a file and attach it to the character, but when the character moves, the hair is not correct and will fly around. I try many parameters settting , but there is no effect, but static objects will ok. thanks

from com.unity.demoteam.hair.

fingerx avatar fingerx commented on September 26, 2024

@qlee01 thanks,I think the unity demoteam ditched the actual users, thanks for the advice

from com.unity.demoteam.hair.

fuglsang avatar fuglsang commented on September 26, 2024

Hi. The hair simulation is stepped [minSteps, maxSteps] for every rendered frame, with the simulation "time step" being defined by the frequency. Currently, if you want to ensure that it steps every visual frame when the simulation frequency is lower than the render frequency, currently you have to set minSteps to 1. This will change in the future.

from com.unity.demoteam.hair.

qlee01 avatar qlee01 commented on September 26, 2024

@fuglsang I actually did set it to 1 already at simulation frequency of 60 Hz; still I get jittery movement. This seems to be more prominent whenever the GPU load gets higher.

from com.unity.demoteam.hair.

fuglsang avatar fuglsang commented on September 26, 2024

@qlee01 Hmm, I see -- that does not sound right. Please post the steps to reproduce this behavior, so I can take a closer look at what is happening there.

from com.unity.demoteam.hair.

qlee01 avatar qlee01 commented on September 26, 2024

@qlee01 Hmm, I see -- that does not sound right. Please post the steps to reproduce this behavior, so I can take a closer look at what is happening there.

This is not easy. In my scenario, this happens all the time, no matter what parameters I choose.
The prerequisites:

  • Moving the hair (by actually moving the transform of the hair). I tried this both synched with my FixedUpdate, and with interpolation in Update, based on rotation and position I got from another transform which is moved with FixedUpdate rate.
  • Have high load on GPU (like 12ms+); on lower loads the jittery is much less, sometimes even completely gone.

I basically tried all thinkable approaches to minimize jitter, but it seems something with position or rotation interpolation seems to be weird inside the Hair package.
I also don't think it is based on collision, but with collision on it can become worse than without.

from com.unity.demoteam.hair.

qlee01 avatar qlee01 commented on September 26, 2024

@fuglsang I had a bit deeper look. Seems the collider are making things much worse. I think it would be good to normalize the collision response by delta time, I added something like this to test it out, and in my case gives better results:

void ApplyCollisionConstraint(inout float3 p)
{
	float3 d = 0.0;
	SolveCollisionConstraint(1.0, p, d);
	p += d * _DT * _CONSTANT_COLLISION_RESPONSE;
}

void ApplyCollisionFrictionConstraint(const float friction, const float3 x0, inout float3 p)
{
	float3 d = 0.0;
	SolveCollisionFrictionConstraint(friction, x0, 1.0, p, d);
	p += d * _DT * _CONSTANT_COLLISION_RESPONSE;
}

EDIT: The constant factor might not be needed, as we can compensate via "collision margin".

from com.unity.demoteam.hair.

qlee01 avatar qlee01 commented on September 26, 2024

@fuglsang I was finally able to resolve all jittery issues, but only by changing the code of HairInstance, and putting an execution order to the meta file.
I would suggest the following easy solution: Offer an "explicit" update mode, where we are able to call the update manually, instead of relying on update happening on "LateUpdate" with no possibility to change the execution order.
This would give highest flexibility, and with this all synchronization issues would be easily solvable without changing the code.

from com.unity.demoteam.hair.

fuglsang avatar fuglsang commented on September 26, 2024

@qlee01 Thanks for the update! I've added an option to let application code explicitly trigger updates/dispatch -- I hope this fits your needs, otherwise please reopen the issue. :)

from com.unity.demoteam.hair.

qlee01 avatar qlee01 commented on September 26, 2024

@fuglsang great, thanks, will test it out asap.

from com.unity.demoteam.hair.

qlee01 avatar qlee01 commented on September 26, 2024

did a test, works as expected. FYI, I still need to add the little change with _DT (delta time) in the constraints compute shader to get rid of artifacts. I guess it's due to the issues with Mesh2SDF producing artifacts on more complex meshes.

I use the new update method like this, hope this is correct (sorry for the formatting, did not find an option for line breaks):

void UpdateHair(float deltaTime) { var cmd = CommandBufferPool.Get(); { if (hairInstance.DispatchUpdate(cmd, CommandBufferExecutionFlags.None, deltaTime)) { Graphics.ExecuteCommandBuffer(cmd); } } CommandBufferPool.Release(cmd); }

from com.unity.demoteam.hair.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.