macos_cpu_skinning.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env bash
  2. # DESCRIPTION
  3. # This script corrects most (but not all) model rendering issues on macOS
  4. # (Metal API, MoltenVK) by computing skinned meshes by the CPU instead of GPU.
  5. #
  6. # EXIT STATUS
  7. # 0 : The patch was applied successfully or is not needed by your system.
  8. # other : Patch failure. See stdout or stderr output for details.
  9. #
  10. # AUTHOR
  11. # 3Shain (2023)
  12. if ! [[ $(uname) == "Darwin" ]]; then
  13. echo "You do not need this patch if you are not on macOS."
  14. exit 0
  15. fi
  16. DIR=$(dirname "${BASH_SOURCE[0]}")
  17. DATADIR=$(find . -maxdepth 1 -type d -name "*_Data")
  18. GGM="$DATADIR/globalgamemanagers"
  19. PATTERN="67616d657300000001"
  20. match=$(xxd -p -c 100000000 < "$GGM" | grep -o "$PATTERN")
  21. if [ -z "$match" ]; then
  22. echo "[ERROR] Incompatible file or the patch is already applied."
  23. exit 1
  24. fi
  25. echo "--- Patching globalgamemanagers"
  26. mv -f "$GGM" "$GGM.bak"
  27. # Universal for both CN and OS game builds
  28. xxd -p -c 100000000 < "$GGM.bak" | sed "s/${PATTERN}/67616d657300000000/" | xxd -r -p > "$GGM"
  29. # Done!
  30. echo "==> Patch applied! Enjoy the game."
  31. echo
  32. echo "[NOTICE] Please refrain from sharing this project in public so"
  33. echo " that there can be Linux patches in the future. Thank you."
  34. exit 0