/
render_tile.sh
executable file
·48 lines (40 loc) · 1.44 KB
/
render_tile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
temp_render_path=$(realpath ./render-build-temp)
input_blender_file=$(realpath $1)
output_sprite_sheet_path=$(realpath $2)
output_filename_prefix=$3
blender -v &>/dev/null
if [ $? -ne 0 ]; then
echo "Can't find Blender in PATH. Blender >=2.9 is required."
exit
else
echo "Found Blender: '$(which Blender)'"
fi
if [ -d $temp_render_path ]; then
echo "Deleting animation render working directory ($temp_render_path)"
rm -r $temp_render_path
fi
if [ ! -d $temp_render_path ]; then
echo "Recreating animation render working directory ($temp_render_path)"
mkdir $temp_render_path
fi
blender -b $input_blender_file --use-extension 1 -s 1 -o $temp_render_path/$output_filename_prefix --render-anim
if [ $? -ne 0 ]; then
echo "Blender exited with a non-zero exit code. Render failed."
else
echo "Rendered animation frames to $temp_render_path"
fi
montage -version &>/dev/null
if [ $? -ne 0 ]; then
echo "Unable convert the animation frames from Blender into a sprite sheet. ImageMagick (montage command) is required."
exit
else
echo "Found montage (ImageMagick): '$(which montage)'"
fi
montage $temp_render_path/$output_filename_prefix*.png -tile 10x1 -geometry 64x32\>+0+0 -background transparent $output_sprite_sheet_path
if [ $? -ne 0 ]; then
echo "Failed to convert animation frames into sprite sheet"
exit
else
echo "Converted animation frames into sprite sheet ($output_sprite_sheet_path)"
fi