-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo
executable file
·63 lines (51 loc) · 1.72 KB
/
demo
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
#!/usr/bin/env bash
throw() {
echo "Error:" "$@"
exit 1
}
if [ ! -t 0 ] ; then
echo "Error: demo script must be run in interactive mode. Exiting."
exit 0
fi
runtime_dir=$(dirname "$0") || throw "Failed to determine runtime directory"
ronald_path="$runtime_dir/ronald"
scenes_dir=$(realpath "$runtime_dir/../scenes") || throw "Failed to locate scenes directory"
if [ ! -d "$scenes_dir" ]; then
throw "Could not locate scenes directory"
fi
mapfile -t files < <(ls "$scenes_dir")
PS3="Select demo scene: "
select selection in "${files[@]}"
do
if [ "$selection" = "" ]; then
echo "Invalid selection. Try again."
else
scene_path="$scenes_dir/$selection"
echo
echo "Using scene: $scene_path"
echo
read -r -e -p "Width (suggested under 512px x 512px resolution for reasonable runtime): " WIDTH
read -r -e -p "Height: " HEIGHT
read -r -e -p "Samples per pixel (suggested under 1500 for reasonable runtime): " SAMPLES
read -r -e -p "Number of threads (0 for hardware_concurrency): " THREADS
read -r -e -p "Output file name (.ppm extension): " OUTFILE
rc=0
echo
set -x
"$ronald_path" \
--width "$WIDTH" \
--height "$HEIGHT" \
--samples "$SAMPLES" \
--threads "$THREADS" \
--out "$OUTFILE" \
"$scene_path"
{ { rc=$?; set +x; }; } 2>/dev/null
if [ "$rc" != "0" ]; then
echo "Problem ocurred while rendering."
else
full_out_path=$(realpath "$OUTFILE") || throw "Failed to determine output file path"
echo "Rendering finished! Output file: $full_out_path"
fi
break;
fi
done