HairStructs.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2026 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #include "ShaderCore.h"
  5. // Prevent including this file multiple times unless we're generating bindings
  6. #if !defined(HAIR_STRUCTS_H) || defined(JPH_SHADER_GENERATE_WRAPPER)
  7. #ifndef JPH_SHADER_GENERATE_WRAPPER
  8. #define HAIR_STRUCTS_H
  9. #endif
  10. JPH_SUPPRESS_WARNING_PUSH
  11. JPH_SUPPRESS_WARNINGS
  12. JPH_SHADER_CONSTANT(int, cHairPerVertexBatch, 64)
  13. JPH_SHADER_CONSTANT(int, cHairPerGridCellBatch, 32)
  14. JPH_SHADER_CONSTANT(int, cHairPerStrandBatch, 32)
  15. JPH_SHADER_CONSTANT(int, cHairPerRenderVertexBatch, 128)
  16. JPH_SHADER_CONSTANT(int, cHairNumSVertexInfluences, 3)
  17. JPH_SHADER_STRUCT_BEGIN(JPH_HairSkinWeight)
  18. JPH_SHADER_STRUCT_MEMBER(JPH_uint, JointIdx)
  19. JPH_SHADER_STRUCT_MEMBER(JPH_float, Weight)
  20. JPH_SHADER_STRUCT_END(JPH_HairSkinWeight)
  21. JPH_SHADER_STRUCT_BEGIN(JPH_HairSkinPoint)
  22. JPH_SHADER_STRUCT_MEMBER(JPH_uint, TriangleIndex) ///< Index of triangle in mScalpVertices to which this skin point is attached
  23. JPH_SHADER_STRUCT_MEMBER(JPH_float, U) ///< Barycentric u coordinate of skin point
  24. JPH_SHADER_STRUCT_MEMBER(JPH_float, V) ///< Barycentric v coordinate of skin point
  25. JPH_SHADER_STRUCT_MEMBER(JPH_uint, ToBishop) ///< Compressed quaternion to rotate the frame defined by the triangle normal and the first edge to the Bishop frame of the first vertex of the strand
  26. JPH_SHADER_STRUCT_END(JPH_HairSkinPoint)
  27. JPH_SHADER_STRUCT_BEGIN(JPH_HairGlobalPoseTransform)
  28. JPH_SHADER_STRUCT_MEMBER(JPH_float3, Position)
  29. JPH_SHADER_STRUCT_MEMBER(JPH_Quat, Rotation)
  30. JPH_SHADER_STRUCT_END(JPH_HairGlobalPoseTransform)
  31. JPH_SHADER_STRUCT_BEGIN(JPH_HairSVertexInfluence)
  32. JPH_SHADER_STRUCT_MEMBER(JPH_uint, VertexIndex) ///< Index in mSimVertices that indicates to which simulated vertex this vertex is attached.
  33. JPH_SHADER_STRUCT_MEMBER(JPH_float3, RelativePosition) ///< Position in local space from the simulated vertex to the render vertex
  34. JPH_SHADER_STRUCT_MEMBER(JPH_float, Weight) ///< Influence weight, 0 = not attached, 1 = fully attached
  35. JPH_SHADER_STRUCT_END(JPH_HairSVertexInfluence)
  36. JPH_SHADER_STRUCT_BEGIN(JPH_HairPosition)
  37. JPH_SHADER_STRUCT_MEMBER(JPH_float3, Position)
  38. JPH_SHADER_STRUCT_MEMBER(JPH_Quat, Rotation)
  39. JPH_SHADER_STRUCT_END(JPH_HairPosition)
  40. JPH_SHADER_STRUCT_BEGIN(JPH_HairVelocity)
  41. JPH_SHADER_STRUCT_MEMBER(JPH_float3, Velocity)
  42. JPH_SHADER_STRUCT_MEMBER(JPH_float3, AngularVelocity)
  43. JPH_SHADER_STRUCT_END(JPH_HairVelocity)
  44. JPH_SHADER_STRUCT_BEGIN(JPH_HairMaterial)
  45. JPH_SHADER_STRUCT_MEMBER(JPH_float4, WorldTransformInfluence)
  46. JPH_SHADER_STRUCT_MEMBER(JPH_float4, GlobalPose)
  47. JPH_SHADER_STRUCT_MEMBER(JPH_float4, SkinGlobalPose)
  48. JPH_SHADER_STRUCT_MEMBER(JPH_float4, GravityFactor)
  49. JPH_SHADER_STRUCT_MEMBER(JPH_float4, HairRadius)
  50. JPH_SHADER_STRUCT_MEMBER(JPH_float4, BendComplianceMultiplier)
  51. JPH_SHADER_STRUCT_MEMBER(JPH_float4, GridVelocityFactor)
  52. JPH_SHADER_STRUCT_MEMBER(JPH_uint, EnableCollision)
  53. JPH_SHADER_STRUCT_MEMBER(JPH_uint, EnableLRA)
  54. JPH_SHADER_STRUCT_MEMBER(JPH_uint, EnableGrid)
  55. JPH_SHADER_STRUCT_MEMBER(JPH_float, Friction)
  56. JPH_SHADER_STRUCT_MEMBER(JPH_float, ExpLinearDampingDeltaTime)
  57. JPH_SHADER_STRUCT_MEMBER(JPH_float, ExpAngularDampingDeltaTime)
  58. JPH_SHADER_STRUCT_MEMBER(JPH_float, BendComplianceInvDeltaTimeSq)
  59. JPH_SHADER_STRUCT_MEMBER(JPH_float, StretchComplianceInvDeltaTimeSq)
  60. JPH_SHADER_STRUCT_MEMBER(JPH_float, GridDensityForceFactor)
  61. JPH_SHADER_STRUCT_MEMBER(JPH_float, InertiaMultiplier)
  62. JPH_SHADER_STRUCT_MEMBER(JPH_float, MaxLinearVelocitySq)
  63. JPH_SHADER_STRUCT_MEMBER(JPH_float, MaxAngularVelocitySq)
  64. JPH_SHADER_STRUCT_END(JPH_HairMaterial)
  65. JPH_SHADER_STRUCT_BEGIN(JPH_HairCollisionPlane)
  66. JPH_SHADER_STRUCT_MEMBER(JPH_Plane, Plane)
  67. JPH_SHADER_STRUCT_MEMBER(JPH_uint, ShapeIndex)
  68. JPH_SHADER_STRUCT_END(JPH_HairCollisionPlane)
  69. JPH_SHADER_STRUCT_BEGIN(JPH_HairCollisionShape)
  70. JPH_SHADER_STRUCT_MEMBER(JPH_float3, CenterOfMass)
  71. JPH_SHADER_STRUCT_MEMBER(JPH_float3, LinearVelocity)
  72. JPH_SHADER_STRUCT_MEMBER(JPH_float3, AngularVelocity)
  73. JPH_SHADER_STRUCT_END(JPH_HairCollisionShape)
  74. // Note: The order was chosen to match the struct between C++ and HLSL.
  75. JPH_SHADER_CONSTANTS_BEGIN(JPH_HairUpdateContext, gContext)
  76. JPH_SHADER_CONSTANTS_MEMBER(JPH_uint, NumStrands)
  77. JPH_SHADER_CONSTANTS_MEMBER(JPH_uint, NumVertices)
  78. JPH_SHADER_CONSTANTS_MEMBER(JPH_uint, NumGridPoints)
  79. JPH_SHADER_CONSTANTS_MEMBER(JPH_uint, NumRenderVertices)
  80. JPH_SHADER_CONSTANTS_MEMBER(JPH_uint3, GridSizeMin2)
  81. JPH_SHADER_CONSTANTS_MEMBER(JPH_float, TwoDivDeltaTime)
  82. JPH_SHADER_CONSTANTS_MEMBER(JPH_float3, GridSizeMin1)
  83. JPH_SHADER_CONSTANTS_MEMBER(JPH_float, DeltaTime)
  84. JPH_SHADER_CONSTANTS_MEMBER(JPH_float3, GridOffset)
  85. JPH_SHADER_CONSTANTS_MEMBER(JPH_float, HalfDeltaTime)
  86. JPH_SHADER_CONSTANTS_MEMBER(JPH_float3, GridScale)
  87. JPH_SHADER_CONSTANTS_MEMBER(JPH_float, InvDeltaTimeSq)
  88. JPH_SHADER_CONSTANTS_MEMBER(JPH_float3, SubStepGravity)
  89. JPH_SHADER_CONSTANTS_MEMBER(JPH_uint, NumSkinVertices)
  90. JPH_SHADER_CONSTANTS_MEMBER(JPH_uint3, GridStride)
  91. JPH_SHADER_CONSTANTS_MEMBER(JPH_uint, NumSkinWeightsPerVertex)
  92. JPH_SHADER_CONSTANTS_MEMBER(JPH_Mat44, DeltaTransform)
  93. JPH_SHADER_CONSTANTS_MEMBER(JPH_Mat44, ScalpToHead)
  94. JPH_SHADER_CONSTANTS_MEMBER(JPH_Quat, DeltaTransformQuat)
  95. JPH_SHADER_CONSTANTS_END(JPH_HairUpdateContext)
  96. // Note: The order was chosen to match the struct between C++ and HLSL.
  97. JPH_SHADER_CONSTANTS_BEGIN(JPH_HairIterationContext, gIterationContext)
  98. JPH_SHADER_CONSTANTS_MEMBER(JPH_float, AccumulatedDeltaTime) ///< = Iteration * DeltaTime
  99. JPH_SHADER_CONSTANTS_MEMBER(JPH_float, IterationFraction) ///< = 1 / (NumIterations - Iteration) or the fraction to apply to get from current to target for this iteration step
  100. JPH_SHADER_CONSTANTS_END(JPH_HairIterationContext)
  101. JPH_SUPPRESS_WARNING_POP
  102. #endif // !defined(HAIR_STRUCTS_H) || defined(JPH_SHADER_GENERATE_WRAPPER)