I have no ideas on the motion blurring, but grabbing the glsl viewport and the zbuffer isn’t very hard. Simply use glReadPixels() (even works correctly with alpha materials).
Unfortunately it’s pretty slow to save this buffer to an image. Below is a script that creates 2 new images inside blender (show_glsl and show_z, they can be found in the UV/Image editor window). I haven’t found a way to make this any faster.
import Blender
from Blender import Image, Window
from Blender.BGL import *
# width and height of 3d-view
windows = Window.GetScreenInfo()
for w in windows:
if w['type'] == Window.Types.VIEW3D:
xmin, ymin, xmax, ymax = w['vertices']
width = xmax-xmin
height = ymax-ymin
# reading buffers
zbuf = Buffer(GL_FLOAT, [width*height])
glReadPixels(xmin, ymin, width, height, GL_DEPTH_COMPONENT, GL_FLOAT, zbuf)
colbuf = Buffer(GL_FLOAT, [width*height, 4])
glReadPixels(xmin, ymin, width, height, GL_RGBA, GL_FLOAT, colbuf)
# creating images
try:
img_z = Image.Get('show_z')
except:
img_z = Image.New('show_z', width, height, 32)
try:
img_col = Image.Get('show_glsl')
except:
img_col = Image.New('show_glsl', width, height, 32)
# progress bar
progress = 0
progress_text = "Drawing"
Window.DrawProgressBar(progress, progress_text)
# used to calculate relative z-values
zmin = min(zbuf)
zmax = max(zbuf)
zmult = 1.0/(zmax-zmin)
for y in xrange(height):
# updating progress bar
current_progress = round((float(y)/(height-1))*100)
if current_progress-10>=progress*100:
progress = current_progress/100.0
Window.DrawProgressBar(progress, progress_text)
for x in xrange(width):
# drawing images
i = y*width + x
z = (zbuf<i>-zmin)*zmult
r,g,b,a = colbuf[i]
img_z.setPixelF(x,y,(z,z,z,1.0))
img_col.setPixelF(x,y,(r,g,b,1.0))
Window.DrawProgressBar(1,progress_text)
Hopefully this helps you a bit.
[I]Edit:
the script generates an images of the relative z-buffer (always ranges from pure white to pure black). If you want the absolute z-buffer, just replace
z = (zbuf[i]-zmin)*zmult
with:
z = zbuf[i]