ArucoUnity icon indicating copy to clipboard operation
ArucoUnity copied to clipboard

Use shaders for image undistortion

Open NormandErwan opened this issue 7 years ago • 2 comments

Instead of using the slow remap function on CPU, it would be better to undistort the camera image with a shader on GPU as Steptoe did with its AR-Rift : http://willsteptoe.com/post/67401705548/ar-rift-aligning-tracking-and-video-spaces-part for pinhole cameras

To shaders are needed : one for pinhole undistortion, and one for omnidir undistortion.

NormandErwan avatar Apr 12 '18 13:04 NormandErwan

I never got a chance to actually implement this correctly into the repo and make a pull request but I did make a shader for this which seemed to increase performance by a lot. This is only the omnidir one but using this one as a guide the pinhole one should be pretty straightforward. Just leaving this here in case it helps someone. https://github.com/MatthewHallberg/WalmartJarvis/blob/main/Assets/Shaders/UnDistort.shader

MatthewHallberg avatar Aug 19 '21 14:08 MatthewHallberg

Sorry forgot something, I was getting the inverse of the rectified cam matrices before passing it into the shader: https://github.com/MatthewHallberg/WalmartJarvis/blob/main/Assets/Scripts/Undistort.cs and the shader also uses this remap function: https://github.com/MatthewHallberg/WalmartJarvis/blob/main/Assets/Shaders/Interpolation.cginc Also, thank you for this amazing repo!

MatthewHallberg avatar Aug 19 '21 14:08 MatthewHallberg