HairIntegrate.hlsl 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2026 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #include "HairIntegrateBindings.h"
  5. #include "HairCommon.h"
  6. #include "HairIntegrate.h"
  7. JPH_SHADER_FUNCTION_BEGIN(void, main, cHairPerVertexBatch, 1, 1)
  8. JPH_SHADER_PARAM_THREAD_ID(tid)
  9. JPH_SHADER_FUNCTION_END
  10. {
  11. // Check if this is a valid vertex
  12. uint vtx = tid.x + cNumStrands; // Skip the root of each strand, it's fixed
  13. if (vtx >= cNumVertices)
  14. return;
  15. if (IsVertexFixed(gVerticesFixed, vtx))
  16. return;
  17. // Load the material
  18. uint strand_idx = vtx % cNumStrands;
  19. JPH_HairMaterial material = gMaterials[GetStrandMaterialIndex(gStrandMaterialIndex, strand_idx)];
  20. // Load the vertex
  21. float strand_fraction = GetVertexStrandFraction(gStrandFractions, vtx);
  22. JPH_HairPosition pos = gPositions[vtx];
  23. JPH_HairVelocity vel = gVelocities[vtx];
  24. // Update previous position
  25. gPreviousPositions[vtx] = pos;
  26. ApplyGrid(pos, vel, material, strand_fraction);
  27. Integrate(pos, vel, material, strand_fraction);
  28. gPositions[vtx] = pos;
  29. }