Posts: 5
Threads: 3
Joined: Apr 2023
Reputation:
0
Hi,
I want to use Obi softbody as an input parameter to create a sound effect. I want to use the deformation factor as one of the controlling parameters. I saw DeformationToColors.cs, and I think it is pretty close to what I want to do with the asset, but I am having a little bit of a hard time understanding how it exactly works. Could you explain or point me to the right documentation location?
So, what I did was add and print this information in the loop of the batch.numIndices in DeformationToColors.cs:
logQueue.Enqueue($"Batch {j}, Constraint {i}, Index {k}, Deformation {deformation}, Norm {norms[p]}, Count {counts[p]}");
and this is what was logged in one of the instances
Batch 5, Constraint 2, Index 3, Deformation 0.0003457069, Norm 0.001275539, Count 5
If you could explain what each of the variables corresponds to and how it helped you achieve the colour indexing of the particles, it would be a great help.
PS: I am assuming this post is cleaner without cluttering it with copying and pasting huge chunks of code from the script. If it is confusing, then please let me know, and I will copy-paste the relevant lines so that you don't need to go back and forth between this post and the original script.
Thank you.
Posts: 6,346
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
07-06-2023, 09:50 AM
(This post was last modified: 07-06-2023, 09:52 AM by josemendez.)
(07-06-2023, 12:45 AM)whatever Wrote: Hi,
I want to use Obi softbody as an input parameter to create a sound effect. I want to use the deformation factor as one of the controlling parameters. I saw DeformationToColors.cs, and I think it is pretty close to what I want to do with the asset, but I am having a little bit of a hard time understanding how it exactly works. Could you explain or point me to the right documentation location?
Hi!
This page explains how constraint data is laid out in Obi:
http://obi.virtualmethodstudio.com/manua...aints.html
And this one explains how constraints work internally, to impose conditions on how the particles move around:
http://obi.virtualmethodstudio.com/manua...gence.html
(07-06-2023, 12:45 AM)whatever Wrote: So, what I did was add and print this information in the loop of the batch.numIndices in DeformationToColors.cs:
logQueue.Enqueue($"Batch {j}, Constraint {i}, Index {k}, Deformation {deformation}, Norm {norms[p]}, Count {counts[p]}");
and this is what was logged in one of the instances
Batch 5, Constraint 2, Index 3, Deformation 0.0003457069, Norm 0.001275539, Count 5
As explained in the above links, constraints are grouped into batches. All constraints in the same batch are guaranteed to not share any particles, which allows for efficient parallelization.
So this data means you're looking at particle #3 in constraint #2 in batch #5, the Frobenius(*) norm of the constraint's deformation matrix is 0.0012, the overall accumulated deformation for that particle is 0.00034, and the amount of constraints that affect that particle so far is 5.
This specific script simply goes over all constraints in the body, and averages the amount of deformation "felt" by each particle as a result of all constraints affecting it. That's why it counts the amount of constraints affecting each particle ("Count", in your log) and accumulates the norm of the matrix into a "Deformation" variable, then it just divides the total deformation by the count to calculate an average, which is then mapped to a color.
kind regards,
(*) Deformation in Obi is stored as a 3x3 matrix, that encodes deformation shape in 3D. Extracting the deformation magnitude from the matrix (that is, how much it deviates from the identity matrix) can be done in a variety of ways, this sample script uses the Frobenius (aka Euclidean) norm which is just the square root of the sum of the squares of all elements in the matrix.
Posts: 5
Threads: 3
Joined: Apr 2023
Reputation:
0
Thank you for your response. It helped a lot. I also went through the codes in more detail. I think I have a better idea of what I want help with.
I want to have mathematical/statistical ways to define deformation of a softbody and use that to make decisions. For example, I want to tell the difference between when it bends sideways or twists around. Like, maybe a sideways bend is a 0.5 and a twist is a 0.2, or something like that.
As I understand, Obi Solver tries to confine the softbodies/ropes/clothes to a certain structure so they are not too deformed that they don't resemble the original self but also has some relaxed constraints so that they are not too rigid. There are different sets of constraints that define this confinement. I believe the calculations done behind the scene to confine the softbody to these constraints might hold the values that I am looking for. Is there a mathematical model that you are basing them on? I know 'Position Based Dynamics' algorithm (Müller et al., 2007) is being used for simulation but does PBD also include definitions for all the constraints used in the obi solver or were other mathematical models also used? Can you please recommend the papers or keywords that can I look for understanding these constraints?
Taking an example of bending constraints, let's take a look at the Execute(int i) function of BurstBendConstraintsBatch.cs. The variables bendVector, bend, constraint, compliance and dLambda are used. Are there any standard definition for those? Do they come from any specific model or paper? If they come from specific models then can you please let me know about them otherwise I would love to learn more about them from you.
Finally, do all of these constraints make sense for softbody. I see in documentation that density and chain are used specifically for fluid and rods. Is density properly defined for Obi Fluid asset only and I need to use it or can I play around with this constraint with softbody and see some effects?
Posts: 6,346
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
12-12-2023, 08:13 AM
(This post was last modified: 12-12-2023, 08:13 AM by josemendez.)
(12-12-2023, 06:42 AM)whatever Wrote: I want to have mathematical/statistical ways to define deformation of a softbody and use that to make decisions. For example, I want to tell the difference between when it bends sideways or twists around. Like, maybe a sideways bend is a 0.5 and a twist is a 0.2, or something like that.
Examining the deformation matrix of each shape matching cluster will give you this information.
Quote:[...] I believe the calculations done behind the scene to confine the softbody to these constraints might hold the values that I am looking for. Is there a mathematical model that you are basing them on?
Yes, we use oriented shape matching constraints:
https://matthias-research.github.io/page...ticles.pdf
(12-12-2023, 06:42 AM)whatever Wrote: I know 'Position Based Dynamics' algorithm (Müller et al., 2007) is being used for simulation but does PBD also include definitions for all the constraints used in the obi solver or were other mathematical models also used? Can you please recommend the papers or keywords that can I look for understanding these constraints?
A comprehensive list of all papers used in Obi is publicly available in our webpage:
http://obi.virtualmethodstudio.com/references.html
(12-12-2023, 06:42 AM)whatever Wrote: Taking an example of bending constraints, let's take a look at the Execute(int i) function of BurstBendConstraintsBatch.cs. The variables bendVector, bend, constraint, compliance and dLambda are used. Are there any standard definition for those? Do they come from any specific model or paper?
Constraint, compliance and lambda are standard values shared by all XPBD constraints. See:
https://matthias-research.github.io/page...s/XPBD.pdf
bendVector and bend are specific to bend constraints:
https://www.researchgate.net/publication...d_Dynamics
(12-12-2023, 06:42 AM)whatever Wrote: Finally, do all of these constraints make sense for softbody. I see in documentation that density and chain are used specifically for fluid and rods. Is density properly defined for Obi Fluid asset only and I need to use it or can I play around with this constraint with softbody and see some effects?
No, not all constraints make sense for all actors. Density only makes sense in the case of fluids, shape matching only makes sense in the case of softbodies, distance only makes sense for cloth and ropes, etc. The description of a very similar, albeit simpler implementation of a unified particle system using PBD can be found here:
https://mmacklin.com/uppfrta_preprint.pdf
kind regards,
Posts: 5
Threads: 3
Joined: Apr 2023
Reputation:
0
13-12-2023, 01:02 AM
(This post was last modified: 13-12-2023, 01:37 AM by whatever.)
(12-12-2023, 08:13 AM)josemendez Wrote: Examining the deformation matrix of each shape matching cluster will give you this information.
Can you please explain what you mean by this? How do I do this?
Thank you for your patience with explaining and sending relevant resources. All of them have been extremely helpful.
Posts: 6,346
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
13-12-2023, 07:56 AM
(This post was last modified: 13-12-2023, 07:58 AM by josemendez.)
(13-12-2023, 01:02 AM)whatever Wrote: Can you please explain what you mean by this? How do I do this?
Thank you for your patience with explaining and sending relevant resources. All of them have been extremely helpful.
Quoting a previous message:
Quote:Deformation in Obi is stored as a 3x3 matrix, that encodes deformation shape in 3D. Extracting the deformation magnitude from the matrix (that is, how much it deviates from the identity matrix) can be done in a variety of ways, this sample script uses the Frobenius (aka Euclidean) norm which is just the square root of the sum of the squares of all elements in the matrix.
Each shape matching cluster stores its deformation in a 3x3 matrix. This matrix can store torsion, skew and stretch of each cluster (see: https://graphics.stanford.edu/courses/cs...muller.pdf), that you can extract by looking at the matrix's values. The deformation gradient sample scene is only interested in "deviation from the identity matrix" so it uses the Frobenius norm to get a single scalar value representing this, but you can use a variety other tools like QR decomposition to extract rotation and skew.
kind regards,
|