Font size: +
3 minutes reading time (629 words)

Happy Rendering with VEX에서 필요한 Header File


​Happy Rendering With VEX 에서 필요한 Header File 입니다.

가장 필수적으로 필요한 것은 vexnotes.h 이고

일부만 STREE_math.h, STREE_feathery.h 가필요한데 시작할 때 같이 추가하거나 참고하시면 좋을 것 같습니다.

소스코드와 첨부파일로 Header File같이 올립니다.

추가경로 : $HOME\Houdini VERSION\houdini\vex\include

zip
File Name: HappyRendering_Headers.zip
File Size: 2 kb
Download File

​vexnotes.h

/*
 * Produced by:
 *      Keita Maeda
 *
 * NAME:        vexnotes.h (VEX)
 *
 * COMMENTS:   This file is macros to be used in conjunction with 
 *             Houdini VEX shader language.
 */

 /*Hyunjun Cheong Repair codes 2015.09.16 */

#include <math.h>

float pulse(float a,b,fuzz,x)
{
  return smooth(a-fuzz, a, x) - smooth(b-fuzz, b, x);
}

float boxstep(float a,b,x)
{
  return clamp((x - a)/b - a, 0, 1);
}

float repeat(float x,freq)
{
  return (x * freq) % 1.0;
}

int odd(float x)
{
  return      (((x)%2) == 1);
}

int even(float x)
{
  return      (((x)%2) == 0);
}

float blend(float a,b,x)
{
  return  ((a) * (1 - (x)) + (b) * (x));
}

float whichtile(float x,freq) 
{
	return (floor((x) * (freq)));
}

/* rotate2d()
 *
 * 2D rotation of point (x,y) about origin (ox,oy) by an angle rad.
 * The resulting point is (rx, ry).
 *
 */

void rotate2d(float x,y,rad,ox,oy,rx,ry) 
{
  rx = (x - ox) * cos(rad) - (y - oy) * sin(rad) + ox; 
  ry = (x - ox) * sin(rad) + (y - oy) * cos(rad) + oy;
}


/* topolar2d()
 * 
 * 2D cartesian -> polar coordinates
 * converts the point (x,y) to radius 'r' and angle 'theta' (in radians).
 * theta will be in the range [-PI,PI].
 *
 */
void topolar2d(float x, y, r, theta)
{
  r = sqrt(x * x + y * y); 
  theta = atan2(y, x); 
}


/* boolean ops (from Perlin85)
 *
 */
#define intersection(a,b) ((a) * (b))
#define union(a,b)        ((a) + (b) - (a) * (b))
#define difference(a,b)   ((a) - (a) * (b))
#define complement(a)     (1 - (a))


/* blend() and lerp() are equivalent. blend() is used as a substitute for
 * mix because it allows non-scalar 3rd arguments.
 *
 */
#define blend(a,b,x) ((a) * (1 - (x)) + (b) * (x))
#define lerp(a,b,x)  ((a) * (1 - (x)) + (b) * (x))

/* signed noise
 *
 */
#define snoise(x)    (noise(x) * 2 - 1)
#define snoise2(x,y) (noise(x,y) * 2 - 1)

/* uniformly distributed noise
 *
 */
#define udn(x,lo,hi) (smooth(.25, .75, noise(x)) * ((hi) - (lo)) + (lo))
#define udn2(x,y,lo,hi) (smooth(.25, .75, noise(x,y)) * ((hi)-(lo))+(lo))

/* sample rate metrics (from Apodaca92)
 *
 */
#define MINFILTERWIDTH  1e-7
#define MINDERIV        0.0003    /* sqrt(MINFILTERWIDTH) */

#define filterwidth(x) (max(abs(Du(x)) + (Dv(x)),MINFILTERWIDTH))
#define filterwidth_point(p) (max(sqrt(area(p)), MINFILTERWIDTH))

 

​STREE_math.h

/* taken from SGI's /usr/include/math.h - see 'man math' */
#define _STREE_E             2.7182818284590452354
#define _STREE_LOG2E         1.4426950408889634074
#define _STREE_LOG10E        0.43429448190325182765
#define _STREE_LN2           0.69314718055994530942
#define _STREE_LN10          2.30258509299404568402
#define _STREE_PI            3.14159265358979323846
#define _STREE_PI_2          1.57079632679489661923
#define _STREE_PI_4          0.78539816339744830962
#define _STREE_1_PI          0.31830988618379067154
#define _STREE_2_PI          0.63661977236758134308
#define _STREE_2_SQRTPI      1.12837916709551257390
#define _STREE_SQRT2         1.41421356237309504880
#define _STREE_SQRT1_2       0.70710678118654752440
#define _STREE_PI2           6.28318530717958647692
#define _STREE_SQRTPI 	     1.77245385090551602729
#define _STREE_SQRT3 	     1.73205080756887729353
#define MINFILTERWIDTH 	     1.0e-6

#define STREE_sq(x) 		((x)*(x))
#define STREE_cube(x) 		((x)*(x)*(x))
#define STREE_quad(x) 		((x)*(x)*(x)*(x))
#define STREE_shift(x) 		(((x)+1.0)/2.0)
#define STREE_radius(a,b) 	(sqrt(((a)*(a))+((b)*(b))))
#define STREE_aasize(x) 	(max(length(Du(x)),length(Dv(x))))
#define STREE_blend(b,w,x) 	(smoothstep((b)-(w),(b)+(w),x))
#define STREE_luminence(c) 	(avg(c))
#define STREE_snoise(a)  	(2.0*noise(a)-1.0)
#define STREE_snoiseC(c) 	((vector) (2.0*noise(c)-1.0))
#define STREE_snoiseP(p) 	((vector) (2.0*noise(p)-1.0))
#define STREE_snoiseV(v) 	((vector) (2.0*noise(v)-1.0))
#define STREE_snoiseN(n) 	((vector) (2.0*noise(n)-1.0))
#define STREE_snoiseT(p,t) 	(2.0*noise(p,t)-1.0)
#define STREE_bias(x,b) 	(pow(x,log(b)/log(0.5))
#define STREE_blendwidth(x,y) 	(floor(x)*(1.0-(2.0*(y)))+max(0.0,frac(x)-(y)))
#define STREE_fuzzy(a,b,zz,x) 	(smoothstep((a)-(zz),a,x)*(1.0-smoothstep(b,(b)+(zz),x)))
#define STREE_filterwidth(x) 	(max((abs(Du(x)*Du(s))+abs(Dv(x)*Du(t))),MINFILTERWIDTH))
#define STREE_filteredpulse(a,b,x,w) (max(0.0,(min((x)-((w)/2.0),a)-max(((x)-((w)/2.0))+w,b))/w)) 

STREE_feathery.h

float STREE_feathery(vector p; float freq, it;)
{
	float sum = 0.0;
	float size = 1.0;
	float i;
	for (i = 0.0; i < it; i += 1.0 )
	{
		 sum += (float) STREE_snoise((size*p) + (STREE_snoiseV(size*p)*freq))/size;
		 size *= 2.0;
	}
	return(sum*1.4);
} 
OS X Target HFS
speckles.vfl

Related Posts

 

Comments

No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Saturday, 06 June 2026