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. 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!
