Example: OSL Camera Shaders

Last modified: 18 March 2025

A camera shader allows you to implement a custom camera type. You could for instance implement a fish-eye camera or you may write a shader which exactly matches the camera used to capture live footage.

There are two types of OSL cameras: the regular OSL camera, which is the usual positioned camera, and the OSL baking camera, which behaves much like the baking camera but the UV coordinate to sample and the resulting ray direction is generated by a shader.

The following is a minimal implementation of a perspective camera. It takes into account the aspect ratio of the image, and allows some of the usual camera features in octane like viewport navigation and stereo rendering.