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 char name[24]= "Clouds2";
38 /* Subtype names must be less than 15 characters */
41 char stnames[NR_TYPES][16]= {"Intens", "Col", "Bump" };
43 /* Structure for buttons,
44 * butcode name default min max 0
48 { NUM|FLO, "Offset", -0.5, -20.0, 20.0, ""},
49 { NUM|INT, "Depth", 8.0, 1.0, 12.0, ""},
50 { NUM|FLO, "Scale", 2.2, -20.0, 20.0, ""},
51 { NUM|FLO, "Falloff", 1.0, -20.0, 20.0, ""}
54 /* The cast struct is for input in the main doit function
55 Varstr and Cast must have the same variables in the same order,
56 INCLUDING dummy variables for label fields. */
66 Intensity, R, G, B, Alpha, nor.x, nor.y, nor.z
71 /* cfra: the current frame */
75 int plugin_tex_doit(int, Cast*, float*, float*, float*, float*);
76 void plugin_instance_init(Cast*);
78 /* ******************** Fixed functions ***************** */
80 int plugin_tex_getversion(void)
82 return B_PLUGIN_VERSION;
85 void plugin_but_changed(int but)
89 void plugin_init(void)
95 * initialize any data for a particular instance of
98 void plugin_instance_init(Cast *cast)
102 /* this function should not be changed: */
104 void plugin_getinfo(PluginInfo *info)
107 info->stypes= NR_TYPES;
108 info->nvars= sizeof(varstr)/sizeof(VarStruct);
110 info->snames= stnames[0];
111 info->result= result;
113 info->varstr= varstr;
115 info->init= plugin_init;
116 info->tex_doit= (TexDoit) plugin_tex_doit;
117 info->callback= plugin_but_changed;
118 info->instance_init= (void (*)(void *)) plugin_instance_init;
121 /* ********************* the texture ******************** */
124 int plugin_tex_doit(int stype, Cast *cast, float *texvec, float *dxt, float *dyt, float *result)
133 tv[0]=(texvec[0]+1.0)/2.0;
134 tv[1]=(texvec[1]+1.0)/2.0;
135 tv[2]=(texvec[2]+1.0)/2.0;
137 p[0] = cast->txtscale * tv[0];
138 p[1] = cast->txtscale * tv[1];
139 p[2] = cast->txtscale * tv[2];
141 for (i=0; i<cast->depth; i++) {
142 val += a * hnoise(1.0, p[0], p[1], p[2]);
150 /* always return this value */
151 result[0] = CLAMP (val+cast->offset, 0.0, 1.0) * pow (fabs(sqrt(tv[0]*tv[0]+tv[1]*tv[1]+tv[2]*tv[2])), cast->falloff);
155 * this is r, g, b, a:
157 result[1]= 0.5*result[0];
159 result[3]= fsqrt(fabs(result[0]));
166 * This value is the displacement of the actual normal in
167 * the Material calculation.