ai_render.h
Go to the documentation of this file.
1// Copyright 2023 Autodesk, Inc. All rights reserved.
2//
3// Use of this software is subject to the terms of the Autodesk license
4// agreement provided at the time of installation or download, or which
5// otherwise accompanies this software in either electronic or hard copy form.
6
12#pragma once
13#include "ai_api.h"
14#include "ai_array.h"
15#include "ai_string.h"
16#include <stddef.h> // NULL
17#include <stdint.h> // uint32_t etc
18
26// forward declares
27struct AtNode;
28class AtRenderSession;
29class AtUniverse;
30
35{
38};
39
44{
55};
56
68{
71};
72
83{
88};
89
94{
102
107{
116
128{
129 AtRenderSession* render_session;
131 uint32_t pass_index;
132 uint32_t total_passes;
140};
141
206typedef AtRenderStatus (*AtRenderUpdateCallback)(void *private_data, AtRenderUpdateType update_type, const AtRenderUpdateInfo *update_info);
207
208AI_API void AiBegin(AtSessionMode mode = AI_SESSION_BATCH);
209AI_API void AiEnd();
210AI_API bool AiArnoldIsActive();
211
212AI_API AtRenderSession* AiRenderSession(AtUniverse* universe, AtSessionMode mode = AI_SESSION_BATCH);
213AI_API AtUniverse* AiRenderSessionGetUniverse(const AtRenderSession* render_session);
214AI_API AI_PURE const AtNode* AiRenderSessionGetOptions(const AtRenderSession* render_session);
215AI_API void AiRenderSessionDestroy(AtRenderSession* render_session);
216
217AI_API AtSessionMode AiGetSessionMode(const AtRenderSession* render_session);
218
219AI_API void AiRenderAddInteractiveOutput(AtRenderSession* render_session, uint32_t output_index);
220AI_API bool AiRenderIsInteractiveOutput(AtRenderSession* render_session, uint32_t output_index);
221AI_API bool AiRenderRemoveInteractiveOutput(AtRenderSession* render_session, uint32_t output_index);
222AI_API void AiRenderRemoveAllInteractiveOutputs(AtRenderSession* render_session);
223
224AI_API bool AiRenderSetHintBool(AtRenderSession* render_session, AtString hint, bool value);
225AI_API bool AiRenderSetHintInt(AtRenderSession* render_session, AtString hint, int32_t value);
226AI_API bool AiRenderSetHintFlt(AtRenderSession* render_session, AtString hint, float value);
227AI_API bool AiRenderSetHintStr(AtRenderSession* render_session, AtString hint, AtString value);
228AI_API bool AiRenderSetHintArray(AtRenderSession* render_session, AtString hint, AtArray *value);
229AI_API bool AiRenderGetHintBool(const AtRenderSession* render_session, AtString hint, bool& value);
230AI_API bool AiRenderGetHintInt(const AtRenderSession* render_session, AtString hint, int32_t& value);
231AI_API bool AiRenderGetHintFlt(const AtRenderSession* render_session, AtString hint, float& value);
232AI_API bool AiRenderGetHintStr(const AtRenderSession* render_session, AtString hint, AtString& value);
233AI_API bool AiRenderGetHintArray(const AtRenderSession* render_session, AtString hint, const AtArray*& value);
234
235AI_API AtRenderErrorCode AiRenderBegin(AtRenderSession* render_session, AtRenderMode mode = AI_RENDER_MODE_CAMERA, AtRenderUpdateCallback update_callback = NULL, void* callback_private_data = NULL);
236AI_API AtRenderErrorCode AiRenderEnd(AtRenderSession* render_session);
237AI_API AtRenderStatus AiRenderGetStatus(const AtRenderSession* render_session);
238AI_API void AiRenderInterrupt(AtRenderSession* render_session, AtBlockingCall blocking = AI_NON_BLOCKING);
239AI_API void AiRenderAbort(AtRenderSession* render_session, AtBlockingCall blocking = AI_NON_BLOCKING);
240AI_API void AiRenderResume(AtRenderSession* render_session);
241AI_API void AiRenderRestart(AtRenderSession* render_session);
242AI_API bool AiRenderIsAnyActive();
243AI_API AtRenderErrorCode AiRender(AtRenderSession* render_session, AtRenderMode mode = AI_RENDER_MODE_CAMERA);
244
245/*\}*/
DLL export prefix for API functions (necessary for multi-platform development)
AtBlockingCall
Whether a function call is blocking (synchronous) or not (asynchronous)
Definition: ai_api.h:147
@ AI_NON_BLOCKING
asynchronous, non-blocking call; returns ASAP, task completes in the background
Definition: ai_api.h:149
Generic array data type and methods.
AtString class for fast comparisons.
Arnold String allows for fast string comparisons.
Definition: ai_string.h:46
AtRenderErrorCode
Render error codes.
Definition: ai_render.h:44
AI_API bool AiRenderSetHintFlt(AtRenderSession *render_session, AtString hint, float value)
Set a render hint.
Definition: ai_render.cpp:661
AtSessionMode
Session mode.
Definition: ai_render.h:68
AI_API void AiRenderRestart(AtRenderSession *render_session)
Restart a render session after it was paused.
Definition: ai_render.cpp:929
AI_API AtRenderSession * AiRenderSession(AtUniverse *universe, AtSessionMode mode=AI_SESSION_BATCH)
Create a new render session.
Definition: ai_render.cpp:1067
int32_t current_AA_samples
The actual AA_samples for the current pass (options.AA_samples remains the original value)
Definition: ai_render.h:133
AI_API bool AiRenderSetHintStr(AtRenderSession *render_session, AtString hint, AtString value)
Set a render hint.
Definition: ai_render.cpp:701
AI_API AtSessionMode AiGetSessionMode(const AtRenderSession *render_session)
Returns the current render session's mode.
Definition: ai_render.cpp:102
AI_API bool AiRenderRemoveInteractiveOutput(AtRenderSession *render_session, uint32_t output_index)
Remove the output so it is not displayed during fast interactive rendering.
Definition: ai_render.cpp:153
int32_t current_GI_volume_samples
The actual GI_volume_samples for the current pass (options.GI_volume_samples remains the original val...
Definition: ai_render.h:139
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.
Definition: ai_render.cpp:843
int32_t current_AA_samples_max
The actual AA_samples_max for the current pass (options.AA_samples_max remains the original value)
Definition: ai_render.h:134
AI_API void AiRenderAddInteractiveOutput(AtRenderSession *render_session, uint32_t output_index)
Add the output to be displayed during fast interactive rendering.
Definition: ai_render.cpp:127
AI_API bool AiRenderSetHintArray(AtRenderSession *render_session, AtString hint, AtArray *value)
Set a render hint.
Definition: ai_render.cpp:760
AtRenderUpdateType
Reason for invoking the render update callback.
Definition: ai_render.h:107
uint32_t pass_index
The pass number we're on out of the total number of passes, useful for indicating progress to the use...
Definition: ai_render.h:131
AtRenderStatus(* AtRenderUpdateCallback)(void *private_data, AtRenderUpdateType update_type, const AtRenderUpdateInfo *update_info)
Render update callback.
Definition: ai_render.h:206
AI_API void AiRenderResume(AtRenderSession *render_session)
Resume a render session after it was paused.
Definition: ai_render.cpp:907
AtRenderMode
Render modes.
Definition: ai_render.h:35
AI_API bool AiArnoldIsActive()
Check whether the Arnold API is active (AiBegin has been called) or not.
Definition: ai_render.cpp:85
AI_API bool AiRenderIsInteractiveOutput(AtRenderSession *render_session, uint32_t output_index)
Get whether the output is displayed during fast interactive rendering.
Definition: ai_render.cpp:203
AI_API bool AiRenderGetHintArray(const AtRenderSession *render_session, AtString hint, const AtArray *&value)
Get a render hint.
Definition: ai_render.cpp:486
AtRenderSession * render_session
Pointer to the render session that is being executed (in case the callback is used for several render...
Definition: ai_render.h:129
AI_API AI_PURE const AtNode * AiRenderSessionGetOptions(const AtRenderSession *render_session)
Get the render options node used by a given render session.
Definition: ai_render.cpp:1101
AI_API bool AiRenderGetHintInt(const AtRenderSession *render_session, AtString hint, int32_t &value)
Get a render hint.
Definition: ai_render.cpp:286
AI_API bool AiRenderSetHintInt(AtRenderSession *render_session, AtString hint, int32_t value)
Set a render hint.
Definition: ai_render.cpp:590
int32_t current_GI_transmission_samples
The actual GI_transmission_samples for the current pass (options.GI_transmission_samples remains the ...
Definition: ai_render.h:137
uint32_t total_passes
The total passes we expect to render, assuming no interruptions or errors
Definition: ai_render.h:132
AtDisplayOutput outputs_to_display
Whether the outputs to be shown are none, partial, interactive, or all outputs
Definition: ai_render.h:130
AI_API AtRenderStatus AiRenderGetStatus(const AtRenderSession *render_session)
Get the current status of a render session.
Definition: ai_render.cpp:885
AI_API void AiRenderAbort(AtRenderSession *render_session, AtBlockingCall blocking=AI_NON_BLOCKING)
Stop rendering on a render session as quickly as possible.
Definition: ai_render.cpp:1007
AtDisplayOutput
Outputs ready for display.
Definition: ai_render.h:83
int32_t current_GI_diffuse_samples
The actual GI_diffuse_samples for the current pass (options.GI_diffuse_samples remains the original v...
Definition: ai_render.h:135
AI_API void AiBegin(AtSessionMode mode=AI_SESSION_BATCH)
Marks the beginning of a block which uses the Arnold rendering interface API.
Definition: ai_render.cpp:47
AI_API AtRenderErrorCode AiRenderEnd(AtRenderSession *render_session)
Finalize and clean up after beginning a render.
Definition: ai_render.cpp:867
int32_t current_GI_sss_samples
The actual GI_sss_samples for the current pass (options.GI_sss_samples remains the original value)
Definition: ai_render.h:138
int32_t current_GI_specular_samples
The actual GI_specular_samples for the current pass (options.GI_specular_samples remains the original...
Definition: ai_render.h:136
AI_API void AiRenderSessionDestroy(AtRenderSession *render_session)
Destroy a render session and release any allocated resources.
Definition: ai_render.cpp:1120
AI_API bool AiRenderSetHintBool(AtRenderSession *render_session, AtString hint, bool value)
Set a render hint.
Definition: ai_render.cpp:524
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.
Definition: ai_render.cpp:1041
AI_API bool AiRenderGetHintStr(const AtRenderSession *render_session, AtString hint, AtString &value)
Get a render hint.
Definition: ai_render.cpp:444
AI_API void AiRenderRemoveAllInteractiveOutputs(AtRenderSession *render_session)
Remove the output so it is not displayed during fast interactive rendering.
Definition: ai_render.cpp:177
AI_API AtUniverse * AiRenderSessionGetUniverse(const AtRenderSession *render_session)
Get the universe used by a given render session.
Definition: ai_render.cpp:1078
AI_API bool AiRenderGetHintBool(const AtRenderSession *render_session, AtString hint, bool &value)
Get a render hint.
Definition: ai_render.cpp:230
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.
Definition: ai_render.cpp:959
AI_API void AiEnd()
Marks the end of a block which uses the Arnold rendering interface API.
Definition: ai_render.cpp:65
AI_API bool AiRenderIsAnyActive()
Returns true if any of the existing universes is being rendered.
Definition: ai_render.cpp:1019
AI_API bool AiRenderGetHintFlt(const AtRenderSession *render_session, AtString hint, float &value)
Get a render hint.
Definition: ai_render.cpp:331
AtRenderStatus
Status of the current render.
Definition: ai_render.h:94
@ AI_ERROR_VALIDATION
usage not validated
Definition: ai_render.h:49
@ AI_INTERRUPT
render interrupted by user
Definition: ai_render.h:51
@ AI_ERROR
generic error
Definition: ai_render.h:54
@ AI_ERROR_NO_CAMERA
camera not defined
Definition: ai_render.h:47
@ AI_SUCCESS
no error
Definition: ai_render.h:45
@ AI_ERROR_BAD_CAMERA
bad camera data
Definition: ai_render.h:48
@ AI_ABORT
render aborted
Definition: ai_render.h:46
@ AI_ERROR_RENDER_REGION
invalid render region
Definition: ai_render.h:50
@ AI_ERROR_NO_OUTPUTS
no rendering outputs
Definition: ai_render.h:52
@ AI_ERROR_UNAVAILABLE_DEVICE
Cannot create GPU context
Definition: ai_render.h:53
@ AI_SESSION_BATCH
batch mode, extra (possibly destructive) optimizations allowed
Definition: ai_render.h:69
@ AI_SESSION_INTERACTIVE
interactive mode, can read/write nodes after rendering
Definition: ai_render.h:70
@ AI_RENDER_UPDATE_INTERRUPT
Callback invoked after render is interrupted and paused, can change the scene.
Definition: ai_render.h:108
@ AI_RENDER_UPDATE_FINISHED
Callback invoked after the final render pass is done, can change the scene
Definition: ai_render.h:112
@ AI_RENDER_UPDATE_IMAGERS
Callback invoked for an imager update
Definition: ai_render.h:114
@ AI_RENDER_UPDATE_ERROR
Callback invoked when an error or abort occurs, and the render has failed
Definition: ai_render.h:113
@ AI_RENDER_UPDATE_AFTER_PASS
Callback invoked after a non-final render pass is done, can change the scene
Definition: ai_render.h:111
@ AI_RENDER_UPDATE_BEFORE_PASS
Callback invoked just before render pass is to begin, can change the scene
Definition: ai_render.h:109
@ AI_RENDER_UPDATE_DURING_PASS
Callback invoked during render pass after some pixel data is ready; not currently invoked,...
Definition: ai_render.h:110
@ AI_RENDER_MODE_CAMERA
Render from a camera.
Definition: ai_render.h:36
@ AI_RENDER_MODE_FREE
Process arbitrary ray-tracing requests, acting as a "ray server".
Definition: ai_render.h:37
@ AI_DISPLAY_OUTPUT_ALL
all outputs are getting updated, any output can be displayed
Definition: ai_render.h:87
@ AI_DISPLAY_OUTPUT_PARTIAL_INTERACTIVE
interactive output updated but not the whole image; put on screen anyway
Definition: ai_render.h:86
@ AI_DISPLAY_OUTPUT_NONE
no updates ready; check render status or error code
Definition: ai_render.h:84
@ AI_DISPLAY_OUTPUT_INTERACTIVE
interactive output updated fully, display on screen
Definition: ai_render.h:85
@ AI_RENDER_STATUS_RENDERING
Currently actively rendering passes
Definition: ai_render.h:98
@ AI_RENDER_STATUS_NOT_STARTED
Before AiRenderBegin(), or after AiRenderEnd()
Definition: ai_render.h:95
@ AI_RENDER_STATUS_FAILED
Render failed, AiRenderEnd() will return the actual error code (AtRenderErrorCode)
Definition: ai_render.h:100
@ AI_RENDER_STATUS_RESTARTING
Update callback is restarting the render
Definition: ai_render.h:97
@ AI_RENDER_STATUS_PAUSED
Update callback paused the render or AiRenderInterrupt() called
Definition: ai_render.h:96
@ AI_RENDER_STATUS_FINISHED
Render done, but AiRenderEnd() not called yet
Definition: ai_render.h:99
This represents a node in Arnold.
Additional useful information about the render, received in the render callback.
Definition: ai_render.h:128
This represents a universe in Arnold.

© 2022 Autodesk, Inc. · All rights reserved · www.arnoldrenderer.com