Shader displace_texture

Click on the filename to display or download the file.

displace_texture.mi
declare shader 
    scalar "displace_texture" ( 
	color texture "texture", 
	scalar "factor" default .1 ) 
    version 1 
    apply displace 
end declare 

displace_texture.c
#include "shader.h" 
#include "miaux.h" 
 
struct displace_texture { 
    miTag texture; 
    miScalar factor; 
}; 
 
DLLEXPORT 
int displace_texture_version(void) { return(1); } 
 
DLLEXPORT 
miBoolean displace_texture ( 
    miScalar *result, miState *state, struct displace_texture *params ) 
{ 
    miColor color; 
    mi_lookup_color_texture(&color, state, 
                            *mi_eval_tag(&params->texture), 
                            &state->tex_list[0]); 
    *result += *mi_eval_scalar(&params->factor) * color.r; 
    return miTRUE; 
} 

22 April 2008 23:40:30