46 |
return 1 - 2 * fabs(x - .5); |
return 1 - 2 * fabs(x - .5); |
47 |
} |
} |
48 |
|
|
49 |
|
float stripe(float x) { |
50 |
|
x -= floor(x); |
51 |
|
return (x < .4999999); |
52 |
|
} |
53 |
|
|
54 |
void GENERATE(TextureParam *params, int width, int height, int depth, int components, float *data) { |
void GENERATE(TextureParam *params, int width, int height, int depth, int components, float *data) { |
55 |
FPARAM(type, 0) |
FPARAM(type, 0); |
56 |
|
FPARAM(scale, 1); |
57 |
|
FPARAM(bias, 0); |
58 |
if(components > 4) return; |
if(components > 4) return; |
59 |
|
|
60 |
|
|
104 |
if (components >= 3) data[ind++] = triangle(y); |
if (components >= 3) data[ind++] = triangle(y); |
105 |
if (components >= 4) data[ind++] = triangle(.5 + y); |
if (components >= 4) data[ind++] = triangle(.5 + y); |
106 |
break; |
break; |
107 |
|
case 6: |
108 |
|
if (components >= 1) data[ind++] = stripe(x); |
109 |
|
if (components >= 2) data[ind++] = stripe(1 - xstep - x); |
110 |
|
if (components >= 3) data[ind++] = stripe(y); |
111 |
|
if (components >= 4) data[ind++] = stripe(1 - ystep - y); |
112 |
|
break; |
113 |
|
|
114 |
} |
} |
115 |
} |
} |
116 |
} |
} |
117 |
|
|
118 |
|
for(int i = 0; i < width * height * depth * components; i++) { |
119 |
|
data[i] = data[i] * scale + bias; |
120 |
|
} |
121 |
|
|
122 |
} |
} |