PDA

View Full Version : stereo-projection


Andy
04-29-2008, 08:46 AM
Hello, I have question regarding stereo-projection.
I would like to produce the image for the right and left eye separately on one client, with the aid of an nvidia-quadro-card. Furthermore I would like to use a curved-screen so I need a distortion-correction and edge-blending for a multi-channel projection.
Is there a chance to do this with Viziard directly?

If not, I will have to use an aditional Software-tool from another vendor, which archives this based on OpenGL- and DirectX-commands directly on the render-engine. This tool seems to have a very high-performance but there is a problem. The tool takes the openGL-output of a window and warps this into the configured projection.
If I want to transform the image for the right and left eye on one Client I have to calculate the images each within separate windows. If I use the command “viz.STEREO” I get one big image with the information for the left and right eye. Is there a possibility to get two separate images in stead of one?

Also I’m open to other solutions regarding this problem.

farshizzo
04-29-2008, 07:54 PM
I've attached a sample script that renders the scene in stereo to a texture and displays it onto a tessellated quad. You can implement the _distortTexCoord function to return distorted texture coordinates, right now it simply returns undistorted coordinates.import viz
viz.go(viz.STEREO)

#Initialize environment
viz.clearcolor(viz.GRAY)
viz.add('gallery.ive')

#Hide scene so it is not rendered to frame buffer
viz.MainScene.visible(0,viz.WORLD)

#Distortion grid constants
GRID_WIDTH = 100
GRID_HEIGHT = 100
GRID_STEP = 5

def CreateLensDistortion(eye):

#Create render texture
tex = viz.addRenderTexture()

#Determine size of window
width,height = viz.window.getSize()
width /= 2

#Create node to render scene to a texture
lens = viz.addRenderNode(size=[width,height])
lens.attachTexture(tex)
lens.disable(eye)

#Create node to displayed rendered texture to screen
overlay = viz.addRenderNode()
overlay.setOrder(viz.POST_RENDER)
overlay.setHUD(0,GRID_WIDTH,0,GRID_HEIGHT)
overlay.disable(eye)
overlay.disable(viz.LIGHTING)

def _distortTexCoord(x,y):
#TODO: Distort texture coordinates given (x,y) vertex coordinates
return x / float(GRID_WIDTH) , y / float(GRID_HEIGHT)

#Create quad with distorted texture coordinates to display render texture
viz.startlayer(viz.QUADS)
for i in range(0,GRID_WIDTH,GRID_STEP):
for j in range(0,GRID_HEIGHT,GRID_STEP):

viz.texcoord(_distortTexCoord(i,j))
viz.vertex(i,j,0)

viz.texcoord(_distortTexCoord(i+GRID_STEP,j))
viz.vertex(i+GRID_STEP,j,0)

viz.texcoord(_distortTexCoord(i+GRID_STEP,j+GRID_S TEP))
viz.vertex(i+GRID_STEP,j+GRID_STEP,0)

viz.texcoord(_distortTexCoord(i,j+GRID_STEP))
viz.vertex(i,j+GRID_STEP,0)

quad = viz.endlayer(parent=overlay)
quad.texture(tex)

#Create lens distortion for left/right eyes
CreateLensDistortion(viz.RENDER_LEFT)
CreateLensDistortion(viz.RENDER_RIGHT)

Andy
05-02-2008, 03:23 AM
Thank you farshizoo for your reply. It seems to work very well but I had a Problem. Can you tell my why I get a complete white Screen if I use “viz.addRenderNode(size=[width,height])”? By using (size=1024,1024) it works also by viz.addRenderNode(scene = viz.MainScene). Is it ok if I use (scene = viz.MainScene)?

For my fist test I use static data’s for the texture coordinates. Have anybody a code for realtime-moving texture coordinates based on an x*x-Grid?

farshizzo
05-02-2008, 04:42 PM
By default the render node is added to the main scene, so specifying that in your code is redundant. Your graphics card might not support render textures of size [1024,1024]. Try adding the following line after you create the render node to see if it helps:lens.setBuffer(viz.RENDER_FRAME_BUFFER)This will use the standard frame buffer to copy to the render texture, instead of FBOs. Also, make sure your graphics card driver is up to date.