Community
Arnold General Rendering Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is there an up-to-date version of the camera API example?

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
212 Views, 2 Replies

Is there an up-to-date version of the camera API example?

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


Tags (1)
Labels (1)
2 REPLIES 2
Message 2 of 3
Stephen.Blair
in reply to: Anonymous

AiCameraDestroy was removed in Arnold 5.0

  • Removed 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;
}




// Stephen Blair
// Arnold Renderer Support
Message 3 of 3
Anonymous
in reply to: Anonymous

Thanks Stephen, this is really helpful!

Niall

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report