Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Solitius's avatar
Solitius
Honored Guest
12 years ago

Help with lens distortion in DirectX

I'm trying to implement the lens distortion correction in my own DirectX 11 based engine, but I'm a bit rusty at DirectX and I'm having trouble wrapping my head around all the necessary steps. Please correct me if i'm mistaken. I need to...

1. Create a 1280*800 ID3D11Texture2D with "D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE"-flags.
2. Create two viewport 640*800 (one for each eye) each covering the 0-640, 641-1280 vertical span.
3. Use texture in "1." as a RenderTarget and render the scene "twice" using each viewport.
4. Switch to ordinary RenderTarget, bind texture "1." as a ShaderResource to the PixelShader and sample the texture by distorting texture coordinates using the distortion-technique described in the SDK-documentation pdf.

To be more specific, is the input texture to the PixelShader supposed to be of dimension 1280*800, containing left and right images combined (if so, which part of the code in the SDK makes the distinction between sampling from the left or right image?) or are you supposed to feed the left and right image separately in some other way? Also please correct me if I have made some other reasoning mistake along the way.

Thank you for your help!

1 Reply

  • As far as I can tell, you're right in that they use a post processing shader to distort the image. However, one can apparently get the distortion they need without making it as blurry by putting the distortion prior to rendering the image (ie don't use post-processing shaders)

    See the mtbs3d thread here It would seem that we had ought to be using that as our current best practices.

    Edit: This doesn't solve your right-and-left eye question, but I believe it does the job for the distortion.