The Occlusion challenge

Blitz3D Forums/Blitz3D Programming/The Occlusion challenge

I devised a color id VIS compilation system similar to jfk's. In fact, our algorithms are practically identical:

;frankie t's identify color by uniqueness (icu) algorithm
array vis(n,n,n)
global worldscale#=.1

loadanimmesh levelmap.b3d

for each childmesh within mesh
	apply unique color equal to childmesh index
	set childmesh attributes to fullbright, flat shading, disable fog, disable backface culling, no texture
next

repeat 
	increment camera through level map geometry on x,y,z planes
	cameraPosition camera,{camera.increment * worldscale#}
	vis(camera.increment.x%,camera.increment.y%,camera.increment.z%)=create bank
	for cameraAngles% = 1 to 6;(up,down,left,right,front,behind)
		cameraAngle camera
		snapshot=cameraSnapshot(camera)
		for each snapshot
			for x = 0 to snapshotWidth
				for y = 0 to snapshotHeight
					color%=readpixel(snapshot,x,y)
					if color>0 and not on vis(camera.increment.x%,camera.increment.y%,camera.increment.z%)
						poke(vis(camera.increment.x%,camera.increment.y%,camera.increment.z%),++,color)
					endif					
				next
			next	
		next
	next
until camera completes level



I have found "Identify Color by Uniqueness" method to be very flexible, easy to implement, and faster than most. It works for convex/concave geometry. You can also precalcuate mesh-switching LOD with it.

The process is extremly slow on older machines. To solve this problem, I was rewriting the compiler to split the compilation task among multiple agent PCs. This multi-processing approach is commonly taken with other task that have long compilation times such as cgi.

However, I could live with TeraBit's compilation times. So I guess all I need to do is get a faster machine.