Skip to content

Instantly share code, notes, and snippets.

@juliand665
Last active October 28, 2020 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliand665/e4dfd7bce84bb2ca50376cc8423404fd to your computer and use it in GitHub Desktop.
Save juliand665/e4dfd7bce84bb2ca50376cc8423404fd to your computer and use it in GitHub Desktop.
Nori Tonemapper Automation
#!/usr/local/bin/fish
set -l root (dirname (status --current-filename))
for file in $argv[1..-1]
echo "tonemapping $file..."
$root/nori/build/tonemapper "$file"
end
#!/usr/local/bin/fish
# Expects to be placed at nori/*/collect_images.fish, e.g. nori/reports/collect_images.fish
# Takes any amount of numbers as arguments, referring to the number of the assignment for which to collect images.
# For each $number, it tonemaps all user-generated and reference EXRs (provided they've changed) at nori/scenes/pa$number/ to PNGs.
# It then places these PNGs in an "out" and "ref" folder, respectively, within nori/reports/report-ex$number/images/.
set -l root (dirname (status --current-filename))/..
set -l numbers $argv[1..-1]
set -l folders ".§out" "**/ref§ref"
for number in $numbers
set -l report_root "$root/reports/report-ex$number/images"
mkdir -p "$report_root/ref" "$report_root/out"
for exr in $root/scenes/pa$number/**/*.exr
set -l report_subfolder
switch $exr
case "*/ref/*"
set report_subfolder "ref"
case "*"
set report_subfolder "out"
end
set -l report "$report_root/$report_subfolder"
set -l scene (dirname $exr)
set -l image (basename $exr .exr)
set -l dest "$report/$image.png"
if env test ! -e "$dest" -o "$exr" -nt "$dest"
# dest doesn't exist or is outdated
echo "-- Updating $image"
"$root/build/tonemapper" "$exr"
mv "$scene/$image.png" "$dest"
end
end
end

These are some fish scripts to automate the process of tonemapping multiple files and/or placing them in your report directory.

Some assumptions I've made that you might want to adjust:

  • batch_tonemap.fish expects to be a sibling of the nori folder, the latter containing a build folder with the tonemap executable.
  • collect_images.fish expects to be two levels into your nori folder, e.g. at nori/reports/collect_images.fish. I found storing the reports within the nori folder to be useful for tracking my reports with git and to have them in the same IDE "project", if you will. Its exact functionality is described within, in the long comment.
  • The shebangs on the first line of each script are for my homebrew-based (macOS) fish installation. You might want to adjust these to fit your setup, so you can run the script directly as an executable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment