HairTeleport.hlsl 779 B

12345678910111213141516171819202122232425262728
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2026 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #include "HairTeleportBindings.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 >= cNumVertices)
  13. return;
  14. // Initialize position based on the initial vertex data
  15. JPH_HairPosition pos;
  16. pos.mPosition = gInitialPositions[vtx];
  17. pos.mRotation = JPH_QuatDecompress(gInitialBishops[vtx]);
  18. gPositions[vtx] = pos;
  19. // Initialize velocity to zero
  20. JPH_HairVelocity vel;
  21. vel.mVelocity = float3(0, 0, 0);
  22. vel.mAngularVelocity = float3(0, 0, 0);
  23. gVelocities[vtx] = vel;
  24. }