![]() |
Jolt Physics
A multi core friendly Game Physics Engine
|
This class defines the setup of a hair groom, it can be shared between multiple hair instances. More...
#include <HairSettings.h>
Classes | |
| class | Gradient |
| Gradient along a hair strand of a value, e.g. compliance, friction, etc. More... | |
| class | GradientSampler |
| class | GridSampler |
| struct | Material |
| The material determines the simulation parameters for a hair strand. More... | |
| struct | RStrand |
| A hair render strand. More... | |
| struct | RVertex |
| A render vertex. More... | |
| struct | SkinPoint |
| Information about where a hair strand is attached to the scalp mesh. More... | |
| struct | SkinWeight |
| How much a vertex is influenced by a joint. More... | |
| struct | SStrand |
| A hair simulation strand. More... | |
| struct | SVertex |
| A simulated vertex in a hair strand. More... | |
| struct | SVertexInfluence |
| Describes how a render vertex is influenced by a simulated vertex. More... | |
Public Member Functions | |
| void | InitRenderAndSimulationStrands (const Array< SVertex > &inVertices, const Array< SStrand > &inStrands) |
| void | Init (float &outMaxDistSqHairToScalp) |
| void | InitCompute (ComputeSystem *inComputeSystem) |
| Must be called after Init to setup the compute buffers. | |
| float | GetNeutralDensity (uint32 inX, uint32 inY, uint32 inZ) const |
| Sample the neutral density at a grid position. | |
| uint32 | GetNumVerticesPadded () const |
| Get the number of vertices in the vertex buffers padded to a multiple of mMaxVerticesPerStrand. | |
| void | PrepareForScalpSkinning (Mat44Arg inJointToHair, const Mat44 *inJointMatrices, Mat44 *outJointMatrices) const |
| Calculates the pose used for skinning the scalp. | |
| void | SkinScalpVertices (Mat44Arg inJointToHair, const Mat44 *inJointMatrices, Array< Vec3 > &outVertices) const |
| void | SaveBinaryState (StreamOut &inStream) const |
| Saves the state of this object in binary form to inStream. Doesn't store the compute buffers. | |
| void | RestoreBinaryState (StreamIn &inStream) |
| Restore the state of this object from inStream. | |
Public Member Functions inherited from RefTarget< HairSettings > | |
| RefTarget ()=default | |
| Constructor. | |
| RefTarget (const RefTarget &) | |
| ~RefTarget () | |
| assert no one is referencing us | |
| void | SetEmbedded () const |
| RefTarget & | operator= (const RefTarget &) |
| Assignment operator. | |
| uint32 | GetRefCount () const |
| Get current refcount of this object. | |
| void | AddRef () const |
| Add or release a reference to this object. | |
| void | Release () const |
Static Public Member Functions | |
| static void | sResample (Array< SVertex > &ioVertices, Array< SStrand > &ioStrands, uint32 inNumVerticesPerStrand) |
| Resample the hairs to a new fixed number of vertices per strand. Must be called prior to Init if desired. | |
Static Public Member Functions inherited from RefTarget< HairSettings > | |
| static int | sInternalGetRefCountOffset () |
| INTERNAL HELPER FUNCTION USED BY SERIALIZATION. | |
Public Attributes | |
| Array< SVertex > | mSimVertices |
| Simulated vertices. Used by mSimStrands. | |
| Array< SStrand > | mSimStrands |
| Defines the start and end of each simulated strand. | |
| Array< RVertex > | mRenderVertices |
| Rendered vertices. Used by mRenderStrands. | |
| Array< RStrand > | mRenderStrands |
| Defines the start and end of each rendered strand. | |
| Array< Float3 > | mScalpVertices |
| Vertices of the scalp mesh, used to attach hairs. Note that the hair vertices mSimVertices must be in the same space as these vertices. | |
| Array< IndexedTriangleNoMaterial > | mScalpTriangles |
| Triangles of the scalp mesh. | |
| Array< Mat44 > | mScalpInverseBindPose |
| Inverse bind pose of the scalp mesh, joints are in model space. | |
| Array< SkinWeight > | mScalpSkinWeights |
| Skin weights of the scalp mesh, for each vertex we have mScalpNumSkinWeightsPerVertex entries. | |
| uint | mScalpNumSkinWeightsPerVertex = 0 |
| Number of skin weights per vertex. | |
| uint32 | mNumIterationsPerSecond = cDefaultIterationsPerSecond |
| float | mMaxDeltaTime = 1.0f / 30.0f |
| Maximum delta time for the simulation step (to avoid running an excessively long step, note that this will effectively slow down time) | |
| UVec4 | mGridSize { 32, 32, 32, 0 } |
| Number of grid cells used to simulate the hair. W unused. | |
| Vec3 | mSimulationBoundsPadding = Vec3::sReplicate(0.1f) |
| Padding around the simulation bounds to ensure that the grid is large enough and that we detect collisions with the hairs. This is added on all sides after calculating the bounds in the neutral pose. | |
| Vec3 | mInitialGravity { 0, -9.81f, 0 } |
| Initial gravity in local space of the hair, used to calculate the unloaded rest pose. | |
| Array< Material > | mMaterials |
| Materials used by the hair strands. | |
| Array< SkinPoint > | mSkinPoints |
| For each simulated vertex, where it is attached to the scalp mesh. | |
| AABox | mSimulationBounds { Vec3::sZero(), 1.0f } |
| Bounds that the simulation is supposed to fit in. | |
| Array< float > | mNeutralDensity |
| Neutral density grid used to apply forces to keep the hair in place. | |
| float | mDensityScale = 0.0f |
| Highest density value in the neutral density grid, used to scale the density for rendering. | |
| uint32 | mMaxVerticesPerStrand = 0 |
| Maximum number of vertices per strand, used for padding the compute buffers. | |
| Ref< ComputeBuffer > | mScalpVerticesCB |
| Ref< ComputeBuffer > | mScalpTrianglesCB |
| Ref< ComputeBuffer > | mScalpSkinWeightsCB |
| Ref< ComputeBuffer > | mSkinPointsCB |
| Ref< ComputeBuffer > | mVerticesFixedCB |
| Ref< ComputeBuffer > | mVerticesPositionCB |
| Ref< ComputeBuffer > | mVerticesBishopCB |
| Ref< ComputeBuffer > | mVerticesOmega0CB |
| Ref< ComputeBuffer > | mVerticesLengthCB |
| Ref< ComputeBuffer > | mVerticesStrandFractionCB |
| Ref< ComputeBuffer > | mStrandVertexCountsCB |
| Ref< ComputeBuffer > | mStrandMaterialIndexCB |
| Ref< ComputeBuffer > | mNeutralDensityCB |
| Ref< ComputeBuffer > | mSVertexInfluencesCB |
Static Public Attributes | |
| static constexpr uint32 | cNoInfluence = ~uint32(0) |
| static constexpr uint32 | cDefaultIterationsPerSecond = 360 |
Additional Inherited Members | |
Protected Attributes inherited from RefTarget< HairSettings > | |
| atomic< uint32 > | mRefCount |
| Current reference count. | |
Static Protected Attributes inherited from RefTarget< HairSettings > | |
| static constexpr uint32 | cEmbedded |
| A large value that gets added to the refcount to mark the object as embedded. | |
This class defines the setup of a hair groom, it can be shared between multiple hair instances.
Sample the neutral density at a grid position.
|
inline |
Get the number of vertices in the vertex buffers padded to a multiple of mMaxVerticesPerStrand.
| void HairSettings::Init | ( | float & | outMaxDistSqHairToScalp | ) |
Initialize the structure, calculating simulation bounds and vertex properties
| outMaxDistSqHairToScalp | Maximum distance^2 the root vertex of a hair is from the scalp, can be used to check if the hair matched the scalp correctly |
| void HairSettings::InitCompute | ( | ComputeSystem * | inComputeSystem | ) |
Must be called after Init to setup the compute buffers.
| void HairSettings::InitRenderAndSimulationStrands | ( | const Array< SVertex > & | inVertices, |
| const Array< SStrand > & | inStrands ) |
Split the supplied render strands into render and simulation strands and calculate connections between them. When this function returns mSimVertices, mSimStrands, mRenderVertices and mRenderStrands are overwritten.
| inVertices | Vertices for the strands. |
| inStrands | The strands that this instance should have. |
| void HairSettings::PrepareForScalpSkinning | ( | Mat44Arg | inJointToHair, |
| const Mat44 * | inJointMatrices, | ||
| Mat44 * | outJointMatrices ) const |
Calculates the pose used for skinning the scalp.
| inJointToHair | Transform to bring the model space joint matrices to the hair local space |
| inJointMatrices | Model space joint matrices of the joints in the face |
| outJointMatrices | Joint matrices combined with the inverse bind pose |
| void HairSettings::RestoreBinaryState | ( | StreamIn & | inStream | ) |
Restore the state of this object from inStream.
| void HairSettings::SaveBinaryState | ( | StreamOut & | inStream | ) | const |
Saves the state of this object in binary form to inStream. Doesn't store the compute buffers.
| void HairSettings::SkinScalpVertices | ( | Mat44Arg | inJointToHair, |
| const Mat44 * | inJointMatrices, | ||
| Array< Vec3 > & | outVertices ) const |
Skin the scalp mesh to the given joint matrices and output the skinned scalp vertices
| inJointToHair | Transform to bring the model space joint matrices to the hair local space |
| inJointMatrices | Model space joint matrices of the joints in the face |
| outVertices | Returns skinned vertices |
|
static |
Resample the hairs to a new fixed number of vertices per strand. Must be called prior to Init if desired.
|
staticconstexpr |
| float HairSettings::mDensityScale = 0.0f |
Highest density value in the neutral density grid, used to scale the density for rendering.
| UVec4 HairSettings::mGridSize { 32, 32, 32, 0 } |
Number of grid cells used to simulate the hair. W unused.
| Vec3 HairSettings::mInitialGravity { 0, -9.81f, 0 } |
Initial gravity in local space of the hair, used to calculate the unloaded rest pose.
| float HairSettings::mMaxDeltaTime = 1.0f / 30.0f |
Maximum delta time for the simulation step (to avoid running an excessively long step, note that this will effectively slow down time)
| uint32 HairSettings::mMaxVerticesPerStrand = 0 |
Maximum number of vertices per strand, used for padding the compute buffers.
| Array<float> HairSettings::mNeutralDensity |
Neutral density grid used to apply forces to keep the hair in place.
| Ref<ComputeBuffer> HairSettings::mNeutralDensityCB |
| uint32 HairSettings::mNumIterationsPerSecond = cDefaultIterationsPerSecond |
Inverse bind pose of the scalp mesh, joints are in model space.
| uint HairSettings::mScalpNumSkinWeightsPerVertex = 0 |
Number of skin weights per vertex.
| Array<SkinWeight> HairSettings::mScalpSkinWeights |
Skin weights of the scalp mesh, for each vertex we have mScalpNumSkinWeightsPerVertex entries.
| Ref<ComputeBuffer> HairSettings::mScalpSkinWeightsCB |
| Array<IndexedTriangleNoMaterial> HairSettings::mScalpTriangles |
Triangles of the scalp mesh.
| Ref<ComputeBuffer> HairSettings::mScalpTrianglesCB |
Vertices of the scalp mesh, used to attach hairs. Note that the hair vertices mSimVertices must be in the same space as these vertices.
| Ref<ComputeBuffer> HairSettings::mScalpVerticesCB |
| AABox HairSettings::mSimulationBounds { Vec3::sZero(), 1.0f } |
Bounds that the simulation is supposed to fit in.
| Vec3 HairSettings::mSimulationBoundsPadding = Vec3::sReplicate(0.1f) |
Padding around the simulation bounds to ensure that the grid is large enough and that we detect collisions with the hairs. This is added on all sides after calculating the bounds in the neutral pose.
For each simulated vertex, where it is attached to the scalp mesh.
| Ref<ComputeBuffer> HairSettings::mSkinPointsCB |
| Ref<ComputeBuffer> HairSettings::mStrandMaterialIndexCB |
| Ref<ComputeBuffer> HairSettings::mStrandVertexCountsCB |
| Ref<ComputeBuffer> HairSettings::mSVertexInfluencesCB |
| Ref<ComputeBuffer> HairSettings::mVerticesBishopCB |
| Ref<ComputeBuffer> HairSettings::mVerticesFixedCB |
| Ref<ComputeBuffer> HairSettings::mVerticesLengthCB |
| Ref<ComputeBuffer> HairSettings::mVerticesOmega0CB |
| Ref<ComputeBuffer> HairSettings::mVerticesPositionCB |
| Ref<ComputeBuffer> HairSettings::mVerticesStrandFractionCB |