Skip to content

Instantly share code, notes, and snippets.

@cnaude
Last active October 9, 2018 14:54
Show Gist options
  • Save cnaude/ef16e67037a56e2e84aff0f69e04c2c6 to your computer and use it in GitHub Desktop.
Save cnaude/ef16e67037a56e2e84aff0f69e04c2c6 to your computer and use it in GitHub Desktop.
Quick and dirty Chunky time lapse rendering
#!/bin/bash
SPP=150
#WIDTH=950
#HEIGHT=540
WIDTH=1920
HEIGHT=1080
CPULOAD=100
THREADS=3
SCENE=syc_zig
BACKUPDIR=/backups/aardmc/syc_zig
MYDIR=/shares/misc/chunky_renders/${SCENE}_hourly
WORLD=${MYDIR}/world
CHUNKY_HOME=/home/cnaude/Minecraft/Chunky
SCENES=${CHUNKY_HOME}/scenes/
CHUNKY="java -Xmx4G -Dchunky.home=${CHUNKY_HOME} -jar ${CHUNKY_HOME}/ChunkyLauncher.jar"
RPDIR=/home/cnaude/Minecraft/ResourcePacks
RPACKS="${RPDIR}/PERSISTENCE.zip:${RPDIR}/1.12.jar"
REGIONS="r.0.1.mca"
CHUNKY_VERSION="1.4.5"
#CHUNKY_VERSION="latest"
CHUNKY_MEMORY_LIMIT="4000"
$CHUNKY -set "lastWorld" "${WORLD}"
$CHUNKY -set "lastTexturePack" "${RPACKS}"
$CHUNKY -set "sceneDirectory" "${SCENES}"
$CHUNKY -set "numThreads" "${THREADS}"
$CHUNKY -set "cpuLoad" "${CPULOAD}"
$CHUNKY -set "world.path" "${WORLD}" $SCENE
$CHUNKY -set "width" "${WIDTH}" $SCENE
$CHUNKY -set "height" "${HEIGHT}" $SCENE
if [ ! -d $MYDIR ]; then
echo "** Creating $MYDIR"
mkdir -p $MYDIR
fi
if [ -d $WORLD ]; then
echo "** Removing $WORLD"
rm -rf $WORLD
fi
for FILE in $(ls $BACKUPDIR/*gz)
do
if [[ -d "${WORLD}" ]]; then
echo "** Removing $WORLD"
rm -rf $WORLD
fi
MD5=$(md5sum $FILE | awk '{print $1}')
echo "** Checking for $MD5"
grep $MD5 $MYDIR/skip.list
if [[ $? -eq 0 ]]; then
echo "** Skipping $FILE"
continue
fi
rm -rf $SCENES/${SCENE}.octree*
rm -rf $SCENES/${SCENE}.dump*
rm -rf $SCENES/${SCENE}.grass*
rm -rf $SCENES/${SCENE}.foliag*
FRAME=$(echo $FILE | sed 's/.tar.gz//g' | sed 's/.*world-//g')
SKIP=0
if [ -f "$MYDIR/$FRAME.png" ]; then
echo "** Skipping $FILE"
SKIP=1
fi
echo "** Extracting $FILE"
tar -C $MYDIR -xzf $FILE
> $MYDIR/current.md5
for R in $REGIONS
do
md5sum $WORLD/region/$R >> $MYDIR/current.md5
done
if [[ $SKIP -eq 1 ]]; then
mv $MYDIR/current.md5 $MYDIR/previous.md5
echo $MD5 >> $MYDIR/skip.list
continue
fi
if [[ -f $MYDIR/previous.md5 ]]; then
echo "** Comparing md5 with previous"
diff $MYDIR/current.md5 $MYDIR/previous.md5
if [[ $? -eq 0 ]]; then
echo "** Previous md5 matches current. Skipping frame."
echo $MD5 >> $MYDIR/skip.list
continue
fi
else
echo "** No md5 to compare"
mv $MYDIR/current.md5 $MYDIR/previous.md5
fi
nice -n 20 $CHUNKY -render $SCENE -target $SPP
if [ $? == 0 ]; then
nice -n 20 $CHUNKY -snapshot $SCENE $MYDIR/$FRAME.png
mv $MYDIR/current.md5 $MYDIR/previous.md5
echo $MD5 >> $MYDIR/skip.list
fi
done
if [[ -d "${WORLD}" ]]; then
echo "** Removing $WORLD"
rm -rf $WORLD
fi
@johenkel
Copy link

johenkel commented Oct 9, 2018

Great script.
I am trying to render a full map view of a world and the chunkList array is rather large.
Do you have nay idea how to insert the chunkList array into a scene via commandline in order to run the entire process headless ?
The world (10k block radius) is too big to open in the Chunky gui to manually select chunks for a scene.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment