# source:golgotha/src/maxtool/sdk_inc/texutil.h@80Tweet

Last change on this file since 80 was 80, checked in by Sam Hocevar, 14 years ago
• Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
• Property svn:keywords set to `Id`
File size: 2.9 KB
Line
1/**********************************************************************
2 *<
3        FILE: texutil.h
4
5        DESCRIPTION:
6
7        CREATED BY: Dan Silva
8
9        HISTORY:
10
12 **********************************************************************/
13
14
15#ifndef __TEXUTIL__H
16
17#define __TEXUTIL__H
18
19//
20//      Misc. noise functions from Texturing and Modeling A Procedural Approach
21//  Perlin, Musgrave...
22//
23
24CoreExport float bias(float a, float b);
25CoreExport float gain(float a, float b);
26CoreExport float clamp(float x, float a, float b);
27
28CoreExport float boxstep(float a, float b, float x); // linear from (a,0) to (b,1)
29CoreExport float smoothstep(float a, float b, float x);  // Hermite cubic from (a,0) to (b,1)
30CoreExport float mod(float x, float m); // returns x Mod m, handles negatives correctly
31CoreExport int mod(int x, int m); // returns x Mod m, handles negatives correctly
32
33// This function makes a sort of straight segment S curve.
34// sramp() is a for x < a-d and b for x > b+d.
35// for a+d < x < b-d sramp(x) = x
36// for a-d < x < a+d sramp makes a smooth transition (parabolic) from
37//     sramp' = 0 to sramp' = 1
38// for b-d < x < b+d sramp makes a smooth transition (parabolic) from
39//     sramp' = 1 to sramp' = 0
40CoreExport float sramp(float x,float a, float b, float d);
41
42// returns 0 if x<a, 1 if x>b otherwise x.
43CoreExport float threshold(float x,float a, float b);
44
45CoreExport void  setdebug(int i);
46CoreExport float noise1(float arg);
47CoreExport float noise2(Point2 p);
48CoreExport float noise3(Point3 p);
49CoreExport float noise4(Point3 p,float time);
50
51// This is 3DStudio's Noise function: its only slightly different from noise3:
52//  scaled up by factor of 1.65 and clamped to -1,+1.
53CoreExport float noise3DS(Point3 p);
54
55CoreExport float turbulence(Point3& p, float freq);
56
57CoreExport int Perm(int v);
58
59#define MAX_OCTAVES     50
60CoreExport float fBm1(float  point, float H, float lacunarity, float octaves);
61CoreExport float fBm1(Point2 point, float H, float lacunarity, float octaves);
62CoreExport float fBm1(Point3 point, float H, float lacunarity, float octaves);
63
64CoreExport float spline(float x, int nknots, float *knot);
65
66CoreExport Color color_spline(float x, int nknots, Color *knot);
67
68
69// faster version of floor
70inline int FLOOR( float x) { return ((int)(x)-((x)<0.0f)); }
71
72inline float frac(float x) { return x - (float)FLOOR(x); }
73inline float fmax(float x, float y) { return x>y?x:y;   }
74inline float fmin(float x, float y) { return x<y?x:y;   }
75
76// Macro to map it into interval [0,1]
77#define NOISE(p) ((1.0f+noise3DS(p))*.5f)
78
79// alpha-composite ctop on top of cbot, assuming pre-multiplied alpha
80inline AColor AComp(AColor cbot, AColor ctop) {
81        float ia = 1.0f - ctop.a;
82        return (ctop + ia*cbot);
83        }
84
85#endif
Note: See TracBrowser for help on using the repository browser.