From bdb9e130bcd8b1ce5f07b66c1e8b413648275d7e Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 19 Jul 2023 11:56:34 +0200 Subject: [PATCH 01/15] [godot] Add mono flag to 4.x build. --- spine-godot/build/build-v4.sh | 43 ++++++++++++++++++++++++++++------- spine-godot/build/setup.sh | 31 +++++++++++++++++++++---- 2 files changed, 61 insertions(+), 13 deletions(-) diff --git a/spine-godot/build/build-v4.sh b/spine-godot/build/build-v4.sh index ef967d5c4..a39230f32 100755 --- a/spine-godot/build/build-v4.sh +++ b/spine-godot/build/build-v4.sh @@ -11,6 +11,26 @@ fi target="" dev="false" +mono="false" + +if [ $# -gt 0 ]; then + if [ $# -gt 1 ]; then + echo "Usage: $0 [mono:true|false]" + exit 1 + else + if [ "$1" == "true" ] || [ "$1" == "false" ]; then + mono="$1" + else + echo "Invalid value for the 'mono' argument. It should be either 'true' or 'false'." + exit 1 + fi + fi +fi + +if [ -f "../godot/custom.py" ]; then + dev="true" +fi + if [ -f "../godot/custom.py" ]; then dev="true" fi @@ -26,16 +46,23 @@ fi echo "CPUS: $cpus" +mono_module="" +mono_extension="" +if [ $mono = "true" ]; then + mono_module="module_mono_enabled=yes" + mono_extension=".mono" +fi + pushd ../godot -if [ `uname` == 'Darwin' ] && [ $dev = "false" ]; then - scons $target arch=x86_64 compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus - scons $target arch=arm64 compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus +if [ `uname` == 'Darwin' ] && [ $dev = "false" ]; then + scons $target $mono_module arch=x86_64 compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus + scons $target $mono_module arch=arm64 compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus pushd bin cp -r ../misc/dist/macos_tools.app . mv macos_tools.app Godot.app mkdir -p Godot.app/Contents/MacOS - lipo -create godot.macos.editor.arm64 godot.macos.editor.x86_64 -output Godot + lipo -create godot.macos.editor.arm64$mono_extension godot.macos.editor.x86_64$mono_extension -output Godot strip -S -x Godot cp Godot Godot.app/Contents/MacOS/Godot chmod +x Godot.app/Contents/MacOS/Godot @@ -47,11 +74,11 @@ else if [ "$dev" = "true" ]; then target="$target dev_build=true" fi - scons $target compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus + scons $target $mono_module compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus cp compile_commands.json ../build - if [ -f "bin/godot.linuxbsd.editor.x86_64" ]; then - strip bin/godot.linuxbsd.editor.x86_64 - chmod a+x bin/godot.linuxbsd.editor.x86_64 + if [ -f "bin/godot.linuxbsd.editor.x86_64$mono_extension" ]; then + strip bin/godot.linuxbsd.editor.x86_64$mono_extension + chmod a+x bin/godot.linuxbsd.editor.x86_64$mono_extension fi fi popd diff --git a/spine-godot/build/setup.sh b/spine-godot/build/setup.sh index a48f1a8a4..07be7f114 100755 --- a/spine-godot/build/setup.sh +++ b/spine-godot/build/setup.sh @@ -4,18 +4,36 @@ set -e dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" pushd "$dir" > /dev/null -if [ ! "$#" -eq 2 ]; then - echo "Usage: ./setup.sh " +if [ $# -lt 2 ] || [ $# -gt 3 ]; then + echo "Usage: ./setup.sh [mono:true|false]?" echo echo "e.g.:" - echo " ./setup.sh 3.4.4-stable true" - echo " ./setup.sh master false" - echo + echo " ./setup.sh 3.5.2-stable true" + echo " ./setup.sh master false true" + echo + echo "Note: the 'mono' parameter only works for Godot 4.x+!" + exit 1 fi branch=${1%/} dev=${2%/} +mono=false + +if [[ $# -eq 3 && "$branch" != 3* ]]; then + mono=${3%/} +fi + +if [ "$dev" != "true" ] && [ "$dev" != "false" ]; then + echo "Invalid value for the 'dev' argument. It should be either 'true' or 'false'." + exit 1 +fi + +if [ "$mono" != "true" ] && [ "$mono" != "false" ]; then + echo "Invalid value for the 'mono' argument. It should be either 'true' or 'false'." + exit 1 +fi + pushd .. rm -rf godot @@ -23,6 +41,9 @@ git clone --depth 1 https://github.com/godotengine/godot.git -b $branch if [ $dev = "true" ]; then cp -r .idea godot cp build/custom.py godot + if [ "$mono" = "true" ]; then + echo "module_mono_enabled=\"yes\"" >> godot/custom.py + fi cp ../formatters/.clang-format . rm -rf example/.import rm -rf example/.godot From e525c77d18c7a56feeabf3222945c303a1819f23 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 19 Jul 2023 17:53:01 +0200 Subject: [PATCH 02/15] [godot] Rework v4 build scripts to support optionally support C#. --- .gitignore | 3 +- spine-godot/.vscode/launch.json | 25 +++++++++++++ spine-godot/build/build-v4.sh | 63 ++++++++++++++++++++++----------- spine-godot/build/setup.sh | 1 + 4 files changed, 71 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 3ddffea7b..eedd7120e 100644 --- a/.gitignore +++ b/.gitignore @@ -187,4 +187,5 @@ spine-godot/build/compile_commands.json spine-flutter/ios/Classes/spine-cpp spine-flutter/macos/Classes/spine-cpp -spine-flutter/src/spine-cpp \ No newline at end of file +spine-flutter/src/spine-cpp +spine-godot/godot-nuget diff --git a/spine-godot/.vscode/launch.json b/spine-godot/.vscode/launch.json index 20f2e0b0d..f89c19e2a 100644 --- a/spine-godot/.vscode/launch.json +++ b/spine-godot/.vscode/launch.json @@ -54,6 +54,31 @@ "program": "${workspaceFolder}/godot/bin/godot.macos.editor.dev.arm64", }, }, + { + "type": "cppvsdbg", + "request": "launch", + "name": "debug editor v4 c#", + "program": "godot/bin/godot.windows.editor.dev.x86_64.mono.exe", + "args": [ + "-e", + "--path", + "example-v4", + ], + "cwd": "${workspaceFolder}", + "preLaunchTask": "build-v4", + "linux": { + "type": "lldb", + "request": "launch", + "name": "debug editor v4", + "program": "${workspaceFolder}/godot/bin/godot.linux.editor.dev.x86_64", + }, + "osx": { + "type": "lldb", + "request": "launch", + "name": "debug editor v4", + "program": "${workspaceFolder}/godot/bin/godot.macos.editor.dev.arm64.mono", + }, + }, { "type": "cppvsdbg", "request": "launch", diff --git a/spine-godot/build/build-v4.sh b/spine-godot/build/build-v4.sh index a39230f32..8d7e30eb4 100755 --- a/spine-godot/build/build-v4.sh +++ b/spine-godot/build/build-v4.sh @@ -35,17 +35,6 @@ if [ -f "../godot/custom.py" ]; then dev="true" fi -cpus=2 -if [ "$OSTYPE" = "msys" ]; then - cpus=$NUMBER_OF_PROCESSORS -elif [[ "$OSTYPE" = "darwin"* ]]; then - cpus=$(sysctl -n hw.logicalcpu) -else - cpus=$(grep -c ^processor /proc/cpuinfo) -fi - -echo "CPUS: $cpus" - mono_module="" mono_extension="" if [ $mono = "true" ]; then @@ -53,28 +42,62 @@ if [ $mono = "true" ]; then mono_extension=".mono" fi +dev_extension="" +if [ $dev = "true" ]; then + dev_extension=".dev" + target="$target dev_build=true" +fi + +cpus=2 +if [ "$OSTYPE" = "msys" ]; then + os="windows" + cpus=$NUMBER_OF_PROCESSORS + target="vsproj=yes livepp=$LIVEPP" + godot_exe="godot.windows.editor$dev_extension.x86_64$mono_extension.exe" + godot_exe_host=$godot_exe +elif [[ "$OSTYPE" = "darwin"* ]]; then + os="macos" + cpus=$(sysctl -n hw.logicalcpu) + godot_exe="godot.macos.editor$dev_extension.x86_64$mono_extension" + godot_exe_arm="godot.macos.editor$dev_extension.arm64$mono_extension" + godot_exe_host=$godot_exe + if [ `uname -m` == "arm64" ]; then + godot_exe_host=$godot_exe_arm + fi +else + os="linux" + cpus=$(grep -c ^processor /proc/cpuinfo) + godot_exe="godot.linux.editor$dev_extension.x86_64$mono_extension" + godot_exe_host=$godot_exe +fi + +echo "CPUS: $cpus" + pushd ../godot -if [ `uname` == 'Darwin' ] && [ $dev = "false" ]; then +if [ "$os" = "macos" ] && [ $dev = "false" ]; then scons $target $mono_module arch=x86_64 compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus scons $target $mono_module arch=arm64 compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus - + if [ $mono = "true" ]; then + echo "Building C# glue and assemblies." + "./bin/$godot_exe_host" --generate-mono-glue modules/mono/glue + ./modules/mono/build_scripts/build_assemblies.py --godot-output-dir ./bin --push-nupkgs-local ../godot-nuget + fi pushd bin cp -r ../misc/dist/macos_tools.app . mv macos_tools.app Godot.app mkdir -p Godot.app/Contents/MacOS - lipo -create godot.macos.editor.arm64$mono_extension godot.macos.editor.x86_64$mono_extension -output Godot + lipo -create $godot_exe_arm $godot_exe -output Godot strip -S -x Godot cp Godot Godot.app/Contents/MacOS/Godot chmod +x Godot.app/Contents/MacOS/Godot popd else - if [ "$OSTYPE" = "msys" ]; then - target="vsproj=yes livepp=$LIVEPP" - fi - if [ "$dev" = "true" ]; then - target="$target dev_build=true" - fi scons $target $mono_module compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus + if [ $mono = "true" ]; then + echo "Building C# glue and assemblies." + "./bin/$godot_exe_host" --generate-mono-glue modules/mono/glue + ./modules/mono/build_scripts/build_assemblies.py --godot-output-dir ./bin --push-nupkgs-local ../godot-nuget + fi cp compile_commands.json ../build if [ -f "bin/godot.linuxbsd.editor.x86_64$mono_extension" ]; then strip bin/godot.linuxbsd.editor.x86_64$mono_extension diff --git a/spine-godot/build/setup.sh b/spine-godot/build/setup.sh index 07be7f114..8b04c1197 100755 --- a/spine-godot/build/setup.sh +++ b/spine-godot/build/setup.sh @@ -42,6 +42,7 @@ if [ $dev = "true" ]; then cp -r .idea godot cp build/custom.py godot if [ "$mono" = "true" ]; then + echo "" >> godot/custom.py echo "module_mono_enabled=\"yes\"" >> godot/custom.py fi cp ../formatters/.clang-format . From 157b9383b0bc27180d540fe8659f4777143cbff1 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 19 Jul 2023 18:21:37 +0200 Subject: [PATCH 03/15] [godot] Fix macOS build, add assemblies to .app. --- spine-godot/build/build-v4.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/spine-godot/build/build-v4.sh b/spine-godot/build/build-v4.sh index 8d7e30eb4..4ebc5f28a 100755 --- a/spine-godot/build/build-v4.sh +++ b/spine-godot/build/build-v4.sh @@ -37,25 +37,28 @@ fi mono_module="" mono_extension="" -if [ $mono = "true" ]; then +if [ $mono == "true" ]; then mono_module="module_mono_enabled=yes" mono_extension=".mono" + echo "Building Godot with C# support" +else + echo "Building Godot without C# support" fi dev_extension="" -if [ $dev = "true" ]; then +if [ $dev == "true" ]; then dev_extension=".dev" target="$target dev_build=true" fi cpus=2 -if [ "$OSTYPE" = "msys" ]; then +if [ "$OSTYPE" == "msys" ]; then os="windows" cpus=$NUMBER_OF_PROCESSORS target="vsproj=yes livepp=$LIVEPP" godot_exe="godot.windows.editor$dev_extension.x86_64$mono_extension.exe" godot_exe_host=$godot_exe -elif [[ "$OSTYPE" = "darwin"* ]]; then +elif [[ "$OSTYPE" == "darwin"* ]]; then os="macos" cpus=$(sysctl -n hw.logicalcpu) godot_exe="godot.macos.editor$dev_extension.x86_64$mono_extension" @@ -74,10 +77,10 @@ fi echo "CPUS: $cpus" pushd ../godot -if [ "$os" = "macos" ] && [ $dev = "false" ]; then +if [ "$os" == "macos" ] && [ $dev == "false" ]; then scons $target $mono_module arch=x86_64 compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus scons $target $mono_module arch=arm64 compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus - if [ $mono = "true" ]; then + if [ $mono == "true" ]; then echo "Building C# glue and assemblies." "./bin/$godot_exe_host" --generate-mono-glue modules/mono/glue ./modules/mono/build_scripts/build_assemblies.py --godot-output-dir ./bin --push-nupkgs-local ../godot-nuget @@ -90,10 +93,13 @@ if [ "$os" = "macos" ] && [ $dev = "false" ]; then strip -S -x Godot cp Godot Godot.app/Contents/MacOS/Godot chmod +x Godot.app/Contents/MacOS/Godot + if [ $mono == "true" ]; then + cp -r GodotSharp Godot.app/Contents/Resources + fi popd else scons $target $mono_module compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus - if [ $mono = "true" ]; then + if [ $mono == "true" ]; then echo "Building C# glue and assemblies." "./bin/$godot_exe_host" --generate-mono-glue modules/mono/glue ./modules/mono/build_scripts/build_assemblies.py --godot-output-dir ./bin --push-nupkgs-local ../godot-nuget From b405686823fcd00fbc7d06580a5f8e805309f921 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Fri, 21 Jul 2023 14:42:45 +0200 Subject: [PATCH 04/15] [godot] More C# build work. --- .gitignore | 1 + spine-godot/build/build-templates-v4.sh | 74 ++++++++++++++++--------- spine-godot/build/build-v4.sh | 4 +- spine-godot/build/setup.sh | 2 +- 4 files changed, 52 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index eedd7120e..d3329027d 100644 --- a/.gitignore +++ b/.gitignore @@ -189,3 +189,4 @@ spine-flutter/ios/Classes/spine-cpp spine-flutter/macos/Classes/spine-cpp spine-flutter/src/spine-cpp spine-godot/godot-nuget +spine-godot/godot-spine-csharp diff --git a/spine-godot/build/build-templates-v4.sh b/spine-godot/build/build-templates-v4.sh index 8db8a8fed..cca85a79a 100755 --- a/spine-godot/build/build-templates-v4.sh +++ b/spine-godot/build/build-templates-v4.sh @@ -4,8 +4,8 @@ set -e dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" pushd "$dir" > /dev/null -if [ ! "$#" -eq 1 ]; then - echo "Usage: ./build-templates.sh " +if [ "$#" -lt 1 ]; then + echo "Usage: ./build-templates.sh ?" echo echo "e.g.:" echo " ./build-templates.sh windows" @@ -14,7 +14,7 @@ if [ ! "$#" -eq 1 ]; then echo " ./build-templates.sh ios" echo " ./build-templates.sh android" echo " ./build-templates.sh web" - echo + echo exit 1 fi @@ -24,6 +24,28 @@ if [ ! -d ../godot ]; then fi platform=${1%/} +mono=false + +if [[ $# -eq 2 ]]; then + mono=${2%/} + if [ "$platform" != "windows" ] && [ "$platform" != "linux" ] && [ "$platform" != "macos" ]; then + echo "C# is only supported for Windows, Linux, and macOS" + exit 1 + fi + echo "Building Godot template with C# support" +else + echo "Building Godot template without C# support" +fi + +mono_module="" +mono_extension="" +if [ $mono == "true" ]; then + mono_module="module_mono_enabled=yes" + mono_extension=".mono" + echo "Building Godot with C# support" +else + echo "Building Godot without C# support" +fi cpus=2 if [ "$OSTYPE" = "msys" ]; then @@ -38,10 +60,10 @@ pushd ../godot if [ "$platform" = "windows" ]; then # --- Windows --- #generates windows_64_debug.exe and windows_64_release.exe - scons platform=windows tools=no target=template_release custom_modules="../spine_godot" --jobs=$cpus - scons platform=windows tools=no target=template_debug custom_modules="../spine_godot" --jobs=$cpus - cp bin/godot.windows.template_release.x86_64.exe bin/windows_release_x86_64.exe - cp bin/godot.windows.template_debug.x86_64.exe bin/windows_debug_x86_64.exe + scons platform=windows tools=no target=template_release custom_modules="../spine_godot" $mono_module --jobs=$cpus + scons platform=windows tools=no target=template_debug custom_modules="../spine_godot" $mono_module --jobs=$cpus + cp bin/godot.windows.template_release.x86_64$mono_extension.exe bin/windows_release_x86_64.exe + cp bin/godot.windows.template_debug.x86_64$mono_extension.exe bin/windows_debug_x86_64.exe elif [ "$platform" = "macos" ]; then # --- macOS --- @@ -51,8 +73,8 @@ elif [ "$platform" = "macos" ]; then scons platform=macos tools=no target=template_debug arch=x86_64 custom_modules="../spine_godot" --jobs=$cpus scons platform=macos tools=no target=template_release arch=arm64 custom_modules="../spine_godot" --jobs=$cpus scons platform=macos tools=no target=template_debug arch=arm64 custom_modules="../spine_godot" --jobs=$cpus - lipo -create bin/godot.macos.template_release.x86_64 bin/godot.macos.template_release.arm64 -output bin/godot.macos.universal - lipo -create bin/godot.macos.template_debug.x86_64 bin/godot.macos.template_debug.arm64 -output bin/godot.macos.debug.universal + lipo -create "bin/godot.macos.template_release.x86_64$mono_extension" "bin/godot.macos.template_release.arm64$mono_extension" -output bin/godot.macos.universal + lipo -create "bin/godot.macos.template_debug.x86_64$mono_extension" "bin/godot.macos.template_debug.arm64$mono_extension" -output bin/godot.macos.debug.universal strip -S -x bin/godot.macos.universal pushd bin @@ -60,10 +82,21 @@ elif [ "$platform" = "macos" ]; then mkdir -p macos_template.app/Contents/MacOS cp godot.macos.universal macos_template.app/Contents/MacOS/godot_macos_release.universal cp godot.macos.debug.universal macos_template.app/Contents/MacOS/godot_macos_debug.universal - chmod +x macos_template.app/Contents/MacOS/godot_macos* + chmod +x macos_template.app/Contents/MacOS/godot_macos* rm -rf macos.zip zip -q -9 -r macos.zip macos_template.app popd +elif [ "$platform" = "linux" ]; then + # --- Linux --- + # generates linux_x11_64_release, linux_x11_64_debug + scons platform=linuxbsd tools=no target=template_release bits=64 custom_modules="../spine_godot" --jobs=$cpus + scons platform=linuxbsd tools=no target=template_debug bits=64 custom_modules="../spine_godot" --jobs=$cpus + strip bin/godot.linuxbsd.template_release.x86_64$mono_extension + strip bin/godot.linuxbsd.template_debug.x86_64$mono_extension + chmod a+x bin/godot.linuxbsd.template_release.x86_64$mono_extension + chmod a+x bin/godot.linuxbsd.template_debug.x86_64$mono_extension + cp bin/godot.linuxbsd.template_release.x86_64$mono_extension bin/linux_release.x86_64 + cp bin/godot.linuxbsd.template_debug.x86_64$mono_extension bin/linux_debug.x86_64 elif [ "$platform" = "ios" ]; then # --- iOS -- # generates ios.zip @@ -77,19 +110,19 @@ elif [ "$platform" = "ios" ]; then lipo -create bin/libgodot.ios.template_release.arm64.simulator.a bin/libgodot.ios.template_release.x86_64.simulator.a -output bin/libgodot.ios.template_release.simulator.a lipo -create bin/libgodot.ios.template_debug.arm64.simulator.a bin/libgodot.ios.template_debug.x86_64.simulator.a -output bin/libgodot.ios.template_debug.simulator.a strip -S -x bin/libgodot.ios.template_release.arm64.a - strip -S -x bin/libgodot.ios.template_release.simulator.a + strip -S -x bin/libgodot.ios.template_release.simulator.a pushd bin - cp -r ../misc/dist/ios_xcode . + cp -r ../misc/dist/ios_xcode . cp libgodot.ios.template_release.arm64.a ios_xcode/libgodot.ios.release.xcframework/ios-arm64/libgodot.a - cp libgodot.ios.template_release.simulator.a ios_xcode/libgodot.ios.release.xcframework/ios-arm64_x86_64-simulator/libgodot.a + cp libgodot.ios.template_release.simulator.a ios_xcode/libgodot.ios.release.xcframework/ios-arm64_x86_64-simulator/libgodot.a cp libgodot.ios.template_debug.arm64.a ios_xcode/libgodot.ios.debug.xcframework/ios-arm64/libgodot.a - cp libgodot.ios.template_debug.simulator.a ios_xcode/libgodot.ios.debug.xcframework/ios-arm64_x86_64-simulator/libgodot.a + cp libgodot.ios.template_debug.simulator.a ios_xcode/libgodot.ios.debug.xcframework/ios-arm64_x86_64-simulator/libgodot.a rm -rf ios.zip pushd ios_xcode zip -q -9 -r ../ios.zip * popd - popd + popd elif [ "$platform" = "web" ]; then # --- WEB --- # generates webassembly_debug.zip, webassembly_release.zip @@ -109,17 +142,6 @@ elif [ "$platform" = "android" ]; then chmod a+x gradlew ./gradlew generateGodotTemplates popd -elif [ "$platform" = "linux" ]; then - # --- Linux --- - # generates linux_x11_64_release, linux_x11_64_debug - scons platform=linuxbsd tools=no target=template_release bits=64 custom_modules="../spine_godot" --jobs=$cpus - scons platform=linuxbsd tools=no target=template_debug bits=64 custom_modules="../spine_godot" --jobs=$cpus - strip bin/godot.linuxbsd.template_release.x86_64 - strip bin/godot.linuxbsd.template_debug.x86_64 - chmod a+x bin/godot.linuxbsd.template_release.x86_64 - chmod a+x bin/godot.linuxbsd.template_debug.x86_64 - cp bin/godot.linuxbsd.template_release.x86_64 bin/linux_x11_64_release - cp bin/godot.linuxbsd.template_debug.x86_64 bin/linux_x11_64_debug else echo "Unknown platform: $platform" exit 1 diff --git a/spine-godot/build/build-v4.sh b/spine-godot/build/build-v4.sh index 4ebc5f28a..cff73b584 100755 --- a/spine-godot/build/build-v4.sh +++ b/spine-godot/build/build-v4.sh @@ -15,7 +15,7 @@ mono="false" if [ $# -gt 0 ]; then if [ $# -gt 1 ]; then - echo "Usage: $0 [mono:true|false]" + echo "Usage: $0 " exit 1 else if [ "$1" == "true" ] || [ "$1" == "false" ]; then @@ -83,7 +83,7 @@ if [ "$os" == "macos" ] && [ $dev == "false" ]; then if [ $mono == "true" ]; then echo "Building C# glue and assemblies." "./bin/$godot_exe_host" --generate-mono-glue modules/mono/glue - ./modules/mono/build_scripts/build_assemblies.py --godot-output-dir ./bin --push-nupkgs-local ../godot-nuget + ./modules/mono/build_scripts/build_assemblies.py --godot-output-dir ./bin --push-nupkgs-local ../godot-spine-csharp fi pushd bin cp -r ../misc/dist/macos_tools.app . diff --git a/spine-godot/build/setup.sh b/spine-godot/build/setup.sh index 8b04c1197..8bc49da87 100755 --- a/spine-godot/build/setup.sh +++ b/spine-godot/build/setup.sh @@ -5,7 +5,7 @@ dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" pushd "$dir" > /dev/null if [ $# -lt 2 ] || [ $# -gt 3 ]; then - echo "Usage: ./setup.sh [mono:true|false]?" + echo "Usage: ./setup.sh ?" echo echo "e.g.:" echo " ./setup.sh 3.5.2-stable true" From 49e901fd4a6956b3738f51af8ebb9fe4dd3664ec Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Fri, 21 Jul 2023 15:32:51 +0200 Subject: [PATCH 05/15] [godot] Unify 4.x builds into a single workflow, with an orchestrating workflow in spine-godot-v4-all.yml --- .github/workflows/spine-godot-v4-all.yml | 25 ++ .github/workflows/spine-godot-v4.1.yml | 368 ----------------------- .github/workflows/spine-godot-v4.yml | 24 +- 3 files changed, 40 insertions(+), 377 deletions(-) create mode 100644 .github/workflows/spine-godot-v4-all.yml delete mode 100644 .github/workflows/spine-godot-v4.1.yml diff --git a/.github/workflows/spine-godot-v4-all.yml b/.github/workflows/spine-godot-v4-all.yml new file mode 100644 index 000000000..889c643b3 --- /dev/null +++ b/.github/workflows/spine-godot-v4-all.yml @@ -0,0 +1,25 @@ +name: Build all Godot 4.x versions + +on: + push: + paths: + - ".github/workflows/spine-godot.yml" + - 'spine-godot/**' + - 'spine-cpp/**' + workflow_dispatch: + +jobs: + build-versions: + strategy: + matrix: + version: + [ + {"tag": "4.0-stable", "version": "4.0.stable", "mono": false}, + {"tag": "4.1-stable", "version": "4.1.stable", "mono": false}, + ] + uses: ./.github/workflows/spine-godot-v4.yml + with: + godot_tag: ${{ matrix.version.tag }} + godot_version: ${{ matrix.version.version }} + godot_mono: ${{ matrix.version.mono }} + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/spine-godot-v4.1.yml b/.github/workflows/spine-godot-v4.1.yml deleted file mode 100644 index df4f069a8..000000000 --- a/.github/workflows/spine-godot-v4.1.yml +++ /dev/null @@ -1,368 +0,0 @@ -name: Build and Publish Godot 4.1 editor and templates - -on: - push: - paths: - - ".github/workflows/spine-godot.yml" - - 'spine-godot/**' - - 'spine-cpp/**' - workflow_dispatch: - -env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_EC2_METADATA_DISABLED: true - EM_VERSION: 3.1.18 - GODOT_TAG: 4.1-stable - GODOT_VERSION: 4.1.stable - -jobs: - - godot-editor-windows: - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup python and scons - uses: ./.github/actions/setup-godot-deps - - - name: Build Godot artifact - shell: bash - run: | - ./spine-godot/build/setup.sh $GODOT_TAG false - ./spine-godot/build/build-v4.sh - - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: godot-editor-windows.zip - path: spine-godot/godot/bin/godot.windows.editor.x86_64.exe - - godot-editor-linux: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup python and scons - uses: ./.github/actions/setup-godot-deps - - - name: Build Godot artifact - shell: bash - run: | - sudo apt-get update - sudo apt-get install build-essential scons pkg-config libx11-dev libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libudev-dev libxi-dev libxrandr-dev - ./spine-godot/build/setup.sh $GODOT_TAG false - ./spine-godot/build/build-v4.sh - - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: godot-editor-linux.zip - path: spine-godot/godot/bin/godot.linuxbsd.editor.x86_64 - - godot-editor-macos: - runs-on: macos-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup python and scons - uses: ./.github/actions/setup-godot-deps - - - name: Build Godot artifact - shell: bash - run: | - ./spine-godot/build/install-macos-vulkan-sdk.sh - ./spine-godot/build/setup.sh $GODOT_TAG false - ./spine-godot/build/build-v4.sh - pushd spine-godot/godot/bin - zip -r godot-editor-macos.zip Godot.app - popd - - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: godot-editor-macos.zip - path: spine-godot/godot/bin/godot-editor-macos.zip - - godot-template-ios: - runs-on: macos-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup python and scons - uses: ./.github/actions/setup-godot-deps - - - name: Build Godot artifact - run: | - ./spine-godot/build/install-macos-vulkan-sdk.sh - ./spine-godot/build/setup.sh $GODOT_TAG false - ./spine-godot/build/build-templates-v4.sh ios - - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: godot-template-ios.zip - path: spine-godot/godot/bin/ios.zip - - godot-template-macos: - runs-on: macos-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup python and scons - uses: ./.github/actions/setup-godot-deps - - - name: Build Godot artifact - run: | - ./spine-godot/build/install-macos-vulkan-sdk.sh - ./spine-godot/build/setup.sh $GODOT_TAG false - ./spine-godot/build/build-templates-v4.sh macos - - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: godot-template-macos.zip - path: spine-godot/godot/bin/macos.zip - - godot-template-linux: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup python and scons - uses: ./.github/actions/setup-godot-deps - - - name: Build Godot artifact - run: | - sudo apt-get update - sudo apt-get install build-essential scons pkg-config libx11-dev libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libudev-dev libxi-dev libxrandr-dev - ./spine-godot/build/setup.sh $GODOT_TAG false - ./spine-godot/build/build-templates-v4.sh linux - - - name: Upload artifacts debug - uses: actions/upload-artifact@v3 - with: - name: godot-template-linux-debug.zip - path: spine-godot/godot/bin/linux_x11_64_debug - - - name: Upload artifacts release - uses: actions/upload-artifact@v3 - with: - name: godot-template-linux-release.zip - path: spine-godot/godot/bin/linux_x11_64_release - - godot-template-windows: - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup python and scons - uses: ./.github/actions/setup-godot-deps - - - name: Build Godot artifact - shell: bash - run: | - ./spine-godot/build/setup.sh $GODOT_TAG false - ./spine-godot/build/build-templates-v4.sh windows - - - name: Upload artifacts debug - uses: actions/upload-artifact@v3 - with: - name: godot-template-windows-debug.zip - path: spine-godot/godot/bin/windows_debug_x86_64.exe - - - name: Upload artifacts release - uses: actions/upload-artifact@v3 - with: - name: godot-template-windows-release.zip - path: spine-godot/godot/bin/windows_release_x86_64.exe - - godot-template-android: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - # Azure repositories are not reliable, we need to prevent azure giving us packages. - - name: Make apt sources.list use the default Ubuntu repositories - run: | - sudo rm -f /etc/apt/sources.list.d/* - sudo cp -f spine-godot/build/sources.lst /etc/apt/sources.list - sudo apt-get update - - - name: Set up Java 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - - name: Setup python and scons - uses: ./.github/actions/setup-godot-deps - - - name: Build Godot artifact - shell: bash - run: | - ./spine-godot/build/setup.sh $GODOT_TAG false - ./spine-godot/build/build-templates-v4.sh android - - - name: Upload artifacts debug - uses: actions/upload-artifact@v3 - with: - name: godot-template-android-debug.zip - path: spine-godot/godot/bin/android_debug.apk - - - name: Upload artifacts release - uses: actions/upload-artifact@v3 - with: - name: godot-template-android-release.zip - path: spine-godot/godot/bin/android_release.apk - - - name: Upload artifacts source - uses: actions/upload-artifact@v3 - with: - name: godot-template-android-source.zip - path: spine-godot/godot/bin/android_source.zip - - godot-template-web: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up Emscripten latest - uses: mymindstorm/setup-emsdk@v11 - with: - version: ${{env.EM_VERSION}} - - - name: Verify Emscripten setup - run: | - emcc -v - - - name: Setup python and scons - uses: ./.github/actions/setup-godot-deps - - - name: Build Godot artifact - run: | - ./spine-godot/build/setup.sh $GODOT_TAG false - ./spine-godot/build/build-templates-v4.sh web - - - name: Upload artifacts debug - uses: actions/upload-artifact@v3 - with: - name: godot-template-web-debug.zip - path: spine-godot/godot/bin/web_debug.zip - - - name: Upload artifacts release - uses: actions/upload-artifact@v3 - with: - name: godot-template-web-release.zip - path: spine-godot/godot/bin/web_release.zip - - upload-to-s3: - needs: [godot-editor-windows, godot-editor-linux, godot-editor-macos, godot-template-ios, godot-template-macos, godot-template-windows, godot-template-linux, godot-template-android, godot-template-web] - runs-on: ubuntu-latest - steps: - - name: Download godot-editor-windows artifact - uses: actions/download-artifact@v2 - with: - name: godot-editor-windows.zip - - - name: Download godot-editor-linux artifact - uses: actions/download-artifact@v2 - with: - name: godot-editor-linux.zip - - - name: Download godot-editor-macos artifact - uses: actions/download-artifact@v2 - with: - name: godot-editor-macos.zip - - - name: Download godot-template-ios artifact - uses: actions/download-artifact@v2 - with: - name: godot-template-ios.zip - - - name: Download godot-template-macos artifact - uses: actions/download-artifact@v2 - with: - name: godot-template-macos.zip - - - name: Download godot-template-windows-release artifact - uses: actions/download-artifact@v2 - with: - name: godot-template-windows-release.zip - - - name: Download godot-template-windows-debug artifact - uses: actions/download-artifact@v2 - with: - name: godot-template-windows-debug.zip - - - name: Download godot-template-linux-release artifact - uses: actions/download-artifact@v2 - with: - name: godot-template-linux-release.zip - - - name: Download godot-template-linux-debug artifact - uses: actions/download-artifact@v2 - with: - name: godot-template-linux-debug.zip - - - name: Download godot-template-android-release artifact - uses: actions/download-artifact@v2 - with: - name: godot-template-android-release.zip - - - name: Download godot-template-android-debug artifact - uses: actions/download-artifact@v2 - with: - name: godot-template-android-debug.zip - - - name: Download godot-template-android-source artifact - uses: actions/download-artifact@v2 - with: - name: godot-template-android-source.zip - - - name: Download godot-template-web-release artifact - uses: actions/download-artifact@v2 - with: - name: godot-template-web-release.zip - - - name: Download godot-template-web-debug artifact - uses: actions/download-artifact@v2 - with: - name: godot-template-web-debug.zip - - - name: Upload artifacts to S3 - shell: bash - if: env.AWS_ACCESS_KEY_ID != null - run: | - BRANCH=${GITHUB_REF#refs/heads/} - echo "branch: $BRANCH" - mv godot.windows.editor.x86_64.exe godot-$BRANCH-$GODOT_TAG.exe - mv godot.linuxbsd.editor.x86_64 godot-$BRANCH-$GODOT_TAG - zip godot-editor-windows.zip godot-$BRANCH-$GODOT_TAG.exe - zip godot-editor-linux.zip godot-$BRANCH-$GODOT_TAG - aws s3 cp godot-editor-windows.zip s3://spine-godot/$BRANCH/$GODOT_TAG/ - aws s3 cp godot-editor-linux.zip s3://spine-godot/$BRANCH/$GODOT_TAG/ - aws s3 cp godot-editor-macos.zip s3://spine-godot/$BRANCH/$GODOT_TAG/ - echo "$GODOT_VERSION" > version.txt - ls -lah - zip spine-godot-templates-$BRANCH-$GODOT_TAG.zip ios.zip macos.zip windows_debug_x86_64.exe windows_release_x86_64.exe linux_x11_64_debug linux_x11_64_release web_debug.zip web_release.zip android_release.apk android_debug.apk android_source.zip version.txt - aws s3 cp spine-godot-templates-$BRANCH-$GODOT_TAG.zip s3://spine-godot/$BRANCH/$GODOT_TAG/spine-godot-templates-$BRANCH-$GODOT_TAG.tpz - - diff --git a/.github/workflows/spine-godot-v4.yml b/.github/workflows/spine-godot-v4.yml index 0abdae91a..cc87b43f7 100644 --- a/.github/workflows/spine-godot-v4.yml +++ b/.github/workflows/spine-godot-v4.yml @@ -1,20 +1,26 @@ -name: Build and Publish Godot 4.0 editor and templates +name: Build and publish Godot 4.x editor and templates on: - push: - paths: - - ".github/workflows/spine-godot.yml" - - 'spine-godot/**' - - 'spine-cpp/**' - workflow_dispatch: + workflow_call: + inputs: + godot_tag: + required: true + type: string + godot_version: + required: true + type: string + godot_mono: + required: true + type: boolean env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_EC2_METADATA_DISABLED: true EM_VERSION: 3.1.18 - GODOT_TAG: 4.0.3-stable - GODOT_VERSION: 4.0.3.stable + GODOT_TAG: ${{ inputs.godot_tag }} + GODOT_VERSION: ${{ inputs.godot_version }} + GODOT_MONO: ${{ inputs.godot_mono }} jobs: From 8a3182a6cd722c4bbf4de2a953dabd191462734a Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Fri, 21 Jul 2023 16:21:09 +0200 Subject: [PATCH 06/15] [godot] Add C# build to workflow. --- .github/workflows/spine-godot-v4-all.yml | 3 +- .github/workflows/spine-godot-v4.yml | 113 +++++++++++++++++++---- .github/workflows/spine-godot.yml | 4 +- 3 files changed, 96 insertions(+), 24 deletions(-) diff --git a/.github/workflows/spine-godot-v4-all.yml b/.github/workflows/spine-godot-v4-all.yml index 889c643b3..e0af9be28 100644 --- a/.github/workflows/spine-godot-v4-all.yml +++ b/.github/workflows/spine-godot-v4-all.yml @@ -1,4 +1,4 @@ -name: Build all Godot 4.x versions +name: Build spine-godot (All Godot 4.x versions) on: push: @@ -16,6 +16,7 @@ jobs: [ {"tag": "4.0-stable", "version": "4.0.stable", "mono": false}, {"tag": "4.1-stable", "version": "4.1.stable", "mono": false}, + {"tag": "4.1-stable", "version": "4.1.stable", "mono": true}, ] uses: ./.github/workflows/spine-godot-v4.yml with: diff --git a/.github/workflows/spine-godot-v4.yml b/.github/workflows/spine-godot-v4.yml index cc87b43f7..ccd0fb391 100644 --- a/.github/workflows/spine-godot-v4.yml +++ b/.github/workflows/spine-godot-v4.yml @@ -1,4 +1,4 @@ -name: Build and publish Godot 4.x editor and templates +name: Build spine-godot (Godot 4.x) on: workflow_call: @@ -21,6 +21,7 @@ env: GODOT_TAG: ${{ inputs.godot_tag }} GODOT_VERSION: ${{ inputs.godot_version }} GODOT_MONO: ${{ inputs.godot_mono }} + GODOT_MONO_UPLOAD_SUFFIX: ${{ inputs.godot_mono == true && '-mono' || '' }} jobs: @@ -43,8 +44,8 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v3 with: - name: godot-editor-windows.zip - path: spine-godot/godot/bin/godot.windows.editor.x86_64.exe + name: ${{ format('{0}{1}.zip', 'godot-editor-windows', env.GODOT_MONO_UPLOAD_SUFFIX) }} + path: spine-godot/godot/bin/**/* godot-editor-linux: runs-on: ubuntu-20.04 @@ -67,8 +68,8 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v3 with: - name: godot-editor-linux.zip - path: spine-godot/godot/bin/godot.linuxbsd.editor.x86_64 + name: ${{ format('{0}{1}.zip', 'godot-editor-linux', env.GODOT_MONO_UPLOAD_SUFFIX) }} + path: spine-godot/godot/bin/**/* godot-editor-macos: runs-on: macos-latest @@ -93,11 +94,13 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v3 with: - name: godot-editor-macos.zip + name: ${{ format('{0}{1}.zip', 'godot-editor-macos', env.GODOT_MONO_UPLOAD_SUFFIX) }} path: spine-godot/godot/bin/godot-editor-macos.zip godot-template-ios: runs-on: macos-latest + if: ${{ github.event.inputs.godot_mono == false }} + steps: - uses: actions/checkout@v3 with: @@ -115,7 +118,7 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v3 with: - name: godot-template-ios.zip + name: ${{ format('{0}{1}.zip', 'godot-template-ios', env.GODOT_MONO_UPLOAD_SUFFIX) }} path: spine-godot/godot/bin/ios.zip godot-template-macos: @@ -137,7 +140,7 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v3 with: - name: godot-template-macos.zip + name: ${{ format('{0}{1}.zip', 'godot-template-macos', env.GODOT_MONO_UPLOAD_SUFFIX) }} path: spine-godot/godot/bin/macos.zip godot-template-linux: @@ -160,14 +163,14 @@ jobs: - name: Upload artifacts debug uses: actions/upload-artifact@v3 with: - name: godot-template-linux-debug.zip - path: spine-godot/godot/bin/linux_x11_64_debug + name: ${{ format('{0}{1}.zip', 'godot-template-linux-debug', env.GODOT_MONO_UPLOAD_SUFFIX) }} + path: spine-godot/godot/bin/linux_debug.x86_64 - name: Upload artifacts release uses: actions/upload-artifact@v3 with: - name: godot-template-linux-release.zip - path: spine-godot/godot/bin/linux_x11_64_release + name: ${{ format('{0}{1}.zip', 'godot-template-linux-release', env.GODOT_MONO_UPLOAD_SUFFIX) }} + path: spine-godot/godot/bin/linux_release.x86_64 godot-template-windows: runs-on: windows-latest @@ -188,17 +191,18 @@ jobs: - name: Upload artifacts debug uses: actions/upload-artifact@v3 with: - name: godot-template-windows-debug.zip + name: ${{ format('{0}{1}.zip', 'godot-template-windows-debug', env.GODOT_MONO_UPLOAD_SUFFIX) }} path: spine-godot/godot/bin/windows_debug_x86_64.exe - name: Upload artifacts release uses: actions/upload-artifact@v3 with: - name: godot-template-windows-release.zip + name: ${{ format('{0}{1}.zip', 'godot-template-windows-release', env.GODOT_MONO_UPLOAD_SUFFIX) }} path: spine-godot/godot/bin/windows_release_x86_64.exe godot-template-android: runs-on: ubuntu-20.04 + if: ${{ github.event.inputs.godot_mono == false }} steps: - uses: actions/checkout@v3 with: @@ -228,23 +232,25 @@ jobs: - name: Upload artifacts debug uses: actions/upload-artifact@v3 with: - name: godot-template-android-debug.zip + name: ${{ format('{0}{1}.zip', 'godot-template-android-debug', env.GODOT_MONO_UPLOAD_SUFFIX) }} path: spine-godot/godot/bin/android_debug.apk - name: Upload artifacts release uses: actions/upload-artifact@v3 with: - name: godot-template-android-release.zip + name: ${{ format('{0}{1}.zip', 'godot-template-android-release', env.GODOT_MONO_UPLOAD_SUFFIX) }} path: spine-godot/godot/bin/android_release.apk - name: Upload artifacts source uses: actions/upload-artifact@v3 with: - name: godot-template-android-source.zip + name: ${{ format('{0}{1}.zip', 'godot-template-android-source', env.GODOT_MONO_UPLOAD_SUFFIX) }} path: spine-godot/godot/bin/android_source.zip godot-template-web: runs-on: ubuntu-20.04 + if: ${{ github.event.inputs.godot_mono == false }} + steps: - uses: actions/checkout@v3 with: @@ -270,18 +276,20 @@ jobs: - name: Upload artifacts debug uses: actions/upload-artifact@v3 with: - name: godot-template-web-debug.zip + name: ${{ format('{0}{1}.zip', 'godot-template-web-debug', env.GODOT_MONO_UPLOAD_SUFFIX) }} path: spine-godot/godot/bin/web_debug.zip - name: Upload artifacts release uses: actions/upload-artifact@v3 with: - name: godot-template-web-release.zip + name: ${{ format('{0}{1}.zip', 'godot-template-web-release', env.GODOT_MONO_UPLOAD_SUFFIX) }} path: spine-godot/godot/bin/web_release.zip upload-to-s3: needs: [godot-editor-windows, godot-editor-linux, godot-editor-macos, godot-template-ios, godot-template-macos, godot-template-windows, godot-template-linux, godot-template-android, godot-template-web] runs-on: ubuntu-latest + if: ${{ github.event.inputs.godot_mono == false }} + steps: - name: Download godot-editor-windows artifact uses: actions/download-artifact@v2 @@ -368,7 +376,72 @@ jobs: aws s3 cp godot-editor-macos.zip s3://spine-godot/$BRANCH/$GODOT_TAG/ echo "$GODOT_VERSION" > version.txt ls -lah - zip spine-godot-templates-$BRANCH-$GODOT_TAG.zip ios.zip macos.zip windows_debug_x86_64.exe windows_release_x86_64.exe linux_x11_64_debug linux_x11_64_release web_debug.zip web_release.zip android_release.apk android_debug.apk android_source.zip version.txt + zip spine-godot-templates-$BRANCH-$GODOT_TAG.zip ios.zip macos.zip windows_debug_x86_64.exe windows_release_x86_64.exe linux_debug.x86_64 linux_release.x86_64 web_debug.zip web_release.zip android_release.apk android_debug.apk android_source.zip version.txt + aws s3 cp spine-godot-templates-$BRANCH-$GODOT_TAG.zip s3://spine-godot/$BRANCH/$GODOT_TAG/spine-godot-templates-$BRANCH-$GODOT_TAG.tpz + + upload-to-s3-mono: + needs: [godot-editor-windows, godot-editor-linux, godot-editor-macos, godot-template-macos, godot-template-windows, godot-template-linux] + runs-on: ubuntu-latest + if: ${{ github.event.inputs.godot_mono == true }} + + steps: + - name: Download godot-editor-windows artifact + uses: actions/download-artifact@v2 + with: + name: godot-editor-windows-mono.zip + + - name: Download godot-editor-linux artifact + uses: actions/download-artifact@v2 + with: + name: godot-editor-linux-mono.zip + + - name: Download godot-editor-macos artifact + uses: actions/download-artifact@v2 + with: + name: godot-editor-macos-mono.zip + + - name: Download godot-template-macos artifact + uses: actions/download-artifact@v2 + with: + name: godot-template-macos-mono.zip + + - name: Download godot-template-windows-release artifact + uses: actions/download-artifact@v2 + with: + name: godot-template-windows-release-mono.zip + + - name: Download godot-template-windows-debug artifact + uses: actions/download-artifact@v2 + with: + name: godot-template-windows-debug-mono.zip + + - name: Download godot-template-linux-release artifact + uses: actions/download-artifact@v2 + with: + name: godot-template-linux-release-mono.zip + + - name: Download godot-template-linux-debug artifact + uses: actions/download-artifact@v2 + with: + name: godot-template-linux-debug-mono.zip + + - name: Upload artifacts to S3 + shell: bash + if: env.AWS_ACCESS_KEY_ID != null + run: | + BRANCH=${GITHUB_REF#refs/heads/} + echo "branch: $BRANCH" + mv godot.windows.editor.x86_64.mono.exe godot-$BRANCH-$GODOT_TAG-mono.exe + mv godot.linuxbsd.editor.x86_64.mono godot-$BRANCH-$GODOT_TAG-mono + zip godot-editor-windows-mono.zip godot-$BRANCH-$GODOT_TAG-mono.exe GodotSharp + zip godot-editor-linux-mono.zip godot-$BRANCH-$GODOT_TAG-mono GodotSharp + aws s3 cp godot-editor-windows-mono.zip s3://spine-godot/$BRANCH/$GODOT_TAG/ + aws s3 cp godot-editor-linux-mono.zip s3://spine-godot/$BRANCH/$GODOT_TAG/ + aws s3 cp godot-editor-macos-mono.zip s3://spine-godot/$BRANCH/$GODOT_TAG/ + echo "$GODOT_VERSION.mono" > version.txt + ls -lah + zip spine-godot-templates-$BRANCH-$GODOT_TAG-mono.zip macos.zip windows_debug_x86_64.exe windows_release_x86_64.exe linux_debug.x86_64 linux_release.x86_64 version.txt aws s3 cp spine-godot-templates-$BRANCH-$GODOT_TAG.zip s3://spine-godot/$BRANCH/$GODOT_TAG/spine-godot-templates-$BRANCH-$GODOT_TAG.tpz + diff --git a/.github/workflows/spine-godot.yml b/.github/workflows/spine-godot.yml index b89a4a79b..fa4cab519 100644 --- a/.github/workflows/spine-godot.yml +++ b/.github/workflows/spine-godot.yml @@ -1,5 +1,4 @@ -name: Build and Publish Godot 3.5 editor and templates - +name: Build spine-godot (Godot 3.5) on: push: paths: @@ -17,7 +16,6 @@ env: GODOT_VERSION: 3.5.2.stable jobs: - godot-editor-windows: runs-on: windows-latest steps: From 1dec42d852051d31c57b54facf57f9eefbf643af Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 24 Jul 2023 10:33:37 +0200 Subject: [PATCH 07/15] [godot] Add debugging output to Godot GH workflow --- .github/workflows/spine-godot-v4.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/spine-godot-v4.yml b/.github/workflows/spine-godot-v4.yml index ccd0fb391..2e5191900 100644 --- a/.github/workflows/spine-godot-v4.yml +++ b/.github/workflows/spine-godot-v4.yml @@ -18,12 +18,22 @@ env: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_EC2_METADATA_DISABLED: true EM_VERSION: 3.1.18 - GODOT_TAG: ${{ inputs.godot_tag }} - GODOT_VERSION: ${{ inputs.godot_version }} - GODOT_MONO: ${{ inputs.godot_mono }} - GODOT_MONO_UPLOAD_SUFFIX: ${{ inputs.godot_mono == true && '-mono' || '' }} + GODOT_TAG: ${{ github.event.inputs.godot_tag }} + GODOT_VERSION: ${{ github.event.inputs.godot_version }} + GODOT_MONO: ${{ github.event.inputs.godot_mono }} + GODOT_MONO_UPLOAD_SUFFIX: ${{ github.event.inputs.godot_mono == true && '-mono' || '' }} jobs: + print_parameters: + runs-on: ubuntu-latest + steps: + - name: Print build parameters + shell: bash + run: | + echo "GODOT_TAG: $GODOT_TAG" + echo "GODOT_VERSION: $GODOT_VERSION" + echo "GODOT_MONO: $GODOT_MONO" + echo "GODOT_MONO_UPLOAD_SUFFIX: $GODOT_MONO_UPLOAD_SUFFIX" godot-editor-windows: runs-on: windows-latest From caafb9b94f74b65b3de7ae991dc8a275345c06dd Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 24 Jul 2023 10:37:32 +0200 Subject: [PATCH 08/15] [godot] More GitHub workflow debugging. --- .github/workflows/spine-godot-v4.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/spine-godot-v4.yml b/.github/workflows/spine-godot-v4.yml index 2e5191900..a59ffc166 100644 --- a/.github/workflows/spine-godot-v4.yml +++ b/.github/workflows/spine-godot-v4.yml @@ -6,12 +6,15 @@ on: godot_tag: required: true type: string + default: "Godot tag not specified!" godot_version: required: true type: string + default: "Godot version not specified!" godot_mono: required: true type: boolean + default: false env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} From 44d766c65e6c01c08086020cec6f373e211488ff Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 24 Jul 2023 10:40:50 +0200 Subject: [PATCH 09/15] [godot] More GitHub workflow debugging. --- .github/workflows/spine-godot-v4.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/spine-godot-v4.yml b/.github/workflows/spine-godot-v4.yml index a59ffc166..45fda3852 100644 --- a/.github/workflows/spine-godot-v4.yml +++ b/.github/workflows/spine-godot-v4.yml @@ -37,6 +37,7 @@ jobs: echo "GODOT_VERSION: $GODOT_VERSION" echo "GODOT_MONO: $GODOT_MONO" echo "GODOT_MONO_UPLOAD_SUFFIX: $GODOT_MONO_UPLOAD_SUFFIX" + env godot-editor-windows: runs-on: windows-latest From 5facf4a68693166bad4607a169875c94419144bf Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 24 Jul 2023 10:44:27 +0200 Subject: [PATCH 10/15] [godot] More GitHub workflow debugging. --- .github/workflows/spine-godot-v4.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/spine-godot-v4.yml b/.github/workflows/spine-godot-v4.yml index 45fda3852..1925dbbb8 100644 --- a/.github/workflows/spine-godot-v4.yml +++ b/.github/workflows/spine-godot-v4.yml @@ -21,10 +21,10 @@ env: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_EC2_METADATA_DISABLED: true EM_VERSION: 3.1.18 - GODOT_TAG: ${{ github.event.inputs.godot_tag }} - GODOT_VERSION: ${{ github.event.inputs.godot_version }} - GODOT_MONO: ${{ github.event.inputs.godot_mono }} - GODOT_MONO_UPLOAD_SUFFIX: ${{ github.event.inputs.godot_mono == true && '-mono' || '' }} + GODOT_TAG: ${{ inputs.godot_tag }} + GODOT_VERSION: ${{ inputs.godot_version }} + GODOT_MONO: ${{ inputs.godot_mono }} + GODOT_MONO_UPLOAD_SUFFIX: ${{ inputs.godot_mono == true && '-mono' || '' }} jobs: print_parameters: @@ -113,7 +113,7 @@ jobs: godot-template-ios: runs-on: macos-latest - if: ${{ github.event.inputs.godot_mono == false }} + if: ${{ inputs.godot_mono == false }} steps: - uses: actions/checkout@v3 @@ -216,7 +216,7 @@ jobs: godot-template-android: runs-on: ubuntu-20.04 - if: ${{ github.event.inputs.godot_mono == false }} + if: ${{ inputs.godot_mono == false }} steps: - uses: actions/checkout@v3 with: @@ -263,7 +263,7 @@ jobs: godot-template-web: runs-on: ubuntu-20.04 - if: ${{ github.event.inputs.godot_mono == false }} + if: ${{ inputs.godot_mono == false }} steps: - uses: actions/checkout@v3 @@ -302,7 +302,7 @@ jobs: upload-to-s3: needs: [godot-editor-windows, godot-editor-linux, godot-editor-macos, godot-template-ios, godot-template-macos, godot-template-windows, godot-template-linux, godot-template-android, godot-template-web] runs-on: ubuntu-latest - if: ${{ github.event.inputs.godot_mono == false }} + if: ${{ inputs.godot_mono == false }} steps: - name: Download godot-editor-windows artifact @@ -396,7 +396,7 @@ jobs: upload-to-s3-mono: needs: [godot-editor-windows, godot-editor-linux, godot-editor-macos, godot-template-macos, godot-template-windows, godot-template-linux] runs-on: ubuntu-latest - if: ${{ github.event.inputs.godot_mono == true }} + if: ${{ inputs.godot_mono == true }} steps: - name: Download godot-editor-windows artifact From 4cdde9635ae7fe1fee37c73e982e7a04898dee91 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 24 Jul 2023 10:48:06 +0200 Subject: [PATCH 11/15] [godot] Manual dispatch for Godot 4 workflow. --- .github/workflows/spine-godot-v4.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/spine-godot-v4.yml b/.github/workflows/spine-godot-v4.yml index 1925dbbb8..b0fc6e5d5 100644 --- a/.github/workflows/spine-godot-v4.yml +++ b/.github/workflows/spine-godot-v4.yml @@ -15,6 +15,20 @@ on: required: true type: boolean default: false + workflow_dispatch: + inputs: + godot_tag: + required: true + type: string + default: "Godot tag not specified!" + godot_version: + required: true + type: string + default: "Godot version not specified!" + godot_mono: + required: true + type: boolean + default: false env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} From b18a92a0f936de04d71adfb2d1305cdae44e5583 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 24 Jul 2023 10:52:24 +0200 Subject: [PATCH 12/15] [godot] Remove debug logging job. You can get the same info when expanding the undiscoverable little arrows in the job logs. --- .github/workflows/spine-godot-v4.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/spine-godot-v4.yml b/.github/workflows/spine-godot-v4.yml index b0fc6e5d5..045a9102d 100644 --- a/.github/workflows/spine-godot-v4.yml +++ b/.github/workflows/spine-godot-v4.yml @@ -41,17 +41,6 @@ env: GODOT_MONO_UPLOAD_SUFFIX: ${{ inputs.godot_mono == true && '-mono' || '' }} jobs: - print_parameters: - runs-on: ubuntu-latest - steps: - - name: Print build parameters - shell: bash - run: | - echo "GODOT_TAG: $GODOT_TAG" - echo "GODOT_VERSION: $GODOT_VERSION" - echo "GODOT_MONO: $GODOT_MONO" - echo "GODOT_MONO_UPLOAD_SUFFIX: $GODOT_MONO_UPLOAD_SUFFIX" - env godot-editor-windows: runs-on: windows-latest From 0b1909ae064859b3b2d6117897865ca33bbb406b Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 24 Jul 2023 11:01:43 +0200 Subject: [PATCH 13/15] [godot] Pass mono flag to buildscripts from workflow. --- .github/workflows/spine-godot-v4.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/spine-godot-v4.yml b/.github/workflows/spine-godot-v4.yml index 045a9102d..15c150445 100644 --- a/.github/workflows/spine-godot-v4.yml +++ b/.github/workflows/spine-godot-v4.yml @@ -55,8 +55,8 @@ jobs: - name: Build Godot artifact shell: bash run: | - ./spine-godot/build/setup.sh $GODOT_TAG false - ./spine-godot/build/build-v4.sh + ./spine-godot/build/setup.sh $GODOT_TAG false $GODOT_MONO + ./spine-godot/build/build-v4.sh $GODOT_MONO - name: Upload artifacts uses: actions/upload-artifact@v3 @@ -79,8 +79,8 @@ jobs: run: | sudo apt-get update sudo apt-get install build-essential scons pkg-config libx11-dev libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libudev-dev libxi-dev libxrandr-dev - ./spine-godot/build/setup.sh $GODOT_TAG false - ./spine-godot/build/build-v4.sh + ./spine-godot/build/setup.sh $GODOT_TAG false $GODOT_MONO + ./spine-godot/build/build-v4.sh $GODOT_MONO - name: Upload artifacts uses: actions/upload-artifact@v3 @@ -102,8 +102,8 @@ jobs: shell: bash run: | ./spine-godot/build/install-macos-vulkan-sdk.sh - ./spine-godot/build/setup.sh $GODOT_TAG false - ./spine-godot/build/build-v4.sh + ./spine-godot/build/setup.sh $GODOT_TAG false $GODOT_MONO + ./spine-godot/build/build-v4.sh $GODOT_MONO pushd spine-godot/godot/bin zip -r godot-editor-macos.zip Godot.app popd @@ -151,8 +151,8 @@ jobs: - name: Build Godot artifact run: | ./spine-godot/build/install-macos-vulkan-sdk.sh - ./spine-godot/build/setup.sh $GODOT_TAG false - ./spine-godot/build/build-templates-v4.sh macos + ./spine-godot/build/setup.sh $GODOT_TAG false $GODOT_MONO + ./spine-godot/build/build-templates-v4.sh macos $GODOT_MONO - name: Upload artifacts uses: actions/upload-artifact@v3 @@ -174,8 +174,8 @@ jobs: run: | sudo apt-get update sudo apt-get install build-essential scons pkg-config libx11-dev libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libudev-dev libxi-dev libxrandr-dev - ./spine-godot/build/setup.sh $GODOT_TAG false - ./spine-godot/build/build-templates-v4.sh linux + ./spine-godot/build/setup.sh $GODOT_TAG false $GODOT_MONO + ./spine-godot/build/build-templates-v4.sh linux $GODOT_MONO - name: Upload artifacts debug uses: actions/upload-artifact@v3 @@ -202,8 +202,8 @@ jobs: - name: Build Godot artifact shell: bash run: | - ./spine-godot/build/setup.sh $GODOT_TAG false - ./spine-godot/build/build-templates-v4.sh windows + ./spine-godot/build/setup.sh $GODOT_TAG false $GODOT_MONO + ./spine-godot/build/build-templates-v4.sh windows $GODOT_MONO - name: Upload artifacts debug uses: actions/upload-artifact@v3 From 80f597362364a99198bc3616b6f406ce2d95a793 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 24 Jul 2023 12:39:55 +0200 Subject: [PATCH 14/15] [godot] Fix Linux C# build. --- spine-godot/build/build-v4.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spine-godot/build/build-v4.sh b/spine-godot/build/build-v4.sh index cff73b584..238e0599c 100755 --- a/spine-godot/build/build-v4.sh +++ b/spine-godot/build/build-v4.sh @@ -70,7 +70,7 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then else os="linux" cpus=$(grep -c ^processor /proc/cpuinfo) - godot_exe="godot.linux.editor$dev_extension.x86_64$mono_extension" + godot_exe="godot.linuxbsd.editor$dev_extension.x86_64$mono_extension" godot_exe_host=$godot_exe fi From 5eca100d60c03d8db38287352c50bb45c0e99f86 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Mon, 24 Jul 2023 20:34:58 +0200 Subject: [PATCH 15/15] [unity] URP shaders: Fixed DoF effect ignoring written depth when Decal feature is enabled. Closes #2283. --- .../Include/Spine-DepthNormalsPass-URP.hlsl | 74 ++++++++++++++++ .../Spine-DepthNormalsPass-URP.hlsl.meta | 7 ++ .../Spine-Sprite-DepthNormalsPass-URP.hlsl | 88 +++++++++++++++++++ ...pine-Sprite-DepthNormalsPass-URP.hlsl.meta | 7 ++ .../Shaders/Spine-SkeletonLit-URP.shader | 36 +++++++- .../Shaders/Spine-Sprite-URP.shader | 36 ++++++++ .../package.json | 2 +- 7 files changed, 248 insertions(+), 2 deletions(-) create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-DepthNormalsPass-URP.hlsl create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-DepthNormalsPass-URP.hlsl.meta create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-DepthNormalsPass-URP.hlsl create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-DepthNormalsPass-URP.hlsl.meta diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-DepthNormalsPass-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-DepthNormalsPass-URP.hlsl new file mode 100644 index 000000000..eee3a181d --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-DepthNormalsPass-URP.hlsl @@ -0,0 +1,74 @@ +#ifndef SPRITES_DEPTH_NORMALS_PASS_URP_INCLUDED +#define SPRITES_DEPTH_NORMALS_PASS_URP_INCLUDED + +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + +struct AttributesSpine +{ + float4 positionOS : POSITION; + float3 normalOS : NORMAL; + float4 vertexColor : COLOR; + float2 texcoord : TEXCOORD0; + UNITY_VERTEX_INPUT_INSTANCE_ID +}; + +struct VaryingsSpine +{ + float3 normalWS : NORMAL; + float4 positionCS : SV_POSITION; + float4 texcoordAndAlpha: TEXCOORD0; + UNITY_VERTEX_OUTPUT_STEREO +}; + +VaryingsSpine DepthNormalsVertex(AttributesSpine input) +{ + VaryingsSpine output = (VaryingsSpine)0; + UNITY_SETUP_INSTANCE_ID(input); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); + + half3 fixedNormal = half3(0, 0, -1); + half3 normalWS = normalize(mul((float3x3)unity_ObjectToWorld, fixedNormal)); + +#ifdef _DOUBLE_SIDED_LIGHTING + // unfortunately we have to compute the sign here in the vertex shader + // instead of using VFACE in fragment shader stage. + half3 viewDirWS = UNITY_MATRIX_V[2].xyz; + half faceSign = sign(dot(viewDirWS, normalWS)); + normalWS *= faceSign; +#endif + output.normalWS = normalWS; + + output.texcoordAndAlpha.xyz = float3(TRANSFORM_TEX(input.texcoord, _MainTex).xy, 0); + output.texcoordAndAlpha.a = input.vertexColor.a; + output.positionCS = TransformObjectToHClip(input.positionOS.xyz); + return output; +} + +void DepthNormalsFragment(VaryingsSpine input, + out half4 outNormalWS : SV_Target0 +#ifdef _WRITE_RENDERING_LAYERS + , out float4 outRenderingLayers : SV_Target1 +#endif + ) +{ + fixed4 texureColor = tex2D(_MainTex, input.texcoordAndAlpha.xy); + clip(texureColor.a * input.texcoordAndAlpha.a - _Cutoff); + + float3 normalWS = input.normalWS; +#if defined(_GBUFFER_NORMALS_OCT) + float2 octNormalWS = PackNormalOctQuadEncode(normalWS); // values between [-1, +1], must use fp32 on some platforms. + float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5); // values between [ 0, 1] + half3 packedNormalWS = PackFloat2To888(remappedOctNormalWS); // values between [ 0, 1] + outNormalWS = half4(packedNormalWS, 0.0); +#else + outNormalWS = half4(normalWS, 0.0); +#endif + +#ifdef USE_WRITE_RENDERING_LAYERS + uint renderingLayers = GetMeshRenderingLayerBackwardsCompatible(); + outRenderingLayers = float4(EncodeMeshRenderingLayer(renderingLayers), 0, 0, 0); +#endif +} + +#endif diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-DepthNormalsPass-URP.hlsl.meta b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-DepthNormalsPass-URP.hlsl.meta new file mode 100644 index 000000000..5517cd01c --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-DepthNormalsPass-URP.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 803855a1999ecce4081f5e0fb18c6475 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-DepthNormalsPass-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-DepthNormalsPass-URP.hlsl new file mode 100644 index 000000000..70a817fa0 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-DepthNormalsPass-URP.hlsl @@ -0,0 +1,88 @@ +#ifndef SPRITES_DEPTH_NORMALS_PASS_URP_INCLUDED +#define SPRITES_DEPTH_NORMALS_PASS_URP_INCLUDED + +#include "Include/Spine-Sprite-Common-URP.hlsl" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" +#include "SpineCoreShaders/SpriteLighting.cginc" +#include "SpineCoreShaders/Spine-Common.cginc" +#include "Spine-Common-URP.hlsl" + +//#include "Include/Spine-Sprite-Common-URP.hlsl" +//#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + +struct VaryingsSprite +{ + float4 pos : SV_POSITION; + fixed4 vertexColor : COLOR; + float3 texcoord : TEXCOORD0; + +#if defined(_NORMALMAP) + half4 normalWorld : TEXCOORD4; + half4 tangentWorld : TEXCOORD5; + half4 binormalWorld : TEXCOORD6; +#else + half3 normalWorld : TEXCOORD4; +#endif + UNITY_VERTEX_INPUT_INSTANCE_ID + UNITY_VERTEX_OUTPUT_STEREO +}; + +VaryingsSprite DepthNormalsVertexSprite(VertexInput input) +{ + VaryingsSprite output = (VaryingsSprite)0; + UNITY_SETUP_INSTANCE_ID(input); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); + + output.pos = calculateLocalPos(input.vertex); + output.vertexColor = calculateVertexColor(input.color); + output.texcoord = float3(calculateTextureCoord(input.texcoord), 0); + + float backFaceSign = 1; +#if defined(FIXED_NORMALS_BACKFACE_RENDERING) + backFaceSign = calculateBackfacingSign(positionWS.xyz); +#endif + + half3 normalWS = calculateSpriteWorldNormal(input, -backFaceSign); + output.normalWorld.xyz = normalWS; +#if defined(_NORMALMAP) + output.tangentWorld.xyz = calculateWorldTangent(input.tangent); + output.binormalWorld.xyz = calculateSpriteWorldBinormal(input, output.normalWorld.xyz, output.tangentWorld.xyz, backFaceSign); +#endif + + return output; +} + +void DepthNormalsFragmentSprite(VaryingsSprite input, + out half4 outNormalWS : SV_Target0 +#ifdef _WRITE_RENDERING_LAYERS + , out float4 outRenderingLayers : SV_Target1 +#endif + ) +{ + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); + + fixed4 texureColor = calculateTexturePixel(input.texcoord.xy); + ALPHA_CLIP(texureColor, input.vertexColor) + +#if defined(PER_PIXEL_LIGHTING) && defined(_NORMALMAP) + half3 normalWS = calculateNormalFromBumpMap(input.texcoord.xy, input.tangentWorld.xyz, input.binormalWorld.xyz, input.normalWorld.xyz); +#else + half3 normalWS = input.normalWorld.xyz; +#endif + +#if defined(_GBUFFER_NORMALS_OCT) + float2 octNormalWS = PackNormalOctQuadEncode(normalWS); // values between [-1, +1], must use fp32 on some platforms. + float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5); // values between [ 0, 1] + half3 packedNormalWS = PackFloat2To888(remappedOctNormalWS); // values between [ 0, 1] + outNormalWS = half4(packedNormalWS, 0.0); +#else + outNormalWS = half4(normalWS, 0.0); +#endif + +#ifdef USE_WRITE_RENDERING_LAYERS + uint renderingLayers = GetMeshRenderingLayerBackwardsCompatible(); + outRenderingLayers = float4(EncodeMeshRenderingLayer(renderingLayers), 0, 0, 0); +#endif +} + +#endif diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-DepthNormalsPass-URP.hlsl.meta b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-DepthNormalsPass-URP.hlsl.meta new file mode 100644 index 000000000..efe280cf7 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-DepthNormalsPass-URP.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 5070c54df4a943a438cfe0a199b55657 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-SkeletonLit-URP.shader b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-SkeletonLit-URP.shader index af98cf955..70fc7e7df 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-SkeletonLit-URP.shader +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-SkeletonLit-URP.shader @@ -123,7 +123,7 @@ ENDHLSL } - Pass + Pass { Name "DepthOnly" Tags{"LightMode" = "DepthOnly"} @@ -157,6 +157,40 @@ #include "Include/Spine-DepthOnlyPass-URP.hlsl" ENDHLSL } + + // This pass is used when drawing to a _CameraNormalsTexture texture + Pass + { + Name "DepthNormals" + Tags{"LightMode" = "DepthNormals"} + + ZWrite On + + HLSLPROGRAM + #pragma vertex DepthNormalsVertex + #pragma fragment DepthNormalsFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature _ALPHATEST_ON + #pragma shader_feature _ _DOUBLE_SIDED_LIGHTING + + // ------------------------------------- + // Universal Pipeline keywords + #pragma multi_compile_fragment _ _WRITE_RENDERING_LAYERS + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + + #define USE_URP + #define fixed4 half4 + #define fixed3 half3 + #define fixed half + #include "Include/Spine-Input-URP.hlsl" + #include "Include/Spine-DepthNormalsPass-URP.hlsl" + ENDHLSL + } } FallBack "Hidden/InternalErrorShader" diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-Sprite-URP.shader b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-Sprite-URP.shader index 01add5f75..d411f1e28 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-Sprite-URP.shader +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-Sprite-URP.shader @@ -213,6 +213,42 @@ Shader "Universal Render Pipeline/Spine/Sprite" ENDHLSL } + // This pass is used when drawing to a _CameraNormalsTexture texture + Pass + { + Name "DepthNormals" + Tags{"LightMode" = "DepthNormals"} + + ZWrite On + Cull[_Cull] + + HLSLPROGRAM + #pragma vertex DepthNormalsVertexSprite + #pragma fragment DepthNormalsFragmentSprite + + // ------------------------------------- + // Material Keywords + #pragma shader_feature _ _FIXED_NORMALS_VIEWSPACE _FIXED_NORMALS_VIEWSPACE_BACKFACE _FIXED_NORMALS_MODELSPACE _FIXED_NORMALS_MODELSPACE_BACKFACE _FIXED_NORMALS_WORLDSPACE + #pragma shader_feature _NORMALMAP + #pragma shader_feature _ALPHA_CLIP + + // ------------------------------------- + // Universal Pipeline keywords + #pragma multi_compile_fragment _ _WRITE_RENDERING_LAYERS + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + + #define USE_URP + #define fixed4 half4 + #define fixed3 half3 + #define fixed half + #include "Include/Spine-Input-Sprite-URP.hlsl" + #include "Include/Spine-Sprite-DepthNormalsPass-URP.hlsl" + ENDHLSL + } + Pass { Name "Unlit" diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json index 25e15624d..7d32f80a6 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json @@ -2,7 +2,7 @@ "name": "com.esotericsoftware.spine.urp-shaders", "displayName": "Spine Universal RP Shaders", "description": "This plugin provides universal render pipeline (URP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 4.1.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", - "version": "4.1.17", + "version": "4.1.18", "unity": "2019.3", "author": { "name": "Esoteric Software",