Specifying Objects, Components, and Contexts
Nau allows users to access objects, and their fields (components) inside a XML project and material library. For instance a shader may need to access the camera’s direction, or we may want to display a color in the interface.
The following objects can be accessed in a XML project or Lua script: BUFFER, BUFFER_BINDING, BUFFER_MATERIAL, CAMERA, COLOR, IMAGE_TEXTURE, LIGHT, PASS, PASS_POST_PROCESS_BUFFER, PASS_POST_PROCESS_TEXTURE, PASS_PRE_PROCESS_BUFFER, PASS_PRE_PROCESS_TEXTURE, RENDERER, RENDER_TARGET, SCENE, SCENE_OBJECT, SPHERE, STATE, TEXTURE, TEXTURE_BINDING, TEXTURE_MATERIAL, VIEWPORT.
To access a component
of an object we need to first specify which particular object we want. This is defined in the context
field. The name of the object, as defined in the XML file is one option for this field. Another option is “CURRENT”. This mode allows access to the current object, where current is the object currently set in the renderer.
Consider a pass with a camera. When the pass is being renderered, the pass becomes the current pass, and the camera becomes also the current camera.
For instance to define a uniform variable named Pos
with the position of the current camera we may write
<valueof uniform="Pos" type="CAMERA" context="CURRENT" component="POSITION" />
The same goal can be achieved specifying the name of the camera, as defined in the assets section of the project.
<valueof uniform="Pos" type="CAMERA" context="MyCamera" component="POSITION" />
The result is the same, but the previous definition is more generic as the uniform will be correctly set for passes with different cameras.
A pass contains scenes, which are composed of meshes associated with materials. Rendering a mesh implies rendering all its meshes. When rendering a mesh, its associated material also becomes the current material. The material’s elements (color, state, buffers, textures and image textures) can be accessed using CURRENT as well.
For instance to pass the diffuse color as specified in the current material to a uniform variable diff
we can write:
<valueof uniform="diffuse" type="COLOR" context="CURRENT" component="DIFFUSE" />
The same logic applies to the interface elements and optix variables. Lua scripting interface follows the same rules, with scripts having access to components of objects (current, or by name), and also being able to set their values.
The full list of object types and components is presented below. Note that some objects are read only, i.e. can not be set in the XML project, nor using lua scripts, or modified by the interface windows.:
Object Type and Components:
BUFFER
CLEAR
(read/write) – ENUM {NEVER BY_FRAME } default: NEVERDIM
(read/write) – UIVEC3 default: (1, 1, 1)ID
(read only) – INT default: -1SIZE
(read/write) – UINT default: 0STRUCT_SIZE
(read only) – UINT default: 0
BUFFER_BINDING
BINDING_POINT
(read/write) – INT default: -1TYPE
(read/write) – ENUM {ATOMIC_COUNTER SHADER_STORAGE } default:
BUFFER_MATERIAL
CLEAR
(read/write) – ENUM {NEVER BY_FRAME } default: NEVERDIM
(read/write) – UIVEC3 default: (1, 1, 1)ID
(read only) – INT default: -1SIZE
(read/write) – UINT default: 0STRUCT_SIZE
(read only) – UINT default: 0
CAMERA
BOTTOM
(read/write) – FLOAT default: -1.000000ELEVATION_ANGLE
(read/write) – FLOAT default: 0.000000FAR
(read/write) – FLOAT default: 10000.000000FOV
(read/write) – FLOAT default: 60.000000LEFT
(read/write) – FLOAT default: -1.000000LOOK_AT_POINT
(read/write) – VEC4 default: (0.000000, 0.000000, -1.000000, 1.000000)NEAR
(read/write) – FLOAT default: 1.000000NORMALIZED_RIGHT
(read only) – VEC4 default: (1.000000, 0.000000, 0.000000, 0.000000)NORMALIZED_UP
(read only) – VEC4 default: (0.000000, 1.000000, 0.000000, 0.000000)POSITION
(read/write) – VEC4 default: (0.000000, 0.000000, 0.000000, 1.000000)PROJECTION_INVERSE_MATRIX
(read only) – MAT4 default: [ 1.000000, 0.000000, 0.000000, 0.000000
0.000000, 1.000000, 0.000000, 0.000000
0.000000, 0.000000, 1.000000, 0.000000
0.000000, 0.000000, 0.000000, 1.000000 ]PROJECTION_MATRIX
(read only) – MAT4 default: [ 1.000000, 0.000000, 0.000000, 0.000000
0.000000, 1.000000, 0.000000, 0.000000
0.000000, 0.000000, 1.000000, 0.000000
0.000000, 0.000000, 0.000000, 1.000000 ]PROJECTION_VIEW_MATRIX
(read only) – MAT4 default: [ 1.000000, 0.000000, 0.000000, 0.000000
0.000000, 1.000000, 0.000000, 0.000000
0.000000, 0.000000, 1.000000, 0.000000
0.000000, 0.000000, 0.000000, 1.000000 ]RIGHT
(read/write) – FLOAT default: 1.000000TOP
(read/write) – FLOAT default: 1.000000TS05_PVM_MATRIX
(read only) – MAT4 default: [ 1.000000, 0.000000, 0.000000, 0.000000
0.000000, 1.000000, 0.000000, 0.000000
0.000000, 0.000000, 1.000000, 0.000000
0.000000, 0.000000, 0.000000, 1.000000 ]TYPE
(read/write) – ENUM {PERSPECTIVE ORTHO } default: PERSPECTIVEUP
(read/write) – VEC4 default: (0.000000, 1.000000, 0.000000, 0.000000)VIEW
(read/write) – VEC4 default: (0.000000, 0.000000, -1.000000, 0.000000)VIEW_INVERSE_MATRIX
(read only) – MAT4 default: [ 1.000000, 0.000000, 0.000000, 0.000000
0.000000, 1.000000, 0.000000, 0.000000
0.000000, 0.000000, 1.000000, 0.000000
0.000000, 0.000000, 0.000000, 1.000000 ]VIEW_MATRIX
(read only) – MAT4 default: [ 1.000000, 0.000000, 0.000000, 0.000000
0.000000, 1.000000, 0.000000, 0.000000
0.000000, 0.000000, 1.000000, 0.000000
0.000000, 0.000000, 0.000000, 1.000000 ]ZX_ANGLE
(read/write) – FLOAT default: 3.141593
COLOR
AMBIENT
(read/write) – VEC4 default: (0.200000, 0.200000, 0.200000, 1.000000)DIFFUSE
(read/write) – VEC4 default: (0.800000, 0.800000, 0.800000, 1.000000)EMISSION
(read/write) – VEC4 default: (0.000000, 0.000000, 0.000000, 1.000000)SHININESS
(read/write) – FLOAT default: 0.000000SPECULAR
(read/write) – VEC4 default: (0.000000, 0.000000, 0.000000, 1.000000)
IMAGE_TEXTURE
ACCESS
(read/write) – ENUM {READ_ONLY WRITE_ONLY READ_WRITE } default:CLEAR
(read/write) – BOOL default: falseINTERNAL_FORMAT
(read/write) – ENUM {RGBA RGBA16 DEPTH_COMPONENT16 DEPTH_COMPONENT24 R8 R16 RG8 RG16 R16F R32F RG16F RG32F R8I R8UI R16I R16UI R32I R32UI RG8I RG8UI RG16I RG16UI RG32I RG32UI RGBA32F RGBA16F DEPTH_COMPONENT32F DEPTH32F_STENCIL8 RGBA32UI RGBA16UI RGBA8UI RGBA32I RGBA16I RGBA8I } default:LEVEL
(read/write) – UINT default: 0TEX_ID
(read/write) – UINT default: 0UNIT
(read only) – INT default: -1
LIGHT
AMBIENT
(read/write) – VEC4 default: (0.200000, 0.200000, 0.200000, 1.000000)COLOR
(read/write) – VEC4 default: (1.000000, 1.000000, 1.000000, 1.000000)CONSTANT_ATT
(read/write) – FLOAT default: 1.000000DIRECTION
(read/write) – VEC4 default: (0.000000, 0.000000, -1.000000, 0.000000)ENABLED
(read/write) – BOOL default: trueID
(read only) – INT default: -1LINEAR_ATT
(read/write) – FLOAT default: 0.000000NORMALIZED_DIRECTION
(read only) – VEC4 default: (0.000000, 0.000000, -1.000000, 0.000000)POSITION
(read/write) – VEC4 default: (0.000000, 0.000000, 0.000000, 1.000000)QUADRATIC_ATT
(read/write) – FLOAT default: 0.000000SPOT_CUTOFF
(read/write) – FLOAT default: 180.000000SPOT_DIRECTION
(read/write) – VEC4 default: (0.000000, 0.000000, -1.000000, 0.000000)SPOT_EXPONENT
(read/write) – FLOAT default: 0.000000
PASS
BUFFER_DRAW_INDIRECT
(read only) – UINT default: 0COLOR_CLEAR
(read/write) – BOOL default: trueCOLOR_CLEAR_VALUE
(read/write) – VEC4 default: (0.000000, 0.000000, 0.000000, 0.000000)COLOR_ENABLE
(read/write) – BOOL default: trueDEPTH_CLAMPING
(read/write) – BOOL default: falseDEPTH_CLEAR
(read/write) – BOOL default: trueDEPTH_CLEAR_VALUE
(read/write) – FLOAT default: 1.000000DEPTH_ENABLE
(read/write) – BOOL default: trueDEPTH_FUNC
(read/write) – ENUM {LESS NEVER ALWAYS LEQUAL EQUAL GEQUAL GREATER NOT_EQUAL } default: LESSDEPTH_MASK
(read/write) – BOOL default: trueDIM_X
(read/write) – UINT default: 1DIM_Y
(read/write) – UINT default: 1DIM_Z
(read/write) – UINT default: 1INSTANCE_COUNT
(read/write) – UINT default: 0RAY_COUNT
(read/write) – INT default: -1RUN_MODE
(read only) – ENUM {DONT_RUN RUN_ALWAYS SKIP_FIRST_FRAME RUN_ONCE RUN_EVEN RUN_ODD } default: RUN_ALWAYSSTENCIL_CLEAR
(read/write) – BOOL default: trueSTENCIL_CLEAR_VALUE
(read/write) – INT default: 0STENCIL_DEPTH_FAIL
(read/write) – ENUM {KEEP ZERO REPLACE INCR INCR_WRAP DECR DECR_WRAP INVERT } default: KEEPSTENCIL_DEPTH_PASS
(read/write) – ENUM {KEEP ZERO REPLACE INCR INCR_WRAP DECR DECR_WRAP INVERT } default: KEEPSTENCIL_ENABLE
(read/write) – BOOL default: falseSTENCIL_FAIL
(read/write) – ENUM {KEEP ZERO REPLACE INCR INCR_WRAP DECR DECR_WRAP INVERT } default: KEEPSTENCIL_FUNC
(read/write) – ENUM {LESS NEVER ALWAYS LEQUAL EQUAL GEQUAL GREATER NOT_EQUAL } default: ALWAYSSTENCIL_OP_MASK
(read/write) – UINT default: 255STENCIL_OP_REF
(read/write) – INT default: 0TEST_MODE
(read only) – ENUM {RUN_IF RUN_WHILE } default: RUN_IF
PASS_POST_PROCESS_BUFFER
CLEAR
(read/write) – BOOL default: false
PASS_POST_PROCESS_TEXTURE
CLEAR
(read/write) – BOOL default: falseCLEAR_LEVEL
(read/write) – INT default: -1MIPMAP
(read/write) – BOOL default: false
PASS_PRE_PROCESS_BUFFER
CLEAR
(read/write) – BOOL default: false
PASS_PRE_PROCESS_TEXTURE
CLEAR
(read/write) – BOOL default: falseCLEAR_LEVEL
(read/write) – INT default: -1MIPMAP
(read/write) – BOOL default: false
RENDERER
BUFFER_DRAW_INDIRECT
(read/write) – UINT default: 0DEBUG_DRAW_CALL
(read only) – BOOL default: falseFRAME_COUNT
(read only) – UINT default: 0INSTANCE_COUNT
(read/write) – UINT default: 0LIGHT_COUNT
(read only) – INT default: 0MODEL
(read only) – MAT4 default: [ 1.000000, 0.000000, 0.000000, 0.000000
0.000000, 1.000000, 0.000000, 0.000000
0.000000, 0.000000, 1.000000, 0.000000
0.000000, 0.000000, 0.000000, 1.000000 ]MOUSE_LEFT_CLICK
(read/write) – IVEC2 default: (0, 0)MOUSE_MIDDLE_CLICK
(read/write) – IVEC2 default: (0, 0)MOUSE_RIGHT_CLICK
(read/write) – IVEC2 default: (0, 0)NORMAL
(read only) – MAT3 default: [ 1.000000, 0.000000, 0.000000
0.000000, 1.000000, 0.000000
0.000000, 0.000000, 1.000000 ]PROJECTION
(read only) – MAT4 default: [ 1.000000, 0.000000, 0.000000, 0.000000
0.000000, 1.000000, 0.000000, 0.000000
0.000000, 0.000000, 1.000000, 0.000000
0.000000, 0.000000, 0.000000, 1.000000 ]PROJECTION_VIEW
(read only) – MAT4 default: [ 1.000000, 0.000000, 0.000000, 0.000000
0.000000, 1.000000, 0.000000, 0.000000
0.000000, 0.000000, 1.000000, 0.000000
0.000000, 0.000000, 0.000000, 1.000000 ]PROJECTION_VIEW_MODEL
(read only) – MAT4 default: [ 1.000000, 0.000000, 0.000000, 0.000000
0.000000, 1.000000, 0.000000, 0.000000
0.000000, 0.000000, 1.000000, 0.000000
0.000000, 0.000000, 0.000000, 1.000000 ]TEXTURE
(read only) – MAT4 default: [ 1.000000, 0.000000, 0.000000, 0.000000
0.000000, 1.000000, 0.000000, 0.000000
0.000000, 0.000000, 1.000000, 0.000000
0.000000, 0.000000, 0.000000, 1.000000 ]TEXTURE_COUNT
(read only) – INT default: 0TIMER
(read only) – FLOAT default: 0.000000TS05_PVM
(read only) – MAT4 default: [ 1.000000, 0.000000, 0.000000, 0.000000
0.000000, 1.000000, 0.000000, 0.000000
0.000000, 0.000000, 1.000000, 0.000000
0.000000, 0.000000, 0.000000, 1.000000 ]VIEW
(read only) – MAT4 default: [ 1.000000, 0.000000, 0.000000, 0.000000
0.000000, 1.000000, 0.000000, 0.000000
0.000000, 0.000000, 1.000000, 0.000000
0.000000, 0.000000, 0.000000, 1.000000 ]VIEW_MODEL
(read only) – MAT4 default: [ 1.000000, 0.000000, 0.000000, 0.000000
0.000000, 1.000000, 0.000000, 0.000000
0.000000, 0.000000, 1.000000, 0.000000
0.000000, 0.000000, 0.000000, 1.000000 ]
RENDER_TARGET
CLEAR_VALUES
(read/write) – VEC4 [(0.000000, 0.000000, 0.000000, 0.000000), (1.000000, 1.000000, 1.000000, 1.000000)] default: (0.000000, 0.000000, 0.000000, 0.000000)LAYERS
(read/write) – UINT default: 1LEVELS
(read/write) – UINT default: 0SAMPLES
(read/write) – UINT default: 0SIZE
(read/write) – UIVEC2 default: (0, 0)
SCENE
BB_CENTER
(read only) – VEC3 default: (0.000000, 0.000000, 0.000000)BB_MAX
(read only) – VEC3 default: (-1.000000, -1.000000, -1.000000)BB_MIN
(read only) – VEC3 default: (1.000000, 1.000000, 1.000000)ROTATE
(read/write) – VEC4 default: (0.000000, 1.000000, 0.000000, 0.000000)SCALE
(read/write) – VEC4 default: (1.000000, 1.000000, 1.000000, 1.000000)TRANSFORM_ORDER
(read/write) – ENUM {T_R_S T_S_R R_T_S R_S_T S_R_T S_T_R } default: T_R_STRANSLATE
(read/write) – VEC4 default: (0.000000, 0.000000, 0.000000, 0.000000)
SCENE_OBJECT
ROTATE
(read/write) – VEC4 default: (0.000000, 0.000000, 1.000000, 0.000000)SCALE
(read/write) – VEC4 default: (1.000000, 1.000000, 1.000000, 1.000000)TRANSFORM_ORDER
(read/write) – ENUM {T_R_S T_S_R R_T_S R_S_T S_R_T S_T_R } default: T_R_STRANSLATE
(read/write) – VEC4 default: (0.000000, 0.000000, 0.000000, 0.000000)
SPHERE
SLICES
(read/write) – UINT [3, ] default: 10STACKS
(read/write) – UINT [2, ] default: 10
STATE
BLEND
(read/write) – BOOL default: falseBLEND_COLOR
(read/write) – VEC4 default: (0.000000, 0.000000, 0.000000, 0.000000)BLEND_DST
(read/write) – ENUM {ZERO ONE SRC_COLOR ONE_MINUS_SRC_COLOR DST_COLOR ONE_MINUS_DST_COLOR SRC_ALPHA ONE_MINUS_SRC_ALPHA DST_ALPHA ONE_MINUS_DST_ALPHA SRC_ALPHA_SATURATE CONSTANT_COLOR ONE_MINUS_CONSTANT_COLOR CONSTANT_ALPHA ONE_MINUS_CONSTANT_ALPHA } default: ZEROBLEND_EQUATION
(read/write) – ENUM {ADD SUBTRACT REVERSE_SUBTRACT MIN MAX } default: ADDBLEND_SRC
(read/write) – ENUM {ZERO ONE SRC_COLOR ONE_MINUS_SRC_COLOR DST_COLOR ONE_MINUS_DST_COLOR SRC_ALPHA ONE_MINUS_SRC_ALPHA DST_ALPHA ONE_MINUS_DST_ALPHA SRC_ALPHA_SATURATE CONSTANT_COLOR ONE_MINUS_CONSTANT_COLOR CONSTANT_ALPHA ONE_MINUS_CONSTANT_ALPHA } default: ONECOLOR_MASK_B4
(read/write) – BVEC4 default: (1, 1, 1, 1)CULL_FACE
(read/write) – BOOL default: trueCULL_TYPE
(read/write) – ENUM {FRONT BACK FRONT_AND_BACK } default: BACKDEPTH_FUNC
(read/write) – ENUM {LESS NEVER ALWAYS LEQUAL EQUAL GEQUAL GREATER NOT_EQUAL } default: LESSDEPTH_MASK
(read/write) – BOOL default: trueDEPTH_TEST
(read/write) – BOOL default: trueORDER
(read/write) – INT default: 0ORDER_TYPE
(read/write) – ENUM {FRONT_TO_BACK BACK_TO_FRONT } default: FRONT_TO_BACK
TEXTURE
COMPONENT_COUNT
(read only) – INT default: 0DEPTH
(read/write) – INT default: 1DIMENSION
(read only) – ENUM {TEXTURE_2D TEXTURE_3D TEXTURE_2D_MULTISAMPLE_ARRAY TEXTURE_2D_ARRAY TEXTURE_2D_MULTISAMPLE TEXTURE_CUBE_MAP } default: TEXTURE_2DELEMENT_SIZE
(read only) – INT default: 0FORMAT
(read only) – ENUM {DEPTH_COMPONENT RED RGB RGBA RG DEPTH32F_STENCIL8 RED } default: RGBAHEIGHT
(read/write) – INT default: 1ID
(read only) – INT default: -1INTERNAL_FORMAT
(read/write) – ENUM {RGBA RGBA16 DEPTH_COMPONENT16 DEPTH_COMPONENT24 R8 R16 RG8 RG16 R16F R32F RG16F RG32F R8I R8UI R16I R16UI R32I R32UI RG8I RG8UI RG16I RG16UI RG32I RG32UI RGBA32F RGBA16F DEPTH_COMPONENT32F DEPTH32F_STENCIL8 RGBA32UI RGBA16UI RGBA8UI RGBA32I RGBA16I RGBA8I } default: RGBALAYERS
(read/write) – INT default: 1LEVELS
(read/write) – INT default: 0MIPMAP
(read/write) – BOOL default: falseSAMPLES
(read/write) – INT default: 0TYPE
(read only) – ENUM {BYTE UNSIGNED_BYTE SHORT UNSIGNED_SHORT INT UNSIGNED_INT FLOAT UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_24_8 FLOAT_32_UNSIGNED_INT_24_8_REV } default: UNSIGNED_BYTEWIDTH
(read/write) – INT default: 1
TEXTURE_BINDING
UNIT
(read/write) – INT default: 0
TEXTURE_MATERIAL
COMPONENT_COUNT
(read only) – INT default: 0DEPTH
(read/write) – INT default: 1DIMENSION
(read only) – ENUM {TEXTURE_2D TEXTURE_3D TEXTURE_2D_MULTISAMPLE_ARRAY TEXTURE_2D_ARRAY TEXTURE_2D_MULTISAMPLE TEXTURE_CUBE_MAP } default: TEXTURE_2DELEMENT_SIZE
(read only) – INT default: 0FORMAT
(read only) – ENUM {DEPTH_COMPONENT RED RGB RGBA RG DEPTH32F_STENCIL8 RED } default: RGBAHEIGHT
(read/write) – INT default: 1ID
(read only) – INT default: -1INTERNAL_FORMAT
(read/write) – ENUM {RGBA RGBA16 DEPTH_COMPONENT16 DEPTH_COMPONENT24 R8 R16 RG8 RG16 R16F R32F RG16F RG32F R8I R8UI R16I R16UI R32I R32UI RG8I RG8UI RG16I RG16UI RG32I RG32UI RGBA32F RGBA16F DEPTH_COMPONENT32F DEPTH32F_STENCIL8 RGBA32UI RGBA16UI RGBA8UI RGBA32I RGBA16I RGBA8I } default: RGBALAYERS
(read/write) – INT default: 1LEVELS
(read/write) – INT default: 0MIPMAP
(read/write) – BOOL default: falseSAMPLES
(read/write) – INT default: 0TYPE
(read only) – ENUM {BYTE UNSIGNED_BYTE SHORT UNSIGNED_SHORT INT UNSIGNED_INT FLOAT UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_24_8 FLOAT_32_UNSIGNED_INT_24_8_REV } default: UNSIGNED_BYTEWIDTH
(read/write) – INT default: 1
VIEWPORT
ABSOLUTE_ORIGIN
(read only) – VEC2 [(0.000000, 0.000000), ] default: (0.000000, 0.000000)ABSOLUTE_SIZE
(read only) – VEC2 [(0.000000, 0.000000), ] default: (1.000000, 1.000000)CLEAR_COLOR
(read/write) – VEC4 [(0.000000, 0.000000, 0.000000, 0.000000), (1.000000, 1.000000, 1.000000, 1.000000)] default: (0.000000, 0.000000, 0.000000, 0.000000)FULL
(read/write) – BOOL default: trueORIGIN
(read/write) – VEC2 [(0.000000, 0.000000), ] default: (0.000000, 0.000000)RATIO
(read/write) – FLOAT [0.000000, ] default: 0.000000SIZE
(read/write) – VEC2 [(0.000000, 0.000000), ] default: (1.000000, 1.000000)