Hi, I'm new to the Arnold SDK and I would like to create a custom camera node that allows user control over the source and direction of each ray. The example on this page seems like it does something very similar, and could be modified to suit my needs:
https://docs.arnoldrenderer.com/display/A5ARP/Writing+a+Camera+Node
However, when I attempt to compile this example, there are numerous errors and warnings. It seems that the C++ API has been significantly refactored since this example was written, to the point where it's almost useless as an introduction for someone not already familar with Arnold development. For example, the source code calls a method called AiCameraDestroy(),which appears to no longer exist (seems that that I need to call AiNodeDestroy() instead). Would it be possible to have the example updated to compile cleanly with the current API, and in the meantime, does anyone have some example code for a camera I could take a look at, please?
Cheers,
Niall
AiCameraDestroy was removed in Arnold 5.0
AiCameraDestroy
, AiFilterDestroy
and AiDriverDestroy
. They no longer need to be called for custom cameras, filters or drivers, as this de-initialization now happens automatically inside Arnold. Here's a simple example from one of our test cases:
#include <ai.h> #include <string.h> AI_CAMERA_NODE_EXPORT_METHODS(MyCameraMethods) node_parameters { AiParameterFlt("fov", 60.f); } node_initialize { AiCameraInitialize(node); } node_update { AiCameraUpdate(node, false); } node_finish { } camera_create_ray { float fov = AiNodeGetFlt(node, "fov"); float tan_fov = tanf(fov * AI_DTOR / 2); AtVector p = AtVector(input.sx * tan_fov, input.sy * tan_fov, 1); // warp ray origin with a noise vector AtVector noise_point = { input.sx, input.sy, 0.5f }; noise_point *= 5; AtVector noise_vector = AiVNoise3(noise_point, 1, 0.f, 1.92f); output.origin = noise_vector * 0.04f; output.dir = AiV3Normalize(p - output.origin); // vignetting float dist2 = input.sx * input.sx + input.sy * input.sy; output.weight = 1 - dist2; // now looking down -Z output.dir.z *= -1; } camera_reverse_ray { return false; } node_loader { if (i != 0) return false; node->methods = MyCameraMethods; node->output_type = AI_TYPE_UNDEFINED; node->name = "mycamera"; node->node_type = AI_NODE_CAMERA; strcpy(node->version, AI_VERSION); return true; }