
#ifndef __SL2VEX_H__
#define __SL2VEX_H__

#ifndef __vex

#define export

vector cross(vector x, y) { return x ^ y; }
#define setp(a, b, c) point(a, b, c)
#define setv(a, b, c) vector(a, b, c)
#define setc(a, b, c) color(a, b, c)

vector shader_space(vector N) { return vtransform("shader", N); }
color hsvtorgb(float r, g, b) { return color "hsv" (r, g, b); }

#else /* __vex */

#define PI 3.1415926535897932384626433832795

#define Ci Cf
#define Oi Of

#define uniform
#define varying
#define output

#define point vector
#define color vector
#define normal vector

/* Houdini's mod function (%) is a regular modulus, and is not
   equivalent to RenderMan's mod, which works with negative values.
   modhack implements a RenderMan-like mod (basically the same as
   presented in "Texturing and Modeling: A Procedural Approach".
*/
float modhack(float a, b)
{
  int n = a/b;
  float val = a - n*b;
  if (val < 0) val += b;
  return val;
}

#define mod modhack

#define faceforward(N, I) frontface(N, I)
#define smoothstep(x, a, b) smooth(x, a, b)
#define calculatenormal(P) computenormal(P)

float xcomp(vector x) { return getcomp(x, 0); }
float ycomp(vector x) { return getcomp(x, 1); }
float zcomp(vector x) { return getcomp(x, 2); }

#define comp getcomp
#define setp set
#define setv set
#define setc set

vector shader_space(vector N) { return wt_nspace(N); }

#undef snoise
float snoise(float pt) { return noise(pt)*2 - 1; }

#endif /* __vex */

#endif /* __SL2VEX_H__ */

