Blender V2.61 - r43446

DNA_material_types.h

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