miBoolean mi_query( miQ_type query, miState * state, miTag tag, void * result, ...)
Return various pieces of information about the current state of mental ray. query is the request code specifying what piece of information to query; state is the shader state, tag is the tag of the DB element to query, if any, and result is a pointer to the variable to store the results in. Some queries do not require a tag; in this case miNULLTAG must be passed as tag. Some queries require extra arguments in addition to the four standard arguments. mi_query returns miFALSE if the queried value is not available or an unknown type code is used. The following query codes are available:
query code | st. | tag | result, ... | purpose |
---|---|---|---|---|
miQ_DATA_DECL | ◊ | ♦ | miTag |
user data declaration if any, or 0 |
miQ_DATA_LABEL | ◊ | ♦ | miUint |
translator-defined user data label |
miQ_DATA_NEEDSWAP | ◊ | ♦ | miBoolean |
requires byte-swapping by shader |
miQ_DATA_NEXT | ◊ | ♦ | miTag |
next user data block in chain, or 0 |
miQ_DATA_PARAM | ◊ | ♦ | char * |
user data contents |
miQ_DATA_PARAM_SIZE | ◊ | ♦ | int |
size of user data block in bytes |
miQ_DATE | ◊ | ◊ | char * |
mental ray compilation date |
miQ_DECL_LOCK 1 | ◊ ♦ |
♦ ◊ |
miLock * |
shared by all shader instances |
miQ_DECL_NAME 1 | ◊ ♦ |
♦ ◊ |
char * |
shader name |
miQ_DECL_PARAM 1 | ◊ ♦ |
♦ ◊ |
char * |
ascii-encoded parameter declaration |
miQ_DECL_RESULT_SIZE 1 | ◊ ♦ |
♦ ◊ |
int |
result size, 4 unless struct |
miQ_DECL_TYPE 1 | ◊ ♦ |
♦ ◊ |
int |
miTYPE_* result type |
miQ_DECL_VERSION 1 | ◊ ♦ |
♦ ◊ |
int |
shader declaration version |
miQ_FINALGATHER_STATE | ♦ | ◊ | int |
0=not a finalgather ray (grand)child, 1=finalgather ray (grand)child in tile rendering, 2=finalgather ray (grand)child in FG precompute |
miQ_SAMPLE_MOVING | ♦ | ◊ | int |
Not zero if mental ray has detected geometry motion for the current raster sample. |
miQ_FUNC_CALLTYPE | ♦ | ◊ | int |
one of miSHADER_*, as specified by the calling mi_call_shader |
miQ_FUNC_DECL 1 | ◊ ♦ |
♦ ◊ |
miTag |
tag of shader declaration |
miQ_FUNC_INDIRECT 1 | ◊ ♦ |
♦ ◊ |
miTag |
take params from this shader |
miQ_FUNC_LOCK 1 | ◊ ♦ |
♦ ◊ |
miLock * |
local shader instance lock |
miQ_FUNC_NEXT 1 | ◊ ♦ |
♦ ◊ |
miTag |
next shader in shader list |
miQ_FUNC_PARAM 1 | ◊ ♦ |
♦ ◊ |
void * |
shader parameters |
miQ_FUNC_PARAM_SIZE 1 | ◊ ♦ |
♦ ◊ |
int |
size of shader parameters in bytes |
miQ_FUNC_PARAM_VALUE 1 | ◊ ♦ |
♦ ◊ |
type,
char *, miParam_type |
value of shader input parameter with given name and type |
miQ_FUNC_RESULT_SIZE 1 | ◊ ♦ |
♦ ◊ |
int |
shader result size in bytes |
miQ_FUNC_TAG | ♦ | ◊ | miTag |
tag of the currently running shader |
miQ_FUNC_TLS_GET | ♦ | ◊ | void * |
retrieve thread-local shader data pointer |
miQ_FUNC_TLS_GETALL 2 | ♦ | ◊ | void *, int * |
array of all valid thread-local shader data pointers, return array size in extra parameter |
miQ_FUNC_TLS_SET | ♦ | ◊ | void * |
set thread-local shader data pointer (see thread-local storage) |
miQ_FUNC_TYPE 1 | ◊ ♦ |
♦ ◊ |
int |
0=C/C++, 1=phen., 2=output file |
miQ_FUNC_USERPTR 1 | ◊ ♦ |
♦ ◊ |
void * |
user pointer in shader instance |
miQ_FUNC_IS_ROOT | ♦ | ◊ | miBoolean |
shader is root of material/light |
miQ_GEO_DATA | ◊ | ◊ | miTag |
user data block of current object |
miQ_GEO_HAS_DERIVS | ♦ | ◊ | miBoolean |
state has valid derivatives |
miQ_GEO_HAS_DERIVS2 | ♦ | ◊ | miBoolean |
state has valid second derivatives |
miQ_GEO_LABEL | ◊ | ◊ | miUint |
translator-defined triangle label |
miQ_GLOBAL_LIGHTS | ◊ | ◊ | miTag * |
array with global light tags |
miQ_GROUP_DATA | ◊ | ♦ | miTag |
user data block |
miQ_GROUP_KID | ◊ | ♦ | miTag |
nth child (n is fifth argument) |
miQ_GROUP_LABEL | ◊ | ♦ | miUint |
translator-defined group label |
miQ_GROUP_MERGE_GROUP | ◊ | ♦ | miBoolean |
miTRUE if connected |
miQ_GROUP_NKIDS | ◊ | ♦ | int |
number of child instances |
miQ_HAIR_NUM_TEXTURES | ◊ | ♦ | int |
number of texture scalars per hair |
miQ_HAIR_NUM_USERS | ◊ | ♦ | int |
number of user scalars per hair |
miQ_HAIR_USERS | ◊ | ♦ | miScalar * |
array of user scalars per hair |
miQ_HAIR_RADIUS | ♦ | ◊ | miScalar |
hair radius at the the current hit point |
miQ_IMAGE_BITS | ◊ | ♦ | int |
number of bits per component (8,16,32) |
miQ_IMAGE_COLORCLIP | ◊ | ◊ | miBoolean |
color frame buffer color clipping mode |
miQ_IMAGE_COMP | ◊ | ♦ | int |
number of components (1,2,3,4) |
miQ_IMAGE_DESATURATE | ◊ | ◊ | miBoolean |
color frame buffer desaturation mode |
miQ_IMAGE_DITHER | ◊ | ◊ | miBoolean |
color frame buffer dithering mode |
miQ_IMAGE_FILTER | ◊ | ♦ | miBoolean |
image allows filtering |
miQ_IMAGE_GAMMA | ◊ | ◊ | double |
color frame buffer gamma factor |
miQ_IMAGE_HEIGHT | ◊ | ♦ | int |
height of image in pixels |
miQ_IMAGE_NOPREMULT | ◊ | ◊ | miBoolean |
color frame buffer premultiplication mode |
miQ_IMAGE_WIDTH | ◊ | ♦ | int |
width of image in pixels |
miQ_INST_AREA | ◊ | ♦ | miScalar |
light instances only: area of area light |
miQ_INST_CAUSTIC | ◊ | ♦ | miUint |
bitmap: bit 1=enable casting, bit 2=enable receiving, bit 3=disable casting, bit 4=disable receiving |
miQ_INST_DATA | ◊ | ♦ | miTag |
user data block |
miQ_INST_DECL | ◊ | ♦ | miTag |
inherited parameter declaration |
miQ_INST_FUNCTION | ◊ | ♦ | miTag |
optional procedural transformation |
miQ_INST_GLOBAL_TO_LOCAL | ◊ | ♦ | miMatrix * |
instance transformation |
miQ_INST_GLOBILLUM | ◊ | ♦ | miUint |
bitmap: bit 1=enable casting, bit 2=enable receiving, bit 3=disable casting, bit 4=disable receiving |
miQ_INST_HIDE | ◊ | ♦ | miBoolean |
instance is inactive |
miQ_INST_IDENTITY | ◊ | ♦ | miBoolean |
miTRUE if identity transformation |
miQ_INST_ITEM | ◊ | ♦ | miTag |
instanced scene element |
miQ_INST_LABEL | ◊ | ♦ | miUint |
translator-defined instance label |
miQ_INST_LOCAL_TO_GLOBAL | ◊ | ♦ | miMatrix * |
inverse instance transformation |
miQ_INST_MATERIAL | ◊ | ♦ | miTag |
inherited material |
miQ_INST_PARAM | ◊ | ♦ | void * |
inherited parameters |
miQ_INST_PARAM_SIZE | ◊ | ♦ | int |
inherited parameter size |
miQ_INST_PARENT | ◊ | ♦ | miTag |
leaf instance parent,
miNULLTAG otherwise |
miQ_INST_PLACEHOLDER_ITEM | ◊ | ♦ | miTag |
content of placeholder instances |
miQ_INST_SHADOW | ◊ | ♦ | miUint |
invisible to shadow rays |
miQ_INST_TRACE | ◊ | ♦ | miUint |
visible to secondary rays |
miQ_INST_VISIBLE | ◊ | ♦ | miUint |
visible to primary rays |
miQ_LIGHT_AREA | ◊ | ♦ | int |
area light type: 0=none, 1=rectangle, 2=disc, 3=sphere |
miQ_LIGHT_AREA_C_AXIS | ◊ | ♦ | miVector |
axis of cylinder area light |
miQ_LIGHT_AREA_C_RADIUS | ◊ | ♦ | miScalar |
radius of cylinder area light |
miQ_LIGHT_AREA_R_EDGE_U | ◊ | ♦ | miVector |
U size of rectangular area light |
miQ_LIGHT_AREA_R_EDGE_V | ◊ | ♦ | miVector |
V size of rectangular area light |
miQ_LIGHT_AREA_D_NORMAL | ◊ | ♦ | miVector |
normal vector of disc area light |
miQ_LIGHT_AREA_D_RADIUS | ◊ | ♦ | miScalar |
radius of disc area light |
miQ_LIGHT_AREA_S_RADIUS | ◊ | ♦ | miScalar |
radius of spherical area light |
miQ_LIGHT_AREA_SAMPLES_U | ◊ | ♦ | int |
number of samples in U direction |
miQ_LIGHT_AREA_SAMPLES_V | ◊ | ♦ | int |
number of samples in V direction |
miQ_LIGHT_CAUSTIC_PHOTONS | ◊ | ♦ | int |
number of caustic photons to store |
miQ_LIGHT_CAUSTIC_PHOTONS_EMIT | ◊ | ♦ | int |
number of caustic photons to emit |
miQ_LIGHT_DATA | ◊ | ♦ | miTag |
user data block |
miQ_LIGHT_DIRECTION | ♦ | ♦ | miVector |
light direction |
miQ_LIGHT_EMITTER | ◊ | ♦ | miVector |
tag of light photon emitter shader |
miQ_LIGHT_ENERGY | ◊ | ♦ | miTag |
energy for caustics and globillum |
miQ_LIGHT_EXPONENT | ◊ | ♦ | miScalar |
distance falloff, n in 1 / r^n |
miQ_LIGHT_GLOBAL_PHOTONS | ◊ | ♦ | miColor |
number of globillum photons to store |
miQ_LIGHT_GLOBAL_PHOTONS_EMIT | ◊ | ♦ | miColor |
number of globillum photons to emit |
miQ_LIGHT_LABEL | ◊ | ♦ | int |
light label |
miQ_LIGHT_NORMAL | ♦ | ◊ | miVector |
normal vector at light surface in world space |
miQ_LIGHT_ORIGIN | ♦ | ♦ | miVector |
light position |
miQ_LIGHT_SHADER | ◊ | ♦ | miTag |
tag of light shader |
miQ_LIGHT_SPREAD | ◊ | ♦ | miScalar |
outer cone angle of spot light |
miQ_LIGHT_TANGENT_SPACE | ♦ | ◊ | miVector[3] |
normal, tangent, bi-tangent (in that order) at light surface in world space |
miQ_LIGHT_TYPE | ◊ | ♦ | int |
light source type: 0=point, 1=directional, 2=spot |
miQ_LIGHT_USE_SHADOWMAP | ◊ | ♦ | miBoolean |
light has a shadow map |
miQ_LIGHTPROFILE_COSTHETA_MAX | ◊ | ♦ | miScalar |
largest possible value of the cosine of the profile vertical angle |
miQ_LIGHTPROFILE_COSTHETA_MIN | ◊ | ♦ | miScalar |
smallest value of the cosine of the profile vertical angle. |
miQ_LIGHTPROFILE_INTENSITY_MAX | ◊ | ♦ | miScalar |
largest intensity value of the profile |
miQ_LIGHTPROFILE_PHI_MAX | ◊ | ♦ | miScalar |
horizontal angle where the light profile ends |
miQ_LIGHTPROFILE_PHI_MIN | ◊ | ♦ | miScalar |
horizontal angle where the light profile starts |
miQ_LIGHTPROFILE_PHI_RES | ◊ | ♦ | int |
number of interpolation points in the horizontal direction |
miQ_LIGHTPROFILE_THETA_RES | ◊ | ♦ | int |
number of interpolation points in the vertical direction |
miQ_MTL_CONTOUR | ◊ | ♦ | miTag |
contour shader |
miQ_MTL_DISPLACE | ◊ | ♦ | miTag |
displacement shader |
miQ_MTL_ENVIRONMENT | ◊ | ♦ | miTag |
environment shader |
miQ_MTL_OPAQUE | ◊ | ♦ | miBoolean |
material is opaque to shadow rays |
miQ_MTL_PHOTON | ◊ | ♦ | miTag |
photon shader |
miQ_MTL_PHOTONVOL | ◊ | ♦ | miTag |
photon volume shader |
miQ_MTL_SHADER | ◊ | ♦ | miTag |
material shader |
miQ_MTL_SHADOW | ◊ | ♦ | miTag |
shadow shader |
miQ_MTL_VOLUME | ◊ | ♦ | miTag |
volume shader |
miQ_NUM_BUMPS | ♦ | ◊ | int * |
number of bumps in state x, y bump lists |
miQ_NUM_GLOBAL_LIGHTS | ◊ | ◊ | int |
number of global lights |
miQ_NUM_TEXTURES | ♦ | ◊ | int * |
number of textures in state->tex_list |
miQ_OBJ_CAUSTIC | ◊ | ♦ | miUint |
0=none, 1=casts, 2=receives, 3=both |
miQ_OBJ_DATA | ◊ | ♦ | miTag |
user data block |
miQ_OBJ_GLOBILLUM | ◊ | ♦ | miUint |
0=none, 1=casts, 2=receives, 3=both |
miQ_OBJ_LABEL | ◊ | ♦ | miUint |
translator-defined object label |
miQ_OBJ_SHADOW | ◊ | ♦ | miBoolean |
invisible to shadow rays |
miQ_OBJ_TRACE | ◊ | ♦ | miBoolean |
visible to secondary rays |
miQ_OBJ_TYPE | ◊ | ♦ | int |
object type: 0=polygons, 1=surfaces, 2=boxes, 3=spacecurves, 4=subdiv, 6=placeholder, 7=hair, 9=particles |
miQ_OBJ_VIEW_DEPENDENT | ◊ | ♦ | miBoolean |
contains view-dependent surfaces |
miQ_OBJ_VISIBLE | ◊ | ♦ | miBoolean |
visible to primary rays |
miQ_PIXEL_SAMPLE | ♦ | ◊ | miScalar[2] |
set up QMC sequences for sampling, and return a jitter value for lightmap shaders. See query pixel sample example. |
miQ_PRI_ASSEMBLY_INST_TAG | ♦ | ◊ | miTag |
for geometry from assemblies, leaf instance tag of the hit primitive |
miQ_PRI_BBOX_MAX | ♦ | ◊ | miVector |
object-space bounding box of intersected primitive |
miQ_PRI_BBOX_MIN | ♦ | ◊ | miVector |
object-space bounding box of intersected primitive |
miQ_PRI_DATA | ♦ | ◊ | miPri_data | the per-primitive data of the current primitive in the state |
miQ_PRI_INDEX | ♦ | ◊ | miUint |
current primitive index |
miQ_PRI_NUM_MOTIONS | ♦ | ◊ | miUint |
number of motion vectors per vertex |
miQ_PRI_NUM_VERTICES | ♦ | ◊ | miUint |
number of vertices of primitive |
miQ_PRI_VERTICES_POINTS | ♦ | ◊ | miVector * |
vertex positions of primitive |
miQ_PRI_VERTICES_NORMALS | ♦ | ◊ | miVector * |
vertex normals of primitive |
miQ_PRI_VERTICES_MOTION 2 | ♦ | ◊ | miVector *, int |
vertex motion vectors of primitive, given motion step |
miQ_PRI_VERTICES_TEX 2 | ♦ | ◊ | miVector *, int |
vertex texture vectors of primitive, given texture space |
miQ_PRI_VERTICES_USER 2 | ♦ | ◊ | miVector *, int |
vertex user vectors of primitive, given user space |
miQ_PRI_VERTICES_BUMPS_U | ♦ | ◊ | miVector * |
vertex bump basis U vectors of primitive |
miQ_PRI_VERTICES_BUMPS_V | ♦ | ◊ | miVector * |
vertex bump basis V vectors of primitive |
miQ_PRI_VERTICES_DERIVS_U | ♦ | ◊ | miVector * |
vertex first order derivative vectors of primitive |
miQ_PRI_VERTICES_DERIVS_V | ♦ | ◊ | miVector * |
vertex first order derivative U vectors of primitive |
miQ_PRI_VERTICES_DERIVS_UU | ♦ | ◊ | miVector * |
vertex second order derivative UU vectors of primitive |
miQ_PRI_VERTICES_DERIVS_VV | ♦ | ◊ | miVector * |
vertex second order derivative VV vectors of primitive |
miQ_PRI_VERTICES_DERIVS_UV
miQ_PRI_VERTICES_DERIVS_VU |
♦ | ◊ | miVector * |
vertex second order derivative UV vectors of primitive |
miQ_PRI_PARTICLE_INDEX | ♦ | ◊ | miUint |
current particle index |
miQ_PRI_PARTICLE_TYPE | ♦ | ◊ | int |
current particle type: 0=spheres, 1=tubes |
miQ_PRI_PARTICLE_UV | ♦ | ◊ | miScalar[2] |
current particle intersection coordinates |
miQ_RAY_INTERFACE | ♦ | ◊ | MI::RAY:Interface * |
pointer to C++ interface class |
miQ_SCENE_BBOX_ALL | ♦ | ◊ | miVector[2] |
world-space bounding box of all geometry |
miQ_SCENE_BBOX_CAUSTIC_G | ♦ | ◊ | miVector[2] |
bounding box of all caustic-casting geometry |
miQ_SCENE_BBOX_CAUSTIC_R | ♦ | ◊ | miVector[2] |
bounding box of all caustic-receiving geometry |
miQ_SCENE_BBOX_GLOBILLUM_G | ♦ | ◊ | miVector[2] |
bounding box of all globillum-casting geometry |
miQ_SCENE_BBOX_GLOBILLUM_R | ♦ | ◊ | miVector[2] |
bounding box of all globillum-receiving geometry |
miQ_SCENE_BBOX_SHADOW | ♦ | ◊ | miVector[2] |
bounding box of all shadow-casting geometry |
miQ_SCENE_ROOT_GROUP | ♦ | ◊ | miTag |
the root group of the scene from the render statement; useful for custom scene traversals |
miQ_STAGE | ♦ | ◊ | miStage |
current rendering stage |
miQ_TEXTURE_DIM | ◊ | ♦ | miUint |
dimension of nth texture space of intersected primitive (n is fifth argument) |
miQ_TILE_PIXELS | ♦ | ◊ | int[4] |
lower left and upper right tile pixel coord |
miQ_TILE_SAMPLES | ♦ | ◊ | int[4] |
same but including filter source margin |
miQ_TRANS_CAMERA_TO_INTERNAL | ♦ | ◊ | miMatrix * |
camera to internal space transformation |
miQ_TRANS_CAMERA_TO_WORLD | ♦ | ◊ | miMatrix * |
camera to world space transformation |
miQ_TRANS_INTERNAL_TO_CAMERA | ♦ | ◊ | miMatrix * |
internal to camera space transformation |
miQ_TRANS_INTERNAL_TO_OBJECT | ♦ | ◊ | miMatrix * |
internal to object space transformation |
miQ_TRANS_INTERNAL_TO_WORLD | ♦ | ◊ | miMatrix * |
internal to world space transformation |
miQ_TRANS_OBJECT_TO_INTERNAL | ♦ | ◊ | miMatrix * |
object to internal space transformation |
miQ_TRANS_OBJECT_TO_WORLD | ♦ | ◊ | miMatrix * |
object to world space transformation |
miQ_TRANS_WORLD_TO_CAMERA | ♦ | ◊ | miMatrix * |
world to camera space transformation |
miQ_TRANS_WORLD_TO_INTERNAL | ♦ | ◊ | miMatrix * |
world to internal space transformation |
miQ_TRANS_WORLD_TO_OBJECT | ♦ | ◊ | miMatrix * |
internal to world space transformation |
miQ_VERSION | ◊ | ◊ | char * |
mental ray version string |
state→shader
) to fulfill
the query. This is slightly faster than passing a tag.
2
This query uses additional parameters to pass or return extra information.
int
, but a pointer to an
integer must be passed as the fourth argument (int *
). For
mi_query, "function" is
synonymous with "shader".
Note The return type of miMatrix * means that the address of a pointer must be passed, not the address of a matrix. This reduces the number of bytes that mi_query has to copy from 64 (sixteen floats) to only four (or eight, on some CPU architectures).
miScalar intensity = 0.0; if (mi_query(miQ_FUNC_PARAM_VALUE, 0, tag, &intensity, "intensity", miTYPE_SCALAR) == miTRUE) { ... /* use valid intensity value */ }
miFALSE
under the following
conditions:
state→pri
has not been
modified by the shader or calling shader. Ray-marching volume shaders sometimes
clear this state variable. The miQ_GEO_LABEL query also returns
miFALSE if the object is not marked tagged and no polygon/surface
labels exist.
miNULLTAG
is returned. This query mode may be used by shaders
to implement custom attribute inheritance from the main scene file.
typedef struct miPri_data { miUint info_size; /* size of info */ const miUint *info; /* info: data layout */ miUint data_size; /* size of triangle data */ const miUint *data; /* primitive (triangle) data */ } miPri_data;
miUint num = 0; /* we like to deal with triangles only, like in mi_tri_vectors() */ if (mi_query(miQ_PRI_NUM_VERTICES, state, 0, &num) && num == 3) { miVector n[3], t[3]; miUint tex_space = 2; if (mi_query(miQ_PRI_VERTICES_NORMALS, state, 0, &n) && mi_query(miQ_PRI_VERTICES_TEX, state, 0, &t, tex_space) { /* use the values */ } }
miFALSE
if no
particle was hit. The intersection coordinates returned for the particles
shapes are as follows:
Copyright © 1986, 2015
NVIDIA ARC GmbH. All rights reserved.