Blender  V2.59
RE_shader_ext.h
Go to the documentation of this file.
00001 /*
00002  * $Id: RE_shader_ext.h 37668 2011-06-20 15:20:33Z campbellbarton $
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) 2006 by Blender Foundation
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): none yet.
00026  *
00027  * ***** END GPL/BL DUAL LICENSE BLOCK *****
00028  */
00034 #ifndef RE_SHADER_EXT_H
00035 #define RE_SHADER_EXT_H
00036 
00037 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
00038 /* this include is for shading and texture exports            */
00039 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
00040 
00041 /* localized texture result data */
00042 /* note; tr tg tb ta has to remain in this order */
00043 typedef struct TexResult {
00044         float tin, tr, tg, tb, ta;
00045         int talpha;
00046         float *nor;
00047 } TexResult;
00048 
00049 /* localized shade result data */
00050 typedef struct ShadeResult 
00051 {
00052         float combined[4];
00053         float col[4];
00054         float alpha, mist, z;
00055         float emit[3];
00056         float diff[3];          /* no ramps, shadow, etc */
00057         float spec[3];
00058         float shad[4];          /* shad[3] is shadow intensity */
00059         float ao[3];
00060         float env[3];
00061         float indirect[3];
00062         float refl[3];
00063         float refr[3];
00064         float nor[3];
00065         float winspeed[4];
00066         float rayhits[4];
00067 } ShadeResult;
00068 
00069 /* only here for quick copy */
00070 struct ShadeInputCopy {
00071         
00072         struct Material *mat;
00073         struct VlakRen *vlr;
00074         struct StrandRen *strand;
00075         struct ObjectInstanceRen *obi;
00076         struct ObjectRen *obr;
00077         int facenr;
00078         float facenor[3];                               /* copy from face */
00079         short flippednor;                               /* is facenor flipped? */
00080         struct VertRen *v1, *v2, *v3;   /* vertices can be in any order for quads... */
00081         short i1, i2, i3;                               /* original vertex indices */
00082         short puno;
00083         short osatex;
00084         float vn[3], vno[3];                    /* actual render normal, and a copy to restore it */
00085         float n1[3], n2[3], n3[3];              /* vertex normals, corrected */
00086         int mode;                                               /* base material mode (OR-ed result of entire node tree) */
00087 };
00088 
00089 typedef struct ShadeInputUV {
00090         float dxuv[3], dyuv[3], uv[3];
00091         char *name;
00092 } ShadeInputUV;
00093 
00094 typedef struct ShadeInputCol {
00095         float col[3];
00096         char *name;
00097 } ShadeInputCol;
00098 
00099 /* localized renderloop data */
00100 typedef struct ShadeInput
00101 {
00102         /* copy from face, also to extract tria from quad */
00103         /* note it mirrors a struct above for quick copy */
00104         
00105         struct Material *mat;
00106         struct VlakRen *vlr;
00107         struct StrandRen *strand;
00108         struct ObjectInstanceRen *obi;
00109         struct ObjectRen *obr;
00110         int facenr;
00111         float facenor[3];                               /* copy from face */
00112         short flippednor;                               /* is facenor flipped? */
00113         struct VertRen *v1, *v2, *v3;   /* vertices can be in any order for quads... */
00114         short i1, i2, i3;                               /* original vertex indices */
00115         short puno;
00116         short osatex;
00117         float vn[3], vno[3];                    /* actual render normal, and a copy to restore it */
00118         float n1[3], n2[3], n3[3];              /* vertex normals, corrected */
00119         int mode;                                               /* base material mode (OR-ed result of entire node tree) */
00120         
00121         /* internal face coordinates */
00122         float u, v, dx_u, dx_v, dy_u, dy_v;
00123         float co[3], view[3], camera_co[3];
00124         
00125         /* copy from material, keep synced so we can do memcopy */
00126         /* current size: 23*4 */
00127         float r, g, b;
00128         float specr, specg, specb;
00129         float mirr, mirg, mirb;
00130         float ambr, ambb, ambg;
00131         
00132         float amb, emit, ang, spectra, ray_mirror;
00133         float alpha, refl, spec, zoffs, add;
00134         float translucency;
00135         /* end direct copy from material */
00136         
00137         /* individual copies: */
00138         int har; /* hardness */
00139         
00140         /* texture coordinates */
00141         float lo[3], gl[3], ref[3], orn[3], winco[3], sticky[3], vcol[4];
00142         float refcol[4], displace[3];
00143         float strandco, tang[3], nmapnorm[3], nmaptang[4], stress, winspeed[4];
00144         float duplilo[3], dupliuv[3];
00145 
00146         ShadeInputUV uv[8];   /* 8 = MAX_MTFACE */
00147         ShadeInputCol col[8]; /* 8 = MAX_MCOL */
00148         int totuv, totcol, actuv, actcol;
00149         
00150         /* dx/dy OSA coordinates */
00151         float dxco[3], dyco[3];
00152         float dxlo[3], dylo[3], dxgl[3], dygl[3];
00153         float dxref[3], dyref[3], dxorn[3], dyorn[3];
00154         float dxno[3], dyno[3], dxview, dyview;
00155         float dxlv[3], dylv[3];
00156         float dxwin[3], dywin[3];
00157         float dxsticky[3], dysticky[3];
00158         float dxrefract[3], dyrefract[3];
00159         float dxstrand, dystrand;
00160         
00161         /* AO is a pre-process now */
00162         float ao[3], indirect[3], env[3];
00163         
00164         int xs, ys;                             /* pixel to be rendered */
00165         int mask;                               /* subsample mask */
00166         float scanco[3];                /* original scanline coordinate without jitter */
00167         
00168         int samplenr;                   /* sample counter, to detect if we should do shadow again */
00169         int depth;                              /* 1 or larger on raytrace shading */
00170         int volume_depth;               /* number of intersections through volumes */
00171         
00172         /* for strand shading, normal at the surface */
00173         float surfnor[3], surfdist;
00174 
00175         /* from initialize, part or renderlayer */
00176         short do_preview;               /* for nodes, in previewrender */
00177         short do_manage;                /* color management flag */
00178         short thread, sample;   /* sample: ShadeSample array index */
00179         short nodes;                    /* indicate node shading, temp hack to prevent recursion */
00180         
00181         unsigned int lay;
00182         int layflag, passflag, combinedflag;
00183         struct Group *light_override;
00184         struct Material *mat_override;
00185         
00186 #ifdef RE_RAYCOUNTER
00187         RayCounter raycounter;
00188 #endif
00189         
00190 } ShadeInput;
00191 
00192 
00193 /* node shaders... */
00194 struct Tex;
00195 struct MTex;
00196 struct ImBuf;
00197 
00198 /* this one uses nodes */
00199 int     multitex_ext(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, struct TexResult *texres);
00200 /* nodes disabled */
00201 int multitex_ext_safe(struct Tex *tex, float *texvec, struct TexResult *texres);
00202 /* only for internal node usage */
00203 int multitex_nodes(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, struct TexResult *texres,
00204         short thread, short which_output, struct ShadeInput *shi, struct MTex *mtex);
00205 
00206 /* shaded view and bake */
00207 struct Render;
00208 struct Image;
00209 struct Object;
00210 
00211 int RE_bake_shade_all_selected(struct Render *re, int type, struct Object *actob, short *do_update, float *progress);
00212 struct Image *RE_bake_shade_get_image(void);
00213 void RE_bake_ibuf_filter(struct ImBuf *ibuf, char *mask, const int filter);
00214 
00215 #endif /* RE_SHADER_EXT_H */