Blender  V2.59
DNA_material_types.h
Go to the documentation of this file.
00001 /*
00002  * $Id: DNA_material_types.h 38090 2011-07-04 18:14:41Z jbakker $ 
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): none yet.
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  */
00029 #ifndef DNA_MATERIAL_TYPES_H
00030 #define DNA_MATERIAL_TYPES_H
00031 
00036 #include "DNA_ID.h"
00037 #include "DNA_listBase.h"
00038 
00039 #ifndef MAX_MTEX
00040 #define MAX_MTEX        18
00041 #endif
00042 
00043 struct MTex;
00044 struct ColorBand;
00045 struct Group;
00046 struct bNodeTree;
00047 struct AnimData;
00048 struct Ipo;
00049 
00050 /* WATCH IT: change type? also make changes in ipo.h  */
00051 
00052 typedef struct VolumeSettings {
00053         float density;
00054         float emission;
00055         float scattering;
00056         float reflection;
00057 
00058         float emission_col[3];
00059         float transmission_col[3];
00060         float reflection_col[3];
00061 
00062         float density_scale;
00063         float depth_cutoff;
00064         float asymmetry;
00065         
00066         short stepsize_type;
00067         short shadeflag;
00068         short shade_type;
00069         short precache_resolution;
00070 
00071         float stepsize;
00072         float ms_diff;
00073         float ms_intensity;
00074         float ms_spread;
00075 } VolumeSettings;
00076 
00077 typedef struct Material {
00078         ID id;
00079         struct AnimData *adt;   /* animation data (must be immediately after id for utilities to use it) */ 
00080         
00081         short material_type, flag;      
00082         /* note, keep this below synced with render_types.h */
00083         float r, g, b;
00084         float specr, specg, specb;
00085         float mirr, mirg, mirb;
00086         float ambr, ambb, ambg;
00087         float amb, emit, ang, spectra, ray_mirror;
00088         float alpha, ref, spec, zoffs, add;
00089         float translucency;
00090         /* end synced with render_types.h */
00091         
00092         struct VolumeSettings vol;
00093 
00094         float fresnel_mir, fresnel_mir_i;
00095         float fresnel_tra, fresnel_tra_i;
00096         float filter;           /* filter added, for raytrace transparency and transmissivity */
00097         float tx_limit, tx_falloff;
00098         short ray_depth, ray_depth_tra;
00099         short har;
00100         char seed1, seed2;
00101         
00102         float gloss_mir, gloss_tra;
00103         short samp_gloss_mir, samp_gloss_tra;
00104         float adapt_thresh_mir, adapt_thresh_tra;
00105         float aniso_gloss_mir;
00106         float dist_mir;
00107         short fadeto_mir;
00108         short shade_flag;               /* like Cubic interpolation */
00109                 
00110         int mode, mode_l;               /* mode_l is the or-ed result of all layer modes */
00111         short flarec, starc, linec, ringc;
00112         float hasize, flaresize, subsize, flareboost;
00113         float strand_sta, strand_end, strand_ease, strand_surfnor;
00114         float strand_min, strand_widthfade;
00115         char strand_uvname[32];
00116         
00117         float sbias;                    /* shadow bias to prevent terminator prob */
00118         float lbias;                    /* factor to multiply lampbias with (0.0 = no mult) */
00119         float shad_alpha;               /* in use for irregular shadowbuffer */
00120         int     septex;
00121         
00122         /* for buttons and render*/
00123         char rgbsel, texact, pr_type, use_nodes;
00124         short pr_back, pr_lamp, pr_texture, ml_flag;    /* ml_flag is for disable base material */
00125         
00126         /* shaders */
00127         short diff_shader, spec_shader;
00128         float roughness, refrac;
00129         /* XXX param[4] needs review and improvement (shader system as whole anyway)
00130            This is nasty reused variable for different goals and not easy to RNAify nicely. -jesterKing */
00131         float param[4];         /* size, smooth, size, smooth, for toonshader, 0 (fac) and 1 (fresnel) also for fresnel shader */
00132         float rms;
00133         float darkness;
00134         short texco, mapto;
00135         
00136         /* ramp colors */
00137         struct ColorBand *ramp_col;
00138         struct ColorBand *ramp_spec;
00139         char rampin_col, rampin_spec;
00140         char rampblend_col, rampblend_spec;
00141         short ramp_show, pad3;
00142         float rampfac_col, rampfac_spec;
00143 
00144         struct MTex *mtex[18];          /* MAX_MTEX */
00145         struct bNodeTree *nodetree;     
00146         struct Ipo *ipo;                // XXX depreceated... old animation system
00147         struct Group *group;    /* light group */
00148         struct PreviewImage * preview;
00149 
00150         /* dynamic properties */
00151         float friction, fh, reflect;
00152         float fhdist, xyfrict;
00153         short dynamode, pad2;
00154 
00155         /* subsurface scattering */
00156         float sss_radius[3], sss_col[3];
00157         float sss_error, sss_scale, sss_ior;
00158         float sss_colfac, sss_texfac;
00159         float sss_front, sss_back;
00160         short sss_flag, sss_preset;
00161 
00162         int mapto_textured;     /* render-time cache to optimise texture lookups */
00163         short shadowonly_flag;          /* "shadowsonly" type */
00164         short index;    /* custom index for render passes */
00165 
00166         ListBase gpumaterial;           /* runtime */
00167 } Material;
00168 
00169 /* **************** MATERIAL ********************* */
00170 
00171 /* maximum number of materials per material array.
00172  * (on object, mesh, lamp, etc.). limited by
00173  * short mat_nr in verts, faces. */
00174 #define MAXMAT                  32767
00175 
00176 /* material_type */
00177 #define MA_TYPE_SURFACE 0
00178 #define MA_TYPE_HALO    1
00179 #define MA_TYPE_VOLUME  2
00180 #define MA_TYPE_WIRE    3
00181 
00182 /* flag */
00183                 /* for render */
00184 #define MA_IS_USED              1
00185                 /* for dopesheet */
00186 #define MA_DS_EXPAND    2
00187                 /* for dopesheet (texture stack expander)
00188                  * NOTE: this must have the same value as other texture stacks, 
00189                  * otherwise anim-editors will not read correctly
00190                  */
00191 #define MA_DS_SHOW_TEXS 4
00192 
00193 /* mode (is int) */
00194 #define MA_TRACEBLE             1
00195 #define MA_SHADOW               2
00196 #define MA_SHLESS               4
00197 #define MA_WIRE                 8                       /* deprecated */
00198 #define MA_VERTEXCOL    16
00199 #define MA_HALO_SOFT    16
00200 #define MA_HALO                 32                      /* deprecated */
00201 #define MA_ZTRANSP              64
00202 #define MA_VERTEXCOLP   128
00203 #define MA_ZINV                 256
00204 #define MA_HALO_RINGS   256
00205 #define MA_ENV                  512
00206 #define MA_HALO_LINES   512
00207 #define MA_ONLYSHADOW   1024
00208 #define MA_HALO_XALPHA  1024
00209 #define MA_STAR                 0x800
00210 #define MA_FACETEXTURE  0x800
00211 #define MA_HALOTEX              0x1000
00212 #define MA_HALOPUNO             0x2000
00213 #define MA_ONLYCAST             0x2000
00214 #define MA_NOMIST               0x4000
00215 #define MA_HALO_SHADE   0x4000
00216 #define MA_HALO_FLARE   0x8000
00217 #define MA_TRANSP               0x10000
00218 #define MA_RAYTRANSP    0x20000
00219 #define MA_RAYMIRROR    0x40000
00220 #define MA_SHADOW_TRA   0x80000
00221 #define MA_RAMP_COL             0x100000
00222 #define MA_RAMP_SPEC    0x200000
00223 #define MA_RAYBIAS              0x400000
00224 #define MA_FULL_OSA             0x800000
00225 #define MA_TANGENT_STR  0x1000000
00226 #define MA_SHADBUF              0x2000000
00227                 /* note; we drop MA_TANGENT_STR later to become tangent_u */
00228 #define MA_TANGENT_V    0x4000000
00229 /* qdn: a bit clumsy this, tangents needed for normal maps separated from shading */
00230 #define MA_NORMAP_TANG  0x8000000
00231 #define MA_GROUP_NOLAY  0x10000000
00232 #define MA_FACETEXTURE_ALPHA    0x20000000
00233 #define MA_STR_B_UNITS  0x40000000
00234 #define MA_STR_SURFDIFF 0x80000000
00235 
00236 #define MA_MODE_MASK    0x6fffffff      /* all valid mode bits */
00237 
00238 /* ray mirror fadeout */
00239 #define MA_RAYMIR_FADETOSKY     0
00240 #define MA_RAYMIR_FADETOMAT     1
00241 
00242 /* shadowonly_flag */
00243 #define MA_SO_OLD                       0
00244 #define MA_SO_SHADOW            1
00245 #define MA_SO_SHADED            2
00246 
00247 /* shade_flag */
00248 #define MA_CUBIC                        1
00249 #define MA_OBCOLOR                      2
00250 #define MA_APPROX_OCCLUSION     4
00251 
00252 /* diff_shader */
00253 #define MA_DIFF_LAMBERT         0
00254 #define MA_DIFF_ORENNAYAR       1
00255 #define MA_DIFF_TOON            2
00256 #define MA_DIFF_MINNAERT    3
00257 #define MA_DIFF_FRESNEL     4
00258 
00259 /* spec_shader */
00260 #define MA_SPEC_COOKTORR        0
00261 #define MA_SPEC_PHONG           1
00262 #define MA_SPEC_BLINN           2
00263 #define MA_SPEC_TOON            3
00264 #define MA_SPEC_WARDISO         4
00265 
00266 /* dynamode */
00267 #define MA_DRAW_DYNABUTS    1           /* deprecated */
00268 #define MA_FH_NOR               2
00269 
00270 /* ramps */
00271 #define MA_RAMP_IN_SHADER       0
00272 #define MA_RAMP_IN_ENERGY       1
00273 #define MA_RAMP_IN_NOR          2
00274 #define MA_RAMP_IN_RESULT       3
00275 
00276 #define MA_RAMP_BLEND           0
00277 #define MA_RAMP_ADD                     1
00278 #define MA_RAMP_MULT            2
00279 #define MA_RAMP_SUB                     3
00280 #define MA_RAMP_SCREEN          4
00281 #define MA_RAMP_DIV                     5
00282 #define MA_RAMP_DIFF            6
00283 #define MA_RAMP_DARK            7
00284 #define MA_RAMP_LIGHT           8
00285 #define MA_RAMP_OVERLAY         9
00286 #define MA_RAMP_DODGE           10
00287 #define MA_RAMP_BURN            11
00288 #define MA_RAMP_HUE                     12
00289 #define MA_RAMP_SAT                     13
00290 #define MA_RAMP_VAL                     14
00291 #define MA_RAMP_COLOR           15
00292 #define MA_RAMP_SOFT        16 
00293 #define MA_RAMP_LINEAR      17 
00294 
00295 /* texco */
00296 #define TEXCO_ORCO              1
00297 #define TEXCO_REFL              2
00298 #define TEXCO_NORM              4
00299 #define TEXCO_GLOB              8
00300 #define TEXCO_UV                16
00301 #define TEXCO_OBJECT    32
00302 #define TEXCO_LAVECTOR  64
00303 #define TEXCO_VIEW              128
00304 #define TEXCO_STICKY    256
00305 #define TEXCO_OSA               512
00306 #define TEXCO_WINDOW    1024
00307 #define NEED_UV                 2048
00308 #define TEXCO_TANGENT   4096
00309         /* still stored in vertex->accum, 1 D */
00310 #define TEXCO_STRAND    8192
00311 #define TEXCO_PARTICLE  8192 /* strand is used for normal materials, particle for halo materials */
00312 #define TEXCO_STRESS    16384
00313 #define TEXCO_SPEED             32768
00314 
00315 /* mapto */
00316 #define MAP_COL                 1
00317 #define MAP_NORM                2
00318 #define MAP_COLSPEC             4
00319 #define MAP_COLMIR              8
00320 #define MAP_VARS                (0xFFF0)
00321 #define MAP_REF                 16
00322 #define MAP_SPEC                32
00323 #define MAP_EMIT                64
00324 #define MAP_ALPHA               128
00325 #define MAP_HAR                 256
00326 #define MAP_RAYMIRR             512
00327 #define MAP_TRANSLU             1024
00328 #define MAP_AMB                 2048
00329 #define MAP_DISPLACE    4096
00330 #define MAP_WARP                8192
00331 #define MAP_LAYER               16384           /* unused */
00332 
00333 /* volume mapto - reuse definitions for now - a bit naughty! */
00334 #define MAP_DENSITY                             128
00335 #define MAP_EMISSION                    64
00336 #define MAP_EMISSION_COL                1
00337 #define MAP_SCATTERING                  16
00338 #define MAP_TRANSMISSION_COL    8
00339 #define MAP_REFLECTION_COL              4
00340 #define MAP_REFLECTION                  32
00341 
00342 
00343 /* mapto for halo */
00344 //#define MAP_HA_COL            1
00345 //#define MAP_HA_ALPHA  128
00346 //#define MAP_HA_HAR            256
00347 //#define MAP_HA_SIZE           2
00348 //#define MAP_HA_ADD            64
00349 
00350 /* pmapto */
00351 /* init */
00352 #define MAP_PA_INIT             31
00353 #define MAP_PA_TIME             1
00354 #define MAP_PA_LIFE             2
00355 #define MAP_PA_DENS             4
00356 #define MAP_PA_SIZE             8
00357 #define MAP_PA_LENGTH   16
00358 /* reset */
00359 #define MAP_PA_IVEL             32
00360 /* physics */
00361 #define MAP_PA_PVEL             64
00362 /* path cache */
00363 #define MAP_PA_CACHE    912
00364 #define MAP_PA_CLUMP    128
00365 #define MAP_PA_KINK             256
00366 #define MAP_PA_ROUGH    512
00367 
00368 /* pr_type */
00369 #define MA_FLAT                 0
00370 #define MA_SPHERE               1
00371 #define MA_CUBE                 2
00372 #define MA_MONKEY               3
00373 #define MA_SPHERE_A             4
00374 #define MA_TEXTURE              5
00375 #define MA_LAMP                 6
00376 #define MA_SKY                  7
00377 #define MA_HAIR                 10
00378 #define MA_ATMOS                11
00379 
00380 /* pr_back */
00381 #define MA_DARK                 1
00382 
00383 /* sss_flag */
00384 #define MA_DIFF_SSS             1
00385 
00386 /* vol_stepsize_type */
00387 #define MA_VOL_STEP_RANDOMIZED  0
00388 #define MA_VOL_STEP_CONSTANT    1
00389 #define MA_VOL_STEP_ADAPTIVE    2
00390 
00391 /* vol_shadeflag */
00392 #define MA_VOL_RECV_EXT_SHADOW  1
00393 #define MA_VOL_PRECACHESHADING  8
00394 
00395 /* vol_shading_type */
00396 #define MA_VOL_SHADE_SHADELESS                                  0
00397 #define MA_VOL_SHADE_SHADOWED                                   2
00398 #define MA_VOL_SHADE_SHADED                                             1
00399 #define MA_VOL_SHADE_MULTIPLE                                   3
00400 #define MA_VOL_SHADE_SHADEDPLUSMULTIPLE                 4
00401 
00402 #endif
00403