HairSkinVertices.hlsl 785 B

1234567891011121314151617181920212223242526
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2026 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #include "HairSkinVerticesBindings.h"
  5. #include "HairCommon.h"
  6. JPH_SHADER_FUNCTION_BEGIN(void, main, cHairPerVertexBatch, 1, 1)
  7. JPH_SHADER_PARAM_THREAD_ID(tid)
  8. JPH_SHADER_FUNCTION_END
  9. {
  10. // Check if this is a valid vertex
  11. uint vtx = tid.x;
  12. if (vtx >= cNumSkinVertices)
  13. return;
  14. // Skin the vertex
  15. float3 v = float3(0, 0, 0);
  16. for (uint w = vtx * cNumSkinWeightsPerVertex, w_end = w + cNumSkinWeightsPerVertex; w < w_end; ++w)
  17. {
  18. JPH_HairSkinWeight sw = gScalpSkinWeights[w];
  19. if (sw.mWeight > 0.0f)
  20. v += sw.mWeight * JPH_Mat44Mul3x4Vec3(gScalpJointMatrices[sw.mJointIdx], gScalpVertices[vtx]);
  21. }
  22. gScalpVerticesOut[vtx] = v;
  23. }