#define | rtDeclareVariable(type, name, semantic, annotation) |
rtDeclareVariable宏定义语法(类型,变量名称,语义,注解)。例如,rtDeclareVariable(uint2, launch_index, rtLaunchIndex, );
这个宏用来定义程序中需要用到的变量(共享变量?)。这个变量可以用来保存一个内部状态,保存一条射线的payload,在相交程序和材料程序中交换属性值等等。
语义可以是如下:
rtLaunchIndex - launch序号。类型需要为unsigned int,unit2, unit3, int, int2, int3之一,并且需为只读。
rtLaunchDim - launch的每个dimension的大小,取值范围1-size。数据类型同上。
rtCurrentRay - 当前活动ray,仅在调用rtTrace时有效。该向量不保证是归一化的。数据类型需要是optix::Ray,并且为只读。
rtCurrentTime - 当前ray time。类型需为float,只读。
rtIntersectionDistance - 当前最近交点距离,当rtTrace被调用时返回。类型为float,只读。
rtRayPayload - 用户定义结构,rtTrace的输入,读写。
属性名称 - 该属性从相交程序intersection program送入closest-hit或any-hit程序。其类型需在两个程序中匹配(?)。该变量在closest-hit或any-hit程序中是只读的,在相交程序中被写入。
使用这个变量的方法
rtContextDeclareVariable, rtProgramDeclareVariable, rtSelectorDeclareVariable, rtGeometryInstanceDeclareVariable, rtGeometryDeclareVariable, rtMaterialDeclareVariable
RTresult RTAPI rtProgramDeclareVariable | ( | RTprogram | program, |
const char * | name, | ||
RTvariable * | v | ||
) |
将变量v与程序进行关联。一个变量只能与某个程序关联一次。