Example code for this type of shader can be found in:
/usr/aw/alias/ODS/OpenRender/samples/plabel
or possibly:
/usr/aw/alias/ODS/OpenRender/samples/scanline
static int CALC (
AR_ShaderInfo *pShader,
AR_GeometryInfo *ar_geom,
AR_ShadeData *pShadeData,
AR_OCR_ObjectInfo *object_info,
void *ni,
void *rt_ray_rec
)
For the scanline shader, the scanline data is found in the second parameter, ar_geom. Typically you will access the scanline data by casting the ar_geom variable to type AR_PoseShadeData:
AR_PostShadeData* postShadeData =
(AR_PostShadeData*) ar_geom;
where AR_PostShadeData is defined as:
typedef struct AR_PostShadeData {
AR_PostScanlineData* previous;
AR_PostScanlineData* current;
AR_PostScanlineData* next;
AR_Rgba* previous_color;
AR_Rgba* current_color;
AR_Rgba* next_color;
int resolution;
char* image_output;
} AR_PostShadeData;
for (int i=0;i<postShadeData->resolution;i++)
{
printf("RGB of pixel (%4d,%4d) = (%4d,%4d,%4d)\n",
i,nScanLine,current_color->[i].r,
current_color->[i].g,
current_color->[i].b);
}
nScanLine ++;
static int nXSize;
static int nYSize;
// grab data on first call to CALC
if (postShadeData->previous == NULL)
{
nXSize = ar_render_options.xresolution;
nYSize = ar_render_options.yresolution;
}
This is best explained with an example. Please refer to the following directory and files:
./ODS/OpenRender/ocr/samples/scanline
file: orNormal1.c - Source file for an OpenRender shader plugin. This plugin stores the normal vector for each pixel in user data, which is later looked at in the scanline shader (orNormal2.c)
file: orNormal2.c - Source file for an OpenRender scanline shader plugin. This plug-in gathers the normal vector data that was generated in orNormal1.c, and stores the whole image worth of data into a new image.
file: orNormal.perl - This perl script reads the file input.sdl and generates the file output.sdl. The input.sdl file is a normal sdl that you would save in Alias. The output.sdl is a modified sdl that contains the load calls for the OpenRender plug-ins, the image_shader stanza, and also adds a layered shader to all geometry. This layered shader is orNormal1.c; this way, all geometry gets passed through this shader.
file: runit - A script to run the perl script, render, and look at the results.
To run this example, please type ./runit