This sample code fills two textures using CUDA (like the simpleD3D9Texture sample code), assembles these into a DirectX surface containing the nVidia stereo tag, and finally StretchRects the surface to the DirectX back buffer. All this with high frame rates.
This basic sample code simply displays two distinct 256x256 float textures on both eyes.
This is source code and driver compatible with CUDA SDK 2.3 - and hopefully also 3.0/3.1. Tested with driver 190.38 in 3DVision discover mode on my nVidia 9600M GT equipped laptop. It uses DirectX9 and should thus be backwards compatible to windows XP - except nVidia does not offer 3DVision in current XP drivers ;)
The CUDA Texture, Surface and Screen resolution can be different (e.g. to perform higher resolution renders and display a size-reduced version on screen). In my sample the screen size is 1280x800 (16:10), the surface is in full HD (16:9) and the CUDA textures are 256x256.
Now why would you want to use CUDA for rendering in 3D? Think …
- make Optix raytrace in 3DVision without the need for expensive Quadro cards
- Implement your own custom renderer in CUDA (data visualization, voxels etc)
- Perform image processing on stereoscopic source data, etc…
- Upconvert video material from 2D to 3D with CUDA
- and other possibilities I cannot imagine now…
Download now and thank me later. Took me 3 days to puzzle all this together. Maybe it could be done a little simpler (CUDA interoperability with surface instead of textures?) - but hey it works.
I will be rendering Buddhabrot fractals with this in 3D and maybe I will try attaching Optix to this code. Cheers.