OSL Camera

 

The OSL Camera node is a scriptable node. You can create custom camera types for any purpose (such as VRImmersively engaging and experiencing depth perception in a three dimensional scene through stereo vision goggles and head-mounted displays. warping) with OSL (Open Shader LanguageA shading language developed by Sony Pictures Imageworks. There are multiple render engines that utilize OSL as it is particularly suited for physically-based renderers.) scripts. It is a flexible camera used to match the rendering to the existing footage. One OSL Camera is one OSL compilation unit, which contains one shader, so it has one output attribute pin that connects to a Render Target node's Camera input pin. OSL is a standard created by Sony Imageworks. To learn about the generic OSL standard, information is provided from the OSL Readme and PDF documentation.

OSL_Camera_Fig01_Blender_2019

Figure 1: The OSL Camera Option

 

The OSL Camera node is enabled from Blender's Shader Editor window. There are two options for OSL cameras: the OSL camera, and the OSL Baking camera. See the Octane Baking Layers topic in this manual for more details on these Cameras. Add the OSL camera to a MaterialThe representation of the surface or volume properties of an object. (Figure 2) to access the Material and corresponding OSL camera node in the Camera tab (Figure 3).

OSL_Camera_Fig02_Blender_2019

Figure 2: Adding an OSL Camera node to an Octane material

 

OSL_Camera_Fig03_Blender_2019

Figure 3: Accessing the OSL camera material and OSL camera node in the OSL Camera rollout

 

There are two options to add scripts for the OSL texture. The Internal option is available by opening another area in Blender® for the Text Editor, creating a new text, and writing the OSL script. The External option lets you to select a pre-coded OSL file from the File Explorer window.

You can create your own custom Camera using an OSL camera node. As a starting point, below is a basic OSL implementation of a Thin Lens camera:

shader OslCamera(
float FocalLength = 1 [[ float min = 0.1, float max = 1000, float sliderexponent = 4]],
output point pos = 0,
output vector dir = 0,
output float tMax = 1.0/0.0)
{
float pa;
int res[2];
getattribute("camera:pixelaspect", pa);
getattribute("camera:resolution", res);
float u1 = 2 * (u - .5);
float v1 = 2 * (v - .5) * pa * res[1] / res[0];
pos = P;
vector right = cross(I, N);
dir = 2*FocalLength * I + v1 * N + u1 * right;
dir = transform("camera", "world", dir);
}

For a list of OSL variable declaration input/output types in the OSL Specification that OctaneRender® supports, refer to the Appendix topic on OSL Implementation in the OctaneRender® Standalone manual. To learn more about scripting within OctaneRender® using OSL, see to The Octane OSL Guide.