# Makefile for Radiance bench4 benchmark scene

.SUFFIXES: .unf .pic .ppm

# the default: make the image on a 3R7P2 or more recent version
all: serial.pic serial.ppm

# option: make the image on a 3R6P1 or earlier version
old: old.pic old.ppm

# option: make the image on a 3R7P2 or more recent version in parallel
smp: smp.pic smp.ppm
cluster: cluster.pic cluster.ppm


#%.ppm: %.pic
.pic.ppm:
	ra_ppm $< > $@

.unf.pic:
	pfilt -1 -e +0 -x /4 -y /4 -r .6 -m .15 $< > $@

serial.unf: scene.oct viewpoint options
	rm -f serial.unf
	time rpict @viewpoint @options -x 2048 -y 2048 -t 60 -o serial.unf scene.oct

old.unf: scene.oct viewpoint_old options_old
	rm -f old.unf
	time rpict @viewpoint_old @options_old -x 2048 -y 2048 -t 60 -o old.unf scene.oct

smp.unf: args options viewpoint
	rm -f smp.unf smp.amb
	time ./runsmp

cluster.unf: args options viewpoint
	echo "Cluster calculation not supported yet. Sorry!"
#	time runcluster

args: viewpoint options scene.oct
	echo '-af smp.amb -x 2048 -y 2048 -o smp.unf scene.oct' > args

scene.oct: materials.rad scene.rad lens.obj foreground.rad lens.rad
	obj2mesh -n 15 -r 16384 lens.obj > lens.msh
	oconv -f -n 6 -r 16384 materials.rad cube2f.rad > cube2f_instance.oct
	oconv -f -n 6 -r 16384 materials.rad cube4f.rad > cube4f_instance.oct
	oconv -n 6 -r 16384 materials.rad scene.rad > scene.oct

clean:
	rm args syncfile pp serial.pic old.pic smp.pic *.oct *.unf lens.msh *.amb
