DK2 capture: my chromatic aberration removal shader
When capturing gameplay video with OBS or other video capture software, it's captured with the oculus chromatic aberration, resulting in the colorful rainbow we're used to. This type of image compresses really poorly with the codecs usually implemented in the capture software and the end result looks muddled. It's even worse if you try to remove the chroma offsets after the fact in editing, because now the compression has mixed the color channel data around.
Luckily, OBS does a gamma/color correction pass on all captured footage in a plaintext pixelshader, so I wrote a rough eyeballed shader to remove the chromatic aberration effect, so it can be saved directly with better quality in the usual RGB format. I expect this should work for streaming as well, though I have not tested it.
Here's what it looks like, when enabled.
The text at the edges would be a fabulous rainbow if it wasn't for the correction.
I also added a function to only take the other eye and zoom it.
This might be useful if you're not interested in stereo capture nor want to waste compression bitrate for it. Also, zooming before compression might result in better final product.
Akheir also did a nice colorful gameplay video that well illustrates the end result.
And here's me doing something really dumb in Elite:Dangerous.
You can adjust all these settings in the shader file.
You should also set your eye-relief setting as it does slightly affect the outcome.
Place the shader in your C:\Program Files\OBS\shaders or equivalent location. (note that 32bit and 64bit OBS are installed in separate folders)
On startup, OBS will notice the change and thinks the file is out of date - answer 'no' to update suggestion.
The shader file is reloaded every time you start preview or recording, so OBS restart is not required when experimenting with settings or code changes.
- v20150108 - optimized eye bounds checking - pastebin mirror
- v20150103 - added bounds checks for single eye rendering, added eye placement coordinates
- v20150102 - initial version
Technical crappiness, future features?
The values I have used in the shader were achieved by just eyeballing it. The color offsets are also achieved by just scaling the individual color channels, which is probably not the right way to go about it, but it's fast and there's little to be gained with more complex math.
I have not bothered with geometric undistortion as I personally quite like the fisheyeish effect, and it might have an impact on performance.
Improvements and suggestions are welcome.
Posted Jan 2, 2015, 6:38 PM UTC · edited