-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_and_render.sh
executable file
·66 lines (54 loc) · 1.9 KB
/
build_and_render.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
if [ $# -eq 0 ]; then
echo "No scene name provided as argument."
exit 1
fi
set -e
SCENE_NAME=$1
clear
echo "-----------------------------------------------------------------------------"
echo "Building and running scene \"$SCENE_NAME\""
RENDER_RESULT_DIR=$SCENE_NAME
SCENE_BIN=$SCENE_NAME
SCENE_DEFINITION=$SCENE_NAME.animation.json
echo "-----------------------------------------------------------------------------"
echo "Building executables:"
make build
make build_scene SCENE_NAME="$SCENE_NAME"
echo "-----------------------------------------------------------------------------"
echo "Running scene animation creation executable ./bin/$SCENE_BIN"
./bin/$SCENE_BIN
echo "-----------------------------------------------------------------------------"
echo "Removing old render files from ./rendered/$RENDER_RESULT_DIR"
# Wipe/clear output directory
rm -fR ./rendered/$RENDER_RESULT_DIR
echo "-----------------------------------------------------------------------------"
echo "Rendering scene ./scene/$SCENE_DEFINITION"
./bin/pathtracer scene/$SCENE_DEFINITION
PNG_COUNT=$(find -f ./rendered/$RENDER_RESULT_DIR/*.png | wc -l | xargs)
if [ $PNG_COUNT -gt 1 ]
then
echo
echo
echo "-----------------------------------------------------------------------------"
echo "Encoding movie: ./rendered/$RENDER_RESULT_DIR/$SCENE_NAME.mp4"
cd ./rendered/$RENDER_RESULT_DIR
../../encode_movie.sh
mv output.mp4 $SCENE_NAME.mp4
cd -
fi
echo "-----------------------------------------------------------------------------"
echo "Finished at $(date '+%Y-%m-%d %H:%M:%S')"
echo
echo "Rendered scene: \"$SCENE_NAME\""
echo "Amount images: $PNG_COUNT"
if [ $PNG_COUNT -gt 1 ]
then
echo "Created movie: ./rendered/$RENDER_RESULT_DIR/$SCENE_NAME.mp4"
fi
if [ $PNG_COUNT -eq 1 ]
then
PNG_FILE=$(find -f ./rendered/$RENDER_RESULT_DIR/*.png)
open "$PNG_FILE"
else
open "./rendered/$RENDER_RESULT_DIR/$SCENE_NAME.mp4"
fi