#include "M:/vsfx755/rsl_source/noises.h"
surface npr_voronoidiffuse(
float Kd = 1; /* basic brightness */
float Ka = 1; /* basic brightness */
float voro_freq = 3; /* desc {Feature size } */
float voro_jitter = 0.6;
float cell_size = 7;
string PSpace = "shader";
)
{
normal Nn = normalize (-N);
float dot = Nn . normalize(I);
point objP = transform (PSpace, P);
float voro_f1 = 1, voro_f2 = 0;
point voro_pos1 = 1, voro_pos2 = 0;
voronoi_f1f2_3d (objP*voro_freq,
voro_jitter,voro_f1, voro_pos1, voro_f2,voro_pos2);
float voro_dist = 1 - smoothstep (voro_f1,voro_f2
, voro_f2 - voro_f1 / cell_size);
point newP = transform("world",voro_pos1);
normal newn = (xcomp(newP)-xcomp(E),
ycomp(newP)-ycomp(E),zcomp(newP)-zcomp(E));
newn = normalize(newn);
color diffusecolor = Kd * diffuse(newn);
color ambientcolor = Ka * ambient();
Oi = Os;
Ci = (diffusecolor + ambientcolor);
} |