Blender V2.61 - r43446
|
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) 2006 Blender Foundation. 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 RE_PIPELINE_H 00033 #define RE_PIPELINE_H 00034 00035 #include "DNA_listBase.h" 00036 #include "DNA_vec_types.h" 00037 00038 struct bNodeTree; 00039 struct Image; 00040 struct Main; 00041 struct NodeBlurData; 00042 struct Object; 00043 struct RenderData; 00044 struct RenderResult; 00045 struct ReportList; 00046 struct Scene; 00047 struct SceneRenderLayer; 00048 struct EnvMap; 00049 00050 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 00051 /* this include is what is exposed of render to outside world */ 00052 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 00053 00054 00055 #define RE_MAXNAME 32 00056 00057 /* only used as handle */ 00058 typedef struct Render Render; 00059 00060 /* Render Result usage: 00061 00062 - render engine allocates/frees and delivers raw floating point rects 00063 - right now it's full rects, but might become tiles or file 00064 - the display client has to allocate display rects, sort out what to display, 00065 and how it's converted 00066 */ 00067 00068 typedef struct RenderPass { 00069 struct RenderPass *next, *prev; 00070 int passtype, channels; 00071 char name[16]; /* amount defined in openexr_multi.h */ 00072 char chan_id[8]; /* amount defined in openexr_multi.h */ 00073 float *rect; 00074 int rectx, recty; 00075 } RenderPass; 00076 00077 /* a renderlayer is a full image, but with all passes and samples */ 00078 /* size of the rects is defined in RenderResult */ 00079 /* after render, the Combined pass is in rectf, for renderlayers read from files it is a real pass */ 00080 typedef struct RenderLayer { 00081 struct RenderLayer *next, *prev; 00082 00083 /* copy of RenderData */ 00084 char name[RE_MAXNAME]; 00085 unsigned int lay, lay_zmask; 00086 int layflag, passflag, pass_xor; 00087 00088 struct Material *mat_override; 00089 struct Group *light_override; 00090 00091 float *rectf; /* 4 float, standard rgba buffer (read not above!) */ 00092 float *acolrect; /* 4 float, optional transparent buffer, needs storage for display updates */ 00093 float *scolrect; /* 4 float, optional strand buffer, needs storage for display updates */ 00094 int rectx, recty; 00095 00096 ListBase passes; 00097 00098 } RenderLayer; 00099 00100 typedef struct RenderResult { 00101 struct RenderResult *next, *prev; 00102 00103 /* target image size */ 00104 int rectx, recty; 00105 short crop, sample_nr; 00106 00107 /* optional, 32 bits version of picture, used for ogl render and image curves */ 00108 int *rect32; 00109 /* if this exists, a copy of one of layers, or result of composited layers */ 00110 float *rectf; 00111 /* if this exists, a copy of one of layers, or result of composited layers */ 00112 float *rectz; 00113 00114 /* coordinates within final image (after cropping) */ 00115 rcti tilerect; 00116 /* offset to apply to get a border render in full image */ 00117 int xof, yof; 00118 00119 /* the main buffers */ 00120 ListBase layers; 00121 00122 /* allowing live updates: */ 00123 volatile rcti renrect; 00124 volatile RenderLayer *renlay; 00125 00126 /* optional saved endresult on disk */ 00127 void *exrhandle; 00128 00129 /* for render results in Image, verify validity for sequences */ 00130 int framenr; 00131 00132 /* for acquire image, to indicate if it there is a combined layer */ 00133 int have_combined; 00134 00135 /* render info text */ 00136 char *text; 00137 00138 } RenderResult; 00139 00140 00141 typedef struct RenderStats { 00142 int cfra; 00143 int totface, totvert, totstrand, tothalo, totlamp, totpart; 00144 short curfield, curblur, curpart, partsdone, convertdone, curfsa; 00145 double starttime, lastframetime; 00146 const char *infostr, *statstr; 00147 char scenename[32]; 00148 00149 } RenderStats; 00150 00151 /* *********************** API ******************** */ 00152 00153 /* the name is used as identifier, so elsewhere in blender the result can retrieved */ 00154 /* calling a new render with same name, frees automatic existing render */ 00155 struct Render *RE_NewRender (const char *name); 00156 struct Render *RE_GetRender(const char *name); 00157 00158 /* returns 1 while render is working (or renders called from within render) */ 00159 int RE_RenderInProgress(struct Render *re); 00160 00161 /* assign default dummy callbacks */ 00162 void RE_InitRenderCB(struct Render *re); 00163 00164 /* use free render as signal to do everything over (previews) */ 00165 void RE_FreeRender (struct Render *re); 00166 /* only called on exit */ 00167 void RE_FreeAllRender (void); 00168 00169 /* get results and statistics */ 00170 void RE_FreeRenderResult(struct RenderResult *rr); 00171 struct RenderResult *RE_AcquireResultRead(struct Render *re); 00172 struct RenderResult *RE_AcquireResultWrite(struct Render *re); 00173 void RE_ReleaseResult(struct Render *re); 00174 void RE_AcquireResultImage(struct Render *re, struct RenderResult *rr); 00175 void RE_ReleaseResultImage(struct Render *re); 00176 void RE_SwapResult(struct Render *re, struct RenderResult **rr); 00177 struct RenderStats *RE_GetStats(struct Render *re); 00178 void RE_ResultGet32(struct Render *re, unsigned int *rect); 00179 struct RenderLayer *RE_GetRenderLayer(struct RenderResult *rr, const char *name); 00180 float *RE_RenderLayerGetPass(struct RenderLayer *rl, int passtype); 00181 00182 /* obligatory initialize call, disprect is optional */ 00183 void RE_InitState (struct Render *re, struct Render *source, struct RenderData *rd, struct SceneRenderLayer *srl, int winx, int winy, rcti *disprect); 00184 00185 /* set up the viewplane/perspective matrix, three choices */ 00186 struct Object *RE_GetCamera(struct Render *re); /* return camera override if set */ 00187 void RE_SetCamera(struct Render *re, struct Object *camera); 00188 void RE_SetEnvmapCamera(struct Render *re, struct Object *cam_ob, float viewscale, float clipsta, float clipend); 00189 void RE_SetWindow (struct Render *re, rctf *viewplane, float clipsta, float clipend); 00190 void RE_SetOrtho (struct Render *re, rctf *viewplane, float clipsta, float clipend); 00191 void RE_SetPixelSize(struct Render *re, float pixsize); 00192 00193 /* option to set viewmatrix before making dbase */ 00194 void RE_SetView (struct Render *re, float mat[][4]); 00195 00196 /* make or free the dbase */ 00197 void RE_Database_FromScene(struct Render *re, struct Main *bmain, struct Scene *scene, unsigned int lay, int use_camera_view); 00198 void RE_Database_Free (struct Render *re); 00199 00200 /* project dbase again, when viewplane/perspective changed */ 00201 void RE_DataBase_ApplyWindow(struct Render *re); 00202 00203 /* override the scene setting for amount threads, commandline */ 00204 void RE_set_max_threads(int threads); 00205 00206 /* set the render threads based on the commandline and autothreads setting */ 00207 void RE_init_threadcount(Render *re); 00208 00209 /* the main processor, assumes all was set OK! */ 00210 void RE_TileProcessor(struct Render *re); 00211 00212 /* only RE_NewRender() needed, main Blender render calls */ 00213 void RE_BlenderFrame(struct Render *re, struct Main *bmain, struct Scene *scene, struct SceneRenderLayer *srl, struct Object *camera_override, unsigned int lay, int frame, const short write_still); 00214 void RE_BlenderAnim(struct Render *re, struct Main *bmain, struct Scene *scene, struct Object *camera_override, unsigned int lay, int sfra, int efra, int tfra); 00215 00216 /* error reporting */ 00217 void RE_SetReports(struct Render *re, struct ReportList *reports); 00218 00219 /* main preview render call */ 00220 void RE_PreviewRender(struct Render *re, struct Main *bmain, struct Scene *scene); 00221 00222 int RE_ReadRenderResult(struct Scene *scene, struct Scene *scenode); 00223 int RE_WriteRenderResult(struct ReportList *reports, RenderResult *rr, const char *filename, int compress); 00224 struct RenderResult *RE_MultilayerConvert(void *exrhandle, int rectx, int recty); 00225 00226 extern const float default_envmap_layout[]; 00227 int RE_WriteEnvmapResult(struct ReportList *reports, struct Scene *scene, struct EnvMap *env, const char *relpath, const char imtype, float layout[12]); 00228 00229 /* do a full sample buffer compo */ 00230 void RE_MergeFullSample(struct Render *re, struct Main *bmain, struct Scene *sce, struct bNodeTree *ntree); 00231 00232 /* ancient stars function... go away! */ 00233 void RE_make_stars(struct Render *re, struct Scene *scenev3d, void (*initfunc)(void), 00234 void (*vertexfunc)(float*), void (*termfunc)(void)); 00235 00236 /* display and event callbacks */ 00237 void RE_display_init_cb (struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr)); 00238 void RE_display_clear_cb(struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr)); 00239 void RE_display_draw_cb (struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr, volatile struct rcti *rect)); 00240 void RE_stats_draw_cb (struct Render *re, void *handle, void (*f)(void *handle, RenderStats *rs)); 00241 void RE_progress_cb (struct Render *re, void *handle, void (*f)(void *handle, float)); 00242 void RE_draw_lock_cb (struct Render *re, void *handle, void (*f)(void *handle, int)); 00243 void RE_test_break_cb (struct Render *re, void *handle, int (*f)(void *handle)); 00244 00245 /* should move to kernel once... still unsure on how/where */ 00246 float RE_filter_value(int type, float x); 00247 /* vector blur zbuffer method */ 00248 void RE_zbuf_accumulate_vecblur(struct NodeBlurData *nbd, int xsize, int ysize, float *newrect, float *imgrect, float *vecbufrect, float *zbufrect); 00249 00250 int RE_seq_render_active(struct Scene *scene, struct RenderData *rd); 00251 00252 /* shaded view or baking options */ 00253 #define RE_BAKE_LIGHT 0 /* not listed in rna_scene.c -> can't be enabled! */ 00254 #define RE_BAKE_ALL 1 00255 #define RE_BAKE_AO 2 00256 #define RE_BAKE_NORMALS 3 00257 #define RE_BAKE_TEXTURE 4 00258 #define RE_BAKE_DISPLACEMENT 5 00259 #define RE_BAKE_SHADOW 6 00260 #define RE_BAKE_SPEC_COLOR 7 00261 #define RE_BAKE_SPEC_INTENSITY 8 00262 #define RE_BAKE_MIRROR_COLOR 9 00263 #define RE_BAKE_MIRROR_INTENSITY 10 00264 #define RE_BAKE_ALPHA 11 00265 #define RE_BAKE_EMIT 12 00266 00267 void RE_Database_Baking(struct Render *re, struct Main *bmain, struct Scene *scene, unsigned int lay, const int type, struct Object *actob); 00268 00269 void RE_DataBase_GetView(struct Render *re, float mat[][4]); 00270 void RE_GetCameraWindow(struct Render *re, struct Object *camera, int frame, float mat[][4]); 00271 struct Scene *RE_GetScene(struct Render *re); 00272 00273 int RE_is_rendering_allowed(struct Scene *scene, struct Object *camera_override, struct ReportList *reports); 00274 00275 #endif /* RE_PIPELINE_H */ 00276