check_splat.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env bash
  2. # Checks the native SOG splat renderer on the base SOG wallpaper (3752541815) with a headless GPU render:
  3. # - the picture comes out at the output's size (the frame buffer object was stuck at 16x17, screenshots were blocks)
  4. # - a sudden pointer zigzag makes the mouse ripple change the picture, and the property turns it off again
  5. # - performance mode draws at half size (its default) and still fills the screenshot
  6. # Usage: tools/check_splat.sh <engine binary> [assets dir] [workshop content dir]
  7. set -euo pipefail
  8. HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  9. BINARY=${1:?engine binary}
  10. ASSETS=${2:-/workspace/SteamLibrary/steamapps/common/wallpaper_engine/assets}
  11. CONTENT=${3:-/workspace/SteamLibrary/steamapps/workshop/content/431960}
  12. ID=${SPLAT_ID:-3752541815}
  13. [ -d "$CONTENT/$ID" ] || { echo "SKIP: wallpaper $ID not in $CONTENT"; exit 0; }
  14. work=$(mktemp -d /tmp/lwe-splat.XXXXXX)
  15. trap 'rm -rf "$work"' EXIT
  16. PATH_ZIGZAG="2.0:0.2,0.5;2.03:0.8,0.5;2.06:0.2,0.5;2.09:0.8,0.5;2.12:0.2,0.5;2.15:0.8,0.5;2.18:0.5,0.5"
  17. shot () { # name delay [property=value ...]
  18. local name=$1 delay=$2; shift 2
  19. local args=()
  20. for property in "$@"; do args+=(--set-property "$property"); done
  21. LWE_HEADLESS_CURSOR_PATH="$PATH_ZIGZAG" HEADLESS_RENDER_SIZE=1280x720 HEADLESS_RENDER_DELAY=$delay \
  22. "$HERE/headless_render.sh" "$BINARY" "$work/$name.png" --assets-dir "$ASSETS" --silent --fps 30 \
  23. "${args[@]}" "$CONTENT/$ID" > "$work/$name.log" 2>&1 || { cat "$work/$name.log"; exit 1; }
  24. }
  25. shot ripple 80 performanceMode=false mouseTrailEnabled=true
  26. shot still 80 performanceMode=false mouseTrailEnabled=false
  27. shot half 80 performanceMode=true mouseTrailEnabled=false
  28. python3 - "$work" <<'PY'
  29. import sys
  30. import numpy as np
  31. from PIL import Image
  32. work = sys.argv[1]
  33. load = lambda name: np.asarray(Image.open(f'{work}/{name}.png').convert('RGB')).astype(int)
  34. ripple, still, half = load('ripple'), load('still'), load('half')
  35. failed = False
  36. if still.mean() < 30:
  37. print(f'FAIL: the picture is almost black (mean {still.mean():.1f}), the output is not the full frame'); failed = True
  38. changed = (np.abs(ripple - still).max(axis=2) > 8).mean() * 100
  39. if changed < 2:
  40. print(f'FAIL: the ripple changed only {changed:.2f}% of the picture'); failed = True
  41. else:
  42. print(f'ok: the ripple changed {changed:.1f}% of the picture')
  43. difference = np.abs(half - still).mean()
  44. if difference == 0 or difference > 25:
  45. print(f'FAIL: performance mode picture differs by {difference:.1f} from the full size one'); failed = True
  46. else:
  47. print(f'ok: performance mode picture differs by {difference:.1f} (half size, stretched)')
  48. sys.exit(1 if failed else 0)
  49. PY