Render process operation and querying. More...
Data Structures | |
struct | AtRenderUpdateInfo |
Additional useful information about the render, received in the render callback. More... | |
Typedefs | |
typedef AtRenderStatus(* | AtRenderUpdateCallback) (void *private_data, AtRenderUpdateType update_type, const AtRenderUpdateInfo *update_info) |
Render update callback. More... | |
Functions | |
AI_API void | AiBegin (AtSessionMode default_rs_mode=AI_SESSION_BATCH) |
Marks the beginning of a block which uses the Arnold rendering interface API. More... | |
AI_API void | AiEnd () |
Marks the end of a block which uses the Arnold rendering interface API. More... | |
AI_API bool | AiArnoldIsActive () |
Check whether the Arnold API is active (AiBegin has been called) or not. More... | |
AI_API void | AiSetSystemHandlers (AtSystemHandlerMask mask) |
Sets active handlers used by Arnold, such as the crash handler. More... | |
AI_API AtRenderSession * | AiRenderSession (AtUniverse *universe, AtSessionMode mode=AI_SESSION_BATCH) |
Create a new render session. More... | |
AI_API AtUniverse * | AiRenderSessionGetUniverse (const AtRenderSession *render_session) |
Get the universe used by a given render session. More... | |
AI_API AI_PURE const AtNode * | AiRenderSessionGetOptions (const AtRenderSession *render_session) |
Get the render options node used by a given render session. More... | |
AI_API void | AiRenderSessionDestroy (AtRenderSession *render_session) |
Destroy a render session and release any allocated resources. More... | |
AI_API AtSessionMode | AiGetSessionMode (const AtRenderSession *render_session) |
Returns the current render session's mode. More... | |
AI_API void | AiRenderAddInteractiveOutput (AtRenderSession *render_session, uint32_t output_index) |
Add the output to be displayed during fast interactive rendering. More... | |
AI_API bool | AiRenderIsInteractiveOutput (AtRenderSession *render_session, uint32_t output_index) |
Get whether the output is displayed during fast interactive rendering. More... | |
AI_API bool | AiRenderRemoveInteractiveOutput (AtRenderSession *render_session, uint32_t output_index) |
Remove the output so it is not displayed during fast interactive rendering. More... | |
AI_API void | AiRenderRemoveAllInteractiveOutputs (AtRenderSession *render_session) |
Remove the output so it is not displayed during fast interactive rendering. More... | |
AI_API bool | AiRenderSetHintBool (AtRenderSession *render_session, AtString hint, bool value) |
Set a render hint. More... | |
AI_API bool | AiRenderSetHintInt (AtRenderSession *render_session, AtString hint, int32_t value) |
Set a render hint. More... | |
AI_API bool | AiRenderSetHintFlt (AtRenderSession *render_session, AtString hint, float value) |
Set a render hint. More... | |
AI_API bool | AiRenderSetHintStr (AtRenderSession *render_session, AtString hint, AtString value) |
Set a render hint. More... | |
AI_API bool | AiRenderSetHintArray (AtRenderSession *render_session, AtString hint, AtArray *value) |
Set a render hint. More... | |
AI_API bool | AiRenderGetHintBool (const AtRenderSession *render_session, AtString hint, bool &value) |
Get a render hint. More... | |
AI_API bool | AiRenderGetHintInt (const AtRenderSession *render_session, AtString hint, int32_t &value) |
Get a render hint. More... | |
AI_API bool | AiRenderGetHintFlt (const AtRenderSession *render_session, AtString hint, float &value) |
Get a render hint. More... | |
AI_API bool | AiRenderGetHintStr (const AtRenderSession *render_session, AtString hint, AtString &value) |
Get a render hint. More... | |
AI_API bool | AiRenderGetHintArray (const AtRenderSession *render_session, AtString hint, const AtArray *&value) |
Get a render hint. More... | |
AI_API AtRenderErrorCode | AiRenderBegin (AtRenderSession *render_session, AtRenderMode mode=AI_RENDER_MODE_CAMERA, AtRenderUpdateCallback update_callback=NULL, void *callback_private_data=NULL) |
Start a render asynchronously. More... | |
AI_API AtRenderErrorCode | AiRenderEnd (AtRenderSession *render_session) |
Finalize and clean up after beginning a render. More... | |
AI_API AtRenderStatus | AiRenderGetStatus (const AtRenderSession *render_session) |
Get the current status of a render session. More... | |
AI_API void | AiRenderInterrupt (AtRenderSession *render_session, AtBlockingCall blocking=AI_NON_BLOCKING) |
Stop rendering on a render session quickly and go to a paused state. More... | |
AI_API void | AiRenderAbort (AtRenderSession *render_session, AtBlockingCall blocking=AI_NON_BLOCKING) |
Stop rendering on a render session as quickly as possible. More... | |
AI_API void | AiRenderResume (AtRenderSession *render_session) |
Resume a render session after it was paused. More... | |
AI_API void | AiRenderRestart (AtRenderSession *render_session) |
Restart a render session after it was paused. More... | |
AI_API bool | AiRenderIsAnyActive () |
Returns true if any of the existing universes is being rendered. More... | |
AI_API AtRenderErrorCode | AiRender (AtRenderSession *render_session, AtRenderMode mode=AI_RENDER_MODE_CAMERA) |
Prepares a render and wait synchronously until it is finished before returning. More... | |
Variables | |
AtRenderSession * | AtRenderUpdateInfo::render_session |
Pointer to the render session that is being executed (in case the callback is used for several render sessions) | |
AtDisplayOutput | AtRenderUpdateInfo::outputs_to_display |
Whether the outputs to be shown are none, partial, interactive, or all outputs | |
uint32_t | AtRenderUpdateInfo::pass_index |
The pass number we're on out of the total number of passes, useful for indicating progress to the user | |
uint32_t | AtRenderUpdateInfo::total_passes |
The total passes we expect to render, assuming no interruptions or errors | |
int32_t | AtRenderUpdateInfo::current_AA_samples |
The actual AA_samples for the current pass (options.AA_samples remains the original value) | |
int32_t | AtRenderUpdateInfo::current_AA_samples_max |
The actual AA_samples_max for the current pass (options.AA_samples_max remains the original value) | |
int32_t | AtRenderUpdateInfo::current_GI_diffuse_samples |
The actual GI_diffuse_samples for the current pass (options.GI_diffuse_samples remains the original value) | |
int32_t | AtRenderUpdateInfo::current_GI_specular_samples |
The actual GI_specular_samples for the current pass (options.GI_specular_samples remains the original value) | |
int32_t | AtRenderUpdateInfo::current_GI_transmission_samples |
The actual GI_transmission_samples for the current pass (options.GI_transmission_samples remains the original value) | |
int32_t | AtRenderUpdateInfo::current_GI_sss_samples |
The actual GI_sss_samples for the current pass (options.GI_sss_samples remains the original value) | |
int32_t | AtRenderUpdateInfo::current_GI_volume_samples |
The actual GI_volume_samples for the current pass (options.GI_volume_samples remains the original value) | |
Render process operation and querying.
typedef AtRenderStatus(* AtRenderUpdateCallback) (void *private_data, AtRenderUpdateType update_type, const AtRenderUpdateInfo *update_info) |
Render update callback.
This is called in the following circumstances:
If you need the new render status within the callback, use the following table which provides the equivalent status from the value of update_type:
AtRenderUpdateType | AtRenderStatus |
---|---|
AI_RENDER_UPDATE_INTERRUPT | AI_RENDER_STATUS_PAUSED |
AI_RENDER_UPDATE_BEFORE_PASS | AI_RENDER_STATUS_RENDERING |
AI_RENDER_UPDATE_DURING_PASS | AI_RENDER_STATUS_RENDERING |
AI_RENDER_UPDATE_AFTER_PASS | AI_RENDER_STATUS_RENDERING |
AI_RENDER_UPDATE_FINISHED | AI_RENDER_STATUS_FINISHED |
AI_RENDER_UPDATE_ERROR | AI_RENDER_STATUS_FAILED |
The callback returns the next status desired, but should never return AI_RENDER_STATUS_NOT_STARTED as that is reserved.
If you change the scene during the callback, it is recommended that you return AI_RENDER_STATUS_RESTARTING to go to the beginning of the pass sequence. When the scene doesn't change you probably want to return the status as listed above in the render_update_type_to_status table.
private_data | Pointer passed to AiRenderBegin(), used for whatever the callback needs |
update_type | Indicates when the callback is being called |
update_info | Extra pass, sample, and output information |
enum AtRenderMode |
enum AtRenderErrorCode |
Render error codes.
enum AtSessionMode |
Session mode.
The session mode indicates to the renderer what the purpose of the session is. When it is intended to set up the scene fully, render, and afterwards end the session without modifying or reading parameters from existing nodes, use AI_SESSION_BATCH mode. If instead the nodes will be modified after render or have their parameters accessed for some other reason, and then another render invoked, use AI_SESSION_INTERACTIVE.
Enumerator | |
---|---|
AI_SESSION_BATCH | batch mode, extra (possibly destructive) optimizations allowed |
AI_SESSION_INTERACTIVE | interactive mode, can read/write nodes after rendering |
enum AtDisplayOutput |
Outputs ready for display.
This indicates which outputs are ready for display during interactive rendering. For faster interactive rendering, Arnold may only provide pixel data on the main interactive output to improve responsiveness for the user. If the render gets to keep going, then Arnold will switch over to providing data for all AOVs/outputs.
enum AtRenderStatus |
Status of the current render.
Enumerator | |
---|---|
AI_RENDER_STATUS_NOT_STARTED | Before AiRenderBegin(), or after AiRenderEnd() |
AI_RENDER_STATUS_PAUSED | Update callback paused the render or AiRenderInterrupt() called |
AI_RENDER_STATUS_RESTARTING | Update callback is restarting the render |
AI_RENDER_STATUS_RENDERING | Currently actively rendering passes |
AI_RENDER_STATUS_FINISHED | Render done, but AiRenderEnd() not called yet |
AI_RENDER_STATUS_FAILED | Render failed, AiRenderEnd() will return the actual error code (AtRenderErrorCode) |
enum AtRenderUpdateType |
Reason for invoking the render update callback.
enum AtSystemHandlerMask |
AI_API void AiBegin | ( | AtSessionMode | default_rs_mode | ) |
Marks the beginning of a block which uses the Arnold rendering interface API.
This function initializes the Arnold rendering subsystem and "enables" the Arnold API. It must be paired with a matching AiEnd() call when all work with the Arnold API is completed.
This will also create a default universe and render session, that might be used if needed. Any other universe or render session will have to be created and destroyed explicitly.
For information about the render modes see AtSessionMode
mode | Selects batch or interactive mode for the default render session |
AI_API void AiEnd | ( | ) |
Marks the end of a block which uses the Arnold rendering interface API.
It must be coupled with a matching AiBegin() call. This function shuts down the Arnold rendering subsystem.
This will force end all active render sessions and also destroy them. All memory pools are free'd and the scene is destroyed. API calls should not be made after a call to AiEnd().
AI_API bool AiArnoldIsActive | ( | ) |
AI_API void AiSetSystemHandlers | ( | AtSystemHandlerMask | mask | ) |
Sets active handlers used by Arnold, such as the crash handler.
This function can be called anytime.
AI_API AtRenderSession * AiRenderSession | ( | AtUniverse * | universe, |
AtSessionMode | mode | ||
) |
Create a new render session.
The created render session will be tied to the given universe.
NOTE: passing the default universe or NULL will just return the default render session, instead of creating a new one
universe | Universe to be used by the new render session (NULL for default universe) |
mode | Selects batch or interactive mode for the new render session |
AI_API AtUniverse * AiRenderSessionGetUniverse | ( | const AtRenderSession * | render_session | ) |
Get the universe used by a given render session.
render_session | Pointer to a render session (NULL for default render session) |
AI_API AI_PURE const AtNode * AiRenderSessionGetOptions | ( | const AtRenderSession * | render_session | ) |
Get the render options node used by a given render session.
This render options node holds a separate set of options, initialized from the universe options but partially modified for render specific requirements. This render options are read-only. Any modification should be made through the universe options.
The differences with the universe copy of the options are mostly related to invalid values that are sanitized for rendering and temporary changes to sample values made during interactive render.
render_session | Pointer to a render session (NULL for default render session) |
AI_API void AiRenderSessionDestroy | ( | AtRenderSession * | render_session | ) |
Destroy a render session and release any allocated resources.
render_session | Pointer to the render session to destroy |
AI_API AtSessionMode AiGetSessionMode | ( | const AtRenderSession * | render_session | ) |
Returns the current render session's mode.
The session mode indicates whether node changes after render or .ass file writing are expected or not.
For information about the render modes see AtSessionMode
render_session | Pointer to the render session this function call applies to (NULL for default render session) |
AI_API void AiRenderAddInteractiveOutput | ( | AtRenderSession * | render_session, |
uint32_t | output_index | ||
) |
Add the output to be displayed during fast interactive rendering.
This adds the index into options.outputs for the output that will be updated during interactive rendering when the scene is changing. After interactive rendering is allowed to run for a while, all outputs will start being updated instead of just those added for interactive rendering.
render_session | Pointer to the render session this function call applies to (NULL for default render session) |
output_index | The index into options.outputs for the output to display |
AI_API bool AiRenderIsInteractiveOutput | ( | AtRenderSession * | render_session, |
uint32_t | output_index | ||
) |
Get whether the output is displayed during fast interactive rendering.
This checks the index into options.outputs whether the output will be updated during interactive rendering when the scene is changing. After interactive rendering is allowed to run for a while, all outputs will start being updated instead of just the interactive outputs.
render_session | Pointer to the render session this function call applies to (NULL for default render session) |
output_index | The index into options.outputs to check |
AI_API bool AiRenderRemoveInteractiveOutput | ( | AtRenderSession * | render_session, |
uint32_t | output_index | ||
) |
Remove the output so it is not displayed during fast interactive rendering.
This removes the index into options.outputs for the output so it will not be updated during interactive rendering when the scene is changing. After interactive rendering is allowed to run for a while, all outputs will start being updated instead of just those added for interactive rendering.
render_session | Pointer to the render session this function call applies to (NULL for default render session) |
output_index | The index into options.outputs for the output to not display |
AI_API void AiRenderRemoveAllInteractiveOutputs | ( | AtRenderSession * | render_session | ) |
Remove the output so it is not displayed during fast interactive rendering.
This removes the index into options.outputs for the output so it will not be updated during interactive rendering when the scene is changing. After interactive rendering is allowed to run for a while, all outputs will start being updated instead of just those added for interactive rendering.
render_session | Pointer to the render session this function call applies to (NULL for default render session) |
AI_API bool AiRenderSetHintBool | ( | AtRenderSession * | render_session, |
AtString | hint, | ||
bool | value | ||
) |
Set a render hint.
If a hint exists of this type and name, set it. Currently allowed hints of type bool:
render_session | Pointer to the render session this function call applies to (NULL for default render session) |
hint | The name of the hint |
value | The value to be set if the hint exists |
AI_API bool AiRenderSetHintInt | ( | AtRenderSession * | render_session, |
AtString | hint, | ||
int32_t | value | ||
) |
Set a render hint.
If a hint exists of this type and name, set it. Currently allowed hints of type int:
render_session | Pointer to the render session this function call applies to (NULL for default render session) |
hint | The name of the hint |
value | The value will be set if the hint exists |
AI_API bool AiRenderSetHintFlt | ( | AtRenderSession * | render_session, |
AtString | hint, | ||
float | value | ||
) |
Set a render hint.
If a hint exists of this type and name, set it. Currently allowed hints of type float are:
render_session | Pointer to the render session this function call applies to (NULL for default render session) |
hint | The name of the hint |
value | The value will be set if the hint exists |
Set a render hint.
If a hint exists of this type and name, set it. There are currently no render hints of type string.
render_session | Pointer to the render session this function call applies to (NULL for default render session) |
hint | The name of the hint |
value | The value will be set if the hint exists |
AI_API bool AiRenderSetHintArray | ( | AtRenderSession * | render_session, |
AtString | hint, | ||
AtArray * | value | ||
) |
Set a render hint.
If a hint exists of this type and name, set it. There are currently no render hints of type array.
Note: If the function succeeds the api takes ownership of the array. Do not call AiArrayDestroy.
render_session | Pointer to the render session this function call applies to (NULL for default render session) |
hint | The name of the hint |
value | The value will be set if the hint exists |
AI_API bool AiRenderGetHintBool | ( | const AtRenderSession * | render_session, |
AtString | hint, | ||
bool & | value | ||
) |
Get a render hint.
If a hint exists of this type and name, return it. Currently allowed hints of type bool:
render_session | Pointer to the render session this function call applies to (NULL for default render session) |
hint | The name of the hint |
value | The value will be written to this argument if the hint exists |
AI_API bool AiRenderGetHintInt | ( | const AtRenderSession * | render_session, |
AtString | hint, | ||
int32_t & | value | ||
) |
Get a render hint.
If a hint exists of this type and name, return it. Currently allowed hints of type int are:
render_session | Pointer to the render session this function call applies to (NULL for default render session) |
hint | The name of the hint |
value | The value will be written to this argument if the hint exists |
AI_API bool AiRenderGetHintFlt | ( | const AtRenderSession * | render_session, |
AtString | hint, | ||
float & | value | ||
) |
Get a render hint.
If a hint exists of this type and name, return it. See AiRenderGetHintFlt for currently allowed float hints.
render_session | Pointer to the render session this function call applies to (NULL for default render session) |
hint | The name of the hint |
value | The value will be written to this argument if the hint exists |
AI_API bool AiRenderGetHintStr | ( | const AtRenderSession * | render_session, |
AtString | hint, | ||
AtString & | value | ||
) |
Get a render hint.
If a hint exists of this type and name, return it. There are currently no render hints of type string.
render_session | Pointer to the render session this function call applies to (NULL for default render session) |
hint | The name of the hint |
value | The value will be written to this argument if the hint exists |
AI_API bool AiRenderGetHintArray | ( | const AtRenderSession * | render_session, |
AtString | hint, | ||
const AtArray *& | value | ||
) |
Get a render hint.
If a hint exists of this type and name, return it. There are currently no render hints of type array.
render_session | Pointer to the render session this function call applies to (NULL for default render session) |
hint | The name of the hint |
value | The value will be written to this argument if the hint exists |
AI_API AtRenderErrorCode AiRenderBegin | ( | AtRenderSession * | render_session, |
AtRenderMode | mode, | ||
AtRenderUpdateCallback | update_callback, | ||
void * | callback_private_data | ||
) |
Start a render asynchronously.
Initializes frame-dependant data and launches bucket workers (if requested).
If the mode is set to AI_RENDER_MODE_CAMERA, then Arnold will launch a number of bucket workers (i.e. threads), render the image from the camera, and write the output images (if any). However, if AI_RENDER_MODE_FREE is passed instead, then Arnold will put itself in a mode where it services ray-tracing requests only. In this mode, the user instructs Arnold to shoot rays by calling functions like AiTrace() or AiIrradiance() directly. This mode is useful in situations where the user wants to use Arnold as a "ray-tracing engine" instead of an image generator, for example to "bake" or precompute illumination into light maps. In this mode, it is usually convenient to create the render session using AI_SESSION_INTERACTIVE, specially if the user will inspect node state and parameter values.
If a render update callback is supplied, it will be invoked periodically when render passes complete, when some bucket data is ready, or when an interrupt or error occurs. The callback can update the status of the render. For interactive renders, nodes may be modified in the callback under most circumstances and the render restarted. Or, the render may be left paused, and then resumed later with AiRenderResume() or AiRenderRestart(). See more information at AtRenderUpdateCallback.
render_session | The render session that will be used for this render (NULL for default render session) |
mode | Either render an image from the camera or operate as a ray-tracing server (default is AI_RENDER_MODE_CAMERA) |
update_callback | Invoked periodically for render status updates |
AI_API AtRenderErrorCode AiRenderEnd | ( | AtRenderSession * | render_session | ) |
Finalize and clean up after beginning a render.
This will return the final success or failure of the render, and must be called to clean up after beginning a render. The status (returned from AiRenderGetStatus() API function) will be AI_RENDER_STATUS_NOT_STARTED after calling this, so that a new render may be started afterward.
render_session | Pointer to the render session (NULL for default render session) |
AI_API AtRenderStatus AiRenderGetStatus | ( | const AtRenderSession * | render_session | ) |
Get the current status of a render session.
render_session | Pointer to the render session (NULL for default render session) |
AI_API void AiRenderInterrupt | ( | AtRenderSession * | render_session, |
AtBlockingCall | blocking | ||
) |
Stop rendering on a render session quickly and go to a paused state.
This function is similar in operation to AiRenderAbort(). It instructs the render session to interrupt rendering as quickly and as cleanly as possible. This is often used by a GUI thread in an interactive rendering environment. Unlike AiRenderAbort() the render can be resumed afterwards.
If a render update callback is being used, it will be invoked as soon as the render is paused. The render may be restarted from the callback. If an update callback is not being used, then the render may be resumed via AiRenderResume() instead. The render may be ended after it is paused by calling AiRenderEnd().
render_session | Pointer to the render session (NULL for default render session) |
blocking | Whether the call blocks until the render is fully paused or not |
AI_API void AiRenderAbort | ( | AtRenderSession * | render_session, |
AtBlockingCall | blocking | ||
) |
Stop rendering on a render session as quickly as possible.
This function instructs the render session to stop rendering as quickly and as cleanly as possible. This does not happen immediately, however, as it can take some time for the bucket workers to wrap up their work.
The renderer should only be aborted in situations where there is a serious problem. To interrupt the renderer for purposes of an interactive rendering system, AiRenderInterrupt() should be used instead.
Afterwards, AiRenderEnd() should still be called to conclude clean-up.
render_session | Pointer to the render session (NULL for default render session) |
blocking | Whether the call blocks until the render is fully aborted or not |
AI_API void AiRenderResume | ( | AtRenderSession * | render_session | ) |
Resume a render session after it was paused.
After a render is paused via the render update callback returning AI_RENDER_STATUS_PAUSED, this is called to pick up where the render left off. If the render was interrupted (AiRenderInterrupt() for more info) then this will restart rendering like AiRenderRestart() does.
render_session | Pointer to the render session (NULL for default render session) |
AI_API void AiRenderRestart | ( | AtRenderSession * | render_session | ) |
Restart a render session after it was paused.
After a render is paused via AiRenderInterrupt() or because of the render update callback returning AI_RENDER_STATUS_PAUSED, this is called to restart rendering after nodes have been modified in a way that invalidates pixels that have already been rendered so far.
render_session | Pointer to the render session (NULL for default render session) |
AI_API bool AiRenderIsAnyActive | ( | ) |
Returns true if any of the existing universes is being rendered.
AI_API AtRenderErrorCode AiRender | ( | AtRenderSession * | render_session, |
AtRenderMode | mode | ||
) |
Prepares a render and wait synchronously until it is finished before returning.
This function is basically equivalent to calling AiRenderBegin(), then waiting for the render to be finished, then calling AiRenderEnd().
While the mode parameter can be used to select either CAMERA or FREE render mode (see AiRenderBegin()), it is only expected to be used in CAMERA mode, and even more specifically, only in a batch render session. This function is just a convenient way to quickly perform a render, but it is not optimized for interactive rendering.
render_session | Render session where this render will happen |
mode | Either render the image from the camera or operate as a ray-tracing server (default is AI_RENDER_MODE_CAMERA) |