A simple shader that takes a base color and adds another color.
Mi File
Methodology
1. create a color parameter called base
2. create a color parameter called offset
3. create a shader called "color_offset"
4. create a function where result = base + offset
Mi File
declare shader color "color_offset" ( color "base" default 1 1 1, color "offset" default 0 0 0 ) apply material end declare
C File
#include "shader.h" DLLEXPORT struct color_offset { miColor base; miColor offset; }; DLLEXPORT miBoolean color_offset (miColor *result, miState *state, struct color_offset *params) { miColor *base = mi_eval_color(¶ms->base); miColor *offset = mi_eval_color(¶ms->offset); result->r = base->r + offset->r; result->g = base->g + offset->g; result->b = base->b + offset->b; return miTRUE; }
0 comments:
Post a Comment