#include "library.h"
#include "normals.h"
surface
hatchingCurves_occ(float Kd = 1,
minLength = 0.01, /* [0 0.5] */
maxLength = 0.1, /* [0 0.5] */
rand = 0.0,
jit = 0.005, /* [0 0.1] */
complexity = 5, /* [0 32] */
density = 0.5, /* [0 5] */
width = 0.005, /* [0 1] */
samples = 128, /* [0 1024] */
angle = 90; /* [0 90] */
string texname = "";
color envmaptint = 1,
shadow_color = 0;
string bakename = "")
{
color surfcolor = 1;
normal n = normalize(N);
color occ = gakiOcclusion(samples, angle, texname, envmaptint, shadow_color);
surfcolor = surfcolor * occ * Kd;
// Get the brightness of the illumination
color hsvColor = ctransform("rgb", "hsv", surfcolor);
float brightness = hsvColor[2];
// Offset the point according to the brightness
point pp = transform("world", P);
//normal nf = faceforward(n, I);
normal nf = shadingnormal(n);
nf = transform("world", nf);
vector i = normalize(I);
i = transform("world", i);
// Use our custom shadeop to bake the particle
float rate = 1 - brightness;
if(bakename != "")
hatchingCurves( rate, pp, nf, i, minLength, maxLength, rand, jit, complexity, density, width, bakename );
Oi = Os;
Ci = Oi * Cs * surfcolor;
}