2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2006 Blender Foundation.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): none yet.
25 * ***** END GPL LICENSE BLOCK *****
28 /** \file RE_pipeline.h
32 #ifndef __RE_PIPELINE_H__
33 #define __RE_PIPELINE_H__
35 #include "DNA_listBase.h"
36 #include "DNA_vec_types.h"
47 struct SceneRenderLayer;
50 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
51 /* this include is what is exposed of render to outside world */
52 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
54 /* length of the scene name + passname */
55 #define RE_MAXNAME ((MAX_ID_NAME - 2) + 10)
57 /* only used as handle */
58 typedef struct Render Render;
60 /* Render Result usage:
62 * - render engine allocates/frees and delivers raw floating point rects
63 * - right now it's full rects, but might become tiles or file
64 * - the display client has to allocate display rects, sort out what to display,
65 * and how it's converted
68 typedef struct RenderPass {
69 struct RenderPass *next, *prev;
70 int passtype, channels;
71 char name[16]; /* amount defined in openexr_multi.h */
72 char chan_id[8]; /* amount defined in openexr_multi.h */
77 /* a renderlayer is a full image, but with all passes and samples */
78 /* size of the rects is defined in RenderResult */
79 /* after render, the Combined pass is in rectf, for renderlayers read from files it is a real pass */
80 typedef struct RenderLayer {
81 struct RenderLayer *next, *prev;
83 /* copy of RenderData */
84 char name[RE_MAXNAME];
85 unsigned int lay, lay_zmask, lay_exclude;
86 int layflag, passflag, pass_xor;
88 struct Material *mat_override;
89 struct Group *light_override;
91 float *rectf; /* 4 float, standard rgba buffer (read not above!) */
92 float *acolrect; /* 4 float, optional transparent buffer, needs storage for display updates */
93 float *scolrect; /* 4 float, optional strand buffer, needs storage for display updates */
96 /* optional saved endresult on disk */
103 typedef struct RenderResult {
104 struct RenderResult *next, *prev;
106 /* target image size */
108 short crop, sample_nr;
110 /* optional, 32 bits version of picture, used for ogl render and image curves */
112 /* if this exists, a copy of one of layers, or result of composited layers */
114 /* if this exists, a copy of one of layers, or result of composited layers */
117 /* coordinates within final image (after cropping) */
119 /* offset to apply to get a border render in full image */
122 /* the main buffers */
125 /* allowing live updates: */
126 volatile rcti renrect;
127 volatile RenderLayer *renlay;
129 /* optional saved endresult on disk */
132 /* for render results in Image, verify validity for sequences */
135 /* for acquire image, to indicate if it there is a combined layer */
138 /* render info text */
144 typedef struct RenderStats {
146 int totface, totvert, totstrand, tothalo, totlamp, totpart;
147 short curfield, curblur, curpart, partsdone, convertdone, curfsa;
148 double starttime, lastframetime;
149 const char *infostr, *statstr;
150 char scene_name[MAX_ID_NAME - 2];
153 /* *********************** API ******************** */
155 /* the name is used as identifier, so elsewhere in blender the result can retrieved */
156 /* calling a new render with same name, frees automatic existing render */
157 struct Render *RE_NewRender (const char *name);
158 struct Render *RE_GetRender(const char *name);
160 /* returns 1 while render is working (or renders called from within render) */
161 int RE_RenderInProgress(struct Render *re);
163 /* assign default dummy callbacks */
164 void RE_InitRenderCB(struct Render *re);
166 /* use free render as signal to do everything over (previews) */
167 void RE_FreeRender (struct Render *re);
168 /* only called on exit */
169 void RE_FreeAllRender (void);
170 /* only call on file load */
171 void RE_FreeAllRenderResults(void);
173 /* get results and statistics */
174 void RE_FreeRenderResult(struct RenderResult *rr);
175 struct RenderResult *RE_AcquireResultRead(struct Render *re);
176 struct RenderResult *RE_AcquireResultWrite(struct Render *re);
177 void RE_ReleaseResult(struct Render *re);
178 void RE_AcquireResultImage(struct Render *re, struct RenderResult *rr);
179 void RE_ReleaseResultImage(struct Render *re);
180 void RE_SwapResult(struct Render *re, struct RenderResult **rr);
181 struct RenderStats *RE_GetStats(struct Render *re);
182 void RE_ResultGet32(struct Render *re, unsigned int *rect);
183 struct RenderLayer *RE_GetRenderLayer(struct RenderResult *rr, const char *name);
184 float *RE_RenderLayerGetPass(struct RenderLayer *rl, int passtype);
186 /* obligatory initialize call, disprect is optional */
187 void RE_InitState (struct Render *re, struct Render *source, struct RenderData *rd, struct SceneRenderLayer *srl, int winx, int winy, rcti *disprect);
189 /* set up the viewplane/perspective matrix, three choices */
190 struct Object *RE_GetCamera(struct Render *re); /* return camera override if set */
191 void RE_SetCamera(struct Render *re, struct Object *camera);
192 void RE_SetEnvmapCamera(struct Render *re, struct Object *cam_ob, float viewscale, float clipsta, float clipend);
193 void RE_SetWindow (struct Render *re, rctf *viewplane, float clipsta, float clipend);
194 void RE_SetOrtho (struct Render *re, rctf *viewplane, float clipsta, float clipend);
195 void RE_SetPixelSize(struct Render *re, float pixsize);
197 /* option to set viewmatrix before making dbase */
198 void RE_SetView (struct Render *re, float mat[][4]);
200 /* make or free the dbase */
201 void RE_Database_FromScene(struct Render *re, struct Main *bmain, struct Scene *scene, unsigned int lay, int use_camera_view);
202 void RE_Database_Free (struct Render *re);
204 /* project dbase again, when viewplane/perspective changed */
205 void RE_DataBase_ApplyWindow(struct Render *re);
207 /* override the scene setting for amount threads, commandline */
208 void RE_set_max_threads(int threads);
210 /* set the render threads based on the commandline and autothreads setting */
211 void RE_init_threadcount(Render *re);
213 /* the main processor, assumes all was set OK! */
214 void RE_TileProcessor(struct Render *re);
216 /* only RE_NewRender() needed, main Blender render calls */
217 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);
218 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);
220 /* error reporting */
221 void RE_SetReports(struct Render *re, struct ReportList *reports);
223 /* main preview render call */
224 void RE_PreviewRender(struct Render *re, struct Main *bmain, struct Scene *scene);
226 int RE_ReadRenderResult(struct Scene *scene, struct Scene *scenode);
227 int RE_WriteRenderResult(struct ReportList *reports, RenderResult *rr, const char *filename, int compress);
228 struct RenderResult *RE_MultilayerConvert(void *exrhandle, const char *colorspace, int predivide, int rectx, int recty);
230 extern const float default_envmap_layout[];
231 int RE_WriteEnvmapResult(struct ReportList *reports, struct Scene *scene, struct EnvMap *env, const char *relpath, const char imtype, float layout[12]);
233 /* do a full sample buffer compo */
234 void RE_MergeFullSample(struct Render *re, struct Main *bmain, struct Scene *sce, struct bNodeTree *ntree);
236 /* ancient stars function... go away! */
237 void RE_make_stars(struct Render *re, struct Scene *scenev3d, void (*initfunc)(void),
238 void (*vertexfunc)(float*), void (*termfunc)(void));
240 /* display and event callbacks */
241 void RE_display_init_cb (struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr));
242 void RE_display_clear_cb(struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr));
243 void RE_display_draw_cb (struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr, volatile struct rcti *rect));
244 void RE_stats_draw_cb (struct Render *re, void *handle, void (*f)(void *handle, RenderStats *rs));
245 void RE_progress_cb (struct Render *re, void *handle, void (*f)(void *handle, float));
246 void RE_draw_lock_cb (struct Render *re, void *handle, void (*f)(void *handle, int));
247 void RE_test_break_cb (struct Render *re, void *handle, int (*f)(void *handle));
249 /* should move to kernel once... still unsure on how/where */
250 float RE_filter_value(int type, float x);
251 /* vector blur zbuffer method */
252 void RE_zbuf_accumulate_vecblur(struct NodeBlurData *nbd, int xsize, int ysize, float *newrect, float *imgrect, float *vecbufrect, float *zbufrect);
254 int RE_seq_render_active(struct Scene *scene, struct RenderData *rd);
256 /* shaded view or baking options */
257 #define RE_BAKE_LIGHT 0 /* not listed in rna_scene.c -> can't be enabled! */
258 #define RE_BAKE_ALL 1
260 #define RE_BAKE_NORMALS 3
261 #define RE_BAKE_TEXTURE 4
262 #define RE_BAKE_DISPLACEMENT 5
263 #define RE_BAKE_SHADOW 6
264 #define RE_BAKE_SPEC_COLOR 7
265 #define RE_BAKE_SPEC_INTENSITY 8
266 #define RE_BAKE_MIRROR_COLOR 9
267 #define RE_BAKE_MIRROR_INTENSITY 10
268 #define RE_BAKE_ALPHA 11
269 #define RE_BAKE_EMIT 12
271 void RE_Database_Baking(struct Render *re, struct Main *bmain, struct Scene *scene, unsigned int lay, const int type, struct Object *actob);
273 void RE_DataBase_GetView(struct Render *re, float mat[][4]);
274 void RE_GetCameraWindow(struct Render *re, struct Object *camera, int frame, float mat[][4]);
275 struct Scene *RE_GetScene(struct Render *re);
277 int RE_is_rendering_allowed(struct Scene *scene, struct Object *camera_override, struct ReportList *reports);
279 #endif /* __RE_PIPELINE_H__ */