Functions
Irradiance / Radiance API

Functions

AI_API AtColor AiIrradiance (const AtPoint *p, const AtVector *n, AtByte tid, AtUInt32 pid)
 Irradiance lookup at a (point,normal) pair. More...
 
AI_API AtColor AiRadiance (const AtPoint *p, const AtVector *dir, const AtVector *n, AtNode *obj, AtUInt32 face, float u, float v, AtNode *shader, AtByte tid, AtUInt32 pid)
 Radiance lookup at a point. More...
 
AI_API AtRGB AiSSSEvaluateIrradiance (const AtShaderGlobals *sg, float u, float v, AtUInt32 face, const AtPoint *p, AtUInt32 index)
 Return irradiance at the specified sample. More...
 

Detailed Description

Function Documentation

AI_API AtColor AiIrradiance ( const AtPoint p,
const AtVector n,
AtByte  tid,
AtUInt32  pid 
)

Irradiance lookup at a (point,normal) pair.

This function computes the total hemispherical irradiance at a given point and normal vector, including both direct and indirect illumination.

This can be used to precompute (or "bake") lightmaps as it's typically done for videogames and other realtime applications.

Here is a snippet of code that shows how to make "free" calls to AiIrradiance() and store them in an array:

AtColor irr[NPOINTS];
AtPoint p[NPOINTS];
AtVector n[NPOINTS];
for (i=0; i<NPOINTS; i++) {
p[i] = ... // set position
n[i] = ... // set normal vector
irr[i] = AiIrradiance(&p[i], &n[i], 0, i);
// NOTE#1: we pass 0 as thread id because this example doesn't have multi-threading
// NOTE#2: if we passed 0 instead of i, we'd get aliasing in the illumination
}
// ... save irr to file
Parameters
pthe input shading point
nthe input shading normal
tidthread id for the irradiance calculation (used for multi-threaded code)
pida unique identifier, or point id, for this irradiance calculation, used to generate variations in the illumination sampling patterns
Returns
the irradiance at the hemisphere defined by p and n
AI_API AtColor AiRadiance ( const AtPoint p,
const AtVector dir,
const AtVector n,
AtNode obj,
AtUInt32  face,
float  u,
float  v,
AtNode shader,
AtByte  tid,
AtUInt32  pid 
)

Radiance lookup at a point.

This function computes the radiance along a given direction, coming from a given point. The local surface properties at the point must be passed in: normal vector, object, face, parametric coordinates, and shader.

This function is used in "free" mode just like AiIrradiance(). Possible uses include precomputing a spherical harmonics representation of the reflected radiance function at a point in space.

Parameters
pthe point where radiance comes from
dirthe radiance direction
nthe unit normal vector at p
objan AtNode* for the geometry object at p, usually a polymesh
facethe face in the polymesh
uthe U parametric coordinate, or barycentric coordinate for a polymesh
vthe V parametric coordinate, or barycentric coordinate for a polymesh
shaderan AtNode* for the shader at p
tidthread id for the irradiance calculation (used for multi-threaded code)
pidpoint id used to set random values
Returns
the radiance along dir from p
AI_API AtRGB AiSSSEvaluateIrradiance ( const AtShaderGlobals sg,
float  u,
float  v,
AtUInt32  face,
const AtPoint p,
AtUInt32  index 
)

Return irradiance at the specified sample.

This function was designed to work in conjunction with the pointcloud iterator API as in the following example:

unsigned int i = 0;
AtPointCloudIterator *iter = AiPointCloudIteratorCreate(sg, AI_POINTCLOUD_BLUE_NOISE, 0.1f);
{
irradiance[i] = AiSSSEvaluateIrradiance(sg, sample.uv.x, sample.uv.y, sample.face, &sample.world_position, i);
i++;
}

You probably won't ever need to use this function unless you are implementing a custom SSS engine.

Parameters
sgshader globals (needed for thread id, etc)
ubarycentric u sample coordinate
vbarycentric v sample coordinate
faceindex of the face where the sample is located
pposition of the sample in world space
indexunique index for this sample, used to seed RNG's
Returns
irradiance at the given sample

© 2009-2013 Solid Angle SL · all rights reserved · www.solidangle.com