3
* ***** BEGIN GPL LICENSE BLOCK *****
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
20
* All rights reserved.
22
* The Original Code is: all of this file.
24
* Contributor(s): none yet.
26
* ***** END GPL LICENSE BLOCK *****
32
/* ******************** GLOBAL VARIABLES ***************** */
36
/* Subtype names must be less than 15 characters */
39
char stnames[NR_TYPES][16]= {"Square", "Deformed"};
42
NUM|FLO, "size", 1.0, 0.0, 1.0, "The size of each tile",
43
NUM|FLO, "Noise", 1.0, 0.01, 10.0, ""
46
/* The cast struct is for input in the main doit function
47
Varstr and Cast must have the same variables in the same order */
55
Intensity, R, G, B, Alpha, nor.x, nor.y, nor.z
60
/* cfra: the current frame */
64
int plugin_tex_doit(int, Cast *, float *, float *, float *, float *);
65
void plugin_instance_init(Cast*);
67
/* ******************** Fixed functions ***************** */
69
int plugin_tex_getversion(void)
71
return B_PLUGIN_VERSION;
74
void plugin_but_changed(int but)
78
void plugin_init(void)
83
* initialize any data for a particular instance of
86
void plugin_instance_init(Cast *cast)
90
/* this function should not be changed: */
92
void plugin_getinfo(PluginInfo *info)
95
info->stypes= NR_TYPES;
96
info->nvars= sizeof(varstr)/sizeof(VarStruct);
98
info->snames= stnames[0];
101
info->varstr= varstr;
103
info->init= plugin_init;
104
info->tex_doit= (TexDoit) plugin_tex_doit;
105
info->callback= plugin_but_changed;
106
info->instance_init= (void (*)(void *)) plugin_instance_init;
110
/* ************************************************************
113
Demonstration of a simple square wave function sampled
115
It is not mipmapped yet...
117
************************************************************ */
120
/* square wave, antialiased, no mipmap! */
122
float sample_wave(float freq, float coord, float pixsize)
124
float fac, frac, retval;
127
if(pixsize > freq) return 0.5;
135
if(part1 & 1) retval= 0.0;
140
/* is coord+pixsize another value? */
142
part2= ffloor(fac + pixsize);
143
if(part1==part2) return retval;
146
if(retval==1.0) retval= (1.0-frac)/pixsize;
147
else retval= 1.0-(1.0-frac)/pixsize;
152
int plugin_tex_doit(int stype, Cast *cast, float *texvec, float *dxt, float *dyt, float *result)
157
texvec[0]+= hnoise(cast->noise, texvec[0], texvec[1], texvec[2]);
158
texvec[1]+= hnoise(cast->noise, texvec[1], texvec[2], texvec[0]);
162
xwave= sample_wave(cast->size, texvec[0], fabs(dxt[0]) + fabs(dyt[0]) );
163
ywave= sample_wave(cast->size, texvec[1], fabs(dxt[1]) + fabs(dyt[1]) );
165
if(xwave > ywave) result[0]= xwave-ywave;
166
else result[0]= ywave-xwave;
169
xwave= sample_wave(cast->size, texvec[0], 0.0 );
170
ywave= sample_wave(cast->size, texvec[1], 0.0 );
172
if(xwave > ywave) result[0]= xwave-ywave;
173
else result[0]= ywave-xwave;