-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun.sh
executable file
·78 lines (66 loc) · 2.31 KB
/
run.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
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# Check if folder path is provided as argument
if [ $# -lt 1 ]; then
echo "Usage: $0 <folder_path> [--no-albedo | --ltwo | --scale-albedo | --num-iter <num_iter> | --res <resolution>]"
exit 1
fi
# Assign folder path to a variable
case="$1"
# Handle optional arguments
flags=""
scale_albedo=false
while [ $# -gt 1 ]; do
case "$2" in
--no-albedo)
flags="$flags --no-albedo"
;;
--ltwo)
flags="$flags --ltwo"
;;
--scale-albedo)
scale_albedo=true
;;
--num-iter)
num_iter="$3"
flags="$flags --num-iter $num_iter"
shift
;;
--res)
resolution="$3"
shift
;;
*)
echo "Unknown option: $2"
exit 1
;;
esac
shift
done
# If --num-iter is not provided, set it to 10000
if [ -z "$num_iter" ]; then
num_iter=10000
fi
# If --scale-albedo is provided, run the albedo scaling steps
if [ "$scale_albedo" = true ]; then
# if scale_albedo is true, then no-albedo flag should not be present
flags=$(echo "$flags" | sed 's/--no-albedo//')
# Launch without albedo
./run.sh "$case" --no-albedo $flags --res 512
# Launch with scaled albedos
python scripts/scale_albedos.py --folder "$case"
path=$(dirname "$case")
folder=$(basename "$case")
folder="${folder}-albedoscaled"
./run.sh "$path/$folder/" $flags
exit 0
fi
# Remove num-iter flag from flags
flags=$(echo "$flags" | sed 's/--num-iter [0-9]*//')
iterLightOptimal=${num_iter}
iterWarmupLightGlobal=$(($iterLightOptimal/5*3))
iterWarmupMask=$(($iterLightOptimal/5))
resolutionMarchingCube=${resolution:-1024}
# Execute the commands with the defined variables
./build/testbed --scene "${case}/" --maxiter "${iterWarmupMask}" --save-snapshot --mask-weight 1.0 --no-gui $flags
./build/testbed --scene "${case}/" --maxiter "${iterWarmupLightGlobal}" --save-snapshot --mask-weight 0.3 --no-gui --snapshot "${case}/snapshot_${iterWarmupMask}.msgpack" $flags
./build/testbed --scene "${case}/" --maxiter "${iterLightOptimal}" --save-snapshot --mask-weight 0.3 --no-gui --snapshot "${case}/snapshot_${iterWarmupLightGlobal}.msgpack" --save-mesh --resolution "${resolutionMarchingCube}" --opti-lights $flags