Cycles: merge of changes from tomato branch.
[blender-staging.git] / source / blender / makesrna / intern / rna_render.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
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.
8  *
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.
13  *
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.
17  *
18  * Contributor(s): Blender Foundation (2009)
19  *
20  * ***** END GPL LICENSE BLOCK *****
21  */
22
23 /** \file blender/makesrna/intern/rna_render.c
24  *  \ingroup RNA
25  */
26
27 #include <stdlib.h>
28
29 #include "DNA_scene_types.h"
30
31 #include "BLI_path_util.h"
32
33 #include "RNA_define.h"
34 #include "RNA_enum_types.h"
35
36 #include "rna_internal.h"
37
38 #include "RE_engine.h"
39 #include "RE_pipeline.h"
40
41
42 #ifdef RNA_RUNTIME
43
44 #include "MEM_guardedalloc.h"
45
46 #include "RNA_access.h"
47
48 #include "BKE_context.h"
49 #include "BKE_report.h"
50
51 /* RenderEngine Callbacks */
52
53 void engine_tag_redraw(RenderEngine *engine)
54 {
55         engine->flag |= RE_ENGINE_DO_DRAW;
56 }
57
58 void engine_tag_update(RenderEngine *engine)
59 {
60         engine->flag |= RE_ENGINE_DO_UPDATE;
61 }
62
63 static void engine_update(RenderEngine *engine, Main *bmain, Scene *scene)
64 {
65         extern FunctionRNA rna_RenderEngine_update_func;
66         PointerRNA ptr;
67         ParameterList list;
68         FunctionRNA *func;
69
70         RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
71         func = &rna_RenderEngine_update_func;
72
73         RNA_parameter_list_create(&list, &ptr, func);
74         RNA_parameter_set_lookup(&list, "data", &bmain);
75         RNA_parameter_set_lookup(&list, "scene", &scene);
76         engine->type->ext.call(NULL, &ptr, func, &list);
77
78         RNA_parameter_list_free(&list);
79 }
80
81 static void engine_render(RenderEngine *engine, struct Scene *scene)
82 {
83         extern FunctionRNA rna_RenderEngine_render_func;
84         PointerRNA ptr;
85         ParameterList list;
86         FunctionRNA *func;
87
88         RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
89         func = &rna_RenderEngine_render_func;
90
91         RNA_parameter_list_create(&list, &ptr, func);
92         RNA_parameter_set_lookup(&list, "scene", &scene);
93         engine->type->ext.call(NULL, &ptr, func, &list);
94
95         RNA_parameter_list_free(&list);
96 }
97
98 static void engine_view_update(RenderEngine *engine, const struct bContext *context)
99 {
100         extern FunctionRNA rna_RenderEngine_view_update_func;
101         PointerRNA ptr;
102         ParameterList list;
103         FunctionRNA *func;
104
105         RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
106         func = &rna_RenderEngine_view_update_func;
107
108         RNA_parameter_list_create(&list, &ptr, func);
109         RNA_parameter_set_lookup(&list, "context", &context);
110         engine->type->ext.call(NULL, &ptr, func, &list);
111
112         RNA_parameter_list_free(&list);
113 }
114
115 static void engine_view_draw(RenderEngine *engine, const struct bContext *context)
116 {
117         extern FunctionRNA rna_RenderEngine_view_draw_func;
118         PointerRNA ptr;
119         ParameterList list;
120         FunctionRNA *func;
121
122         RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
123         func = &rna_RenderEngine_view_draw_func;
124
125         RNA_parameter_list_create(&list, &ptr, func);
126         RNA_parameter_set_lookup(&list, "context", &context);
127         engine->type->ext.call(NULL, &ptr, func, &list);
128
129         RNA_parameter_list_free(&list);
130 }
131
132 /* RenderEngine registration */
133
134 static void rna_RenderEngine_unregister(Main *UNUSED(bmain), StructRNA *type)
135 {
136         RenderEngineType *et = RNA_struct_blender_type_get(type);
137
138         if (!et)
139                 return;
140         
141         RNA_struct_free_extension(type, &et->ext);
142         BLI_freelinkN(&R_engines, et);
143         RNA_struct_free(&BLENDER_RNA, type);
144 }
145
146 static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
147                                             StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
148 {
149         RenderEngineType *et, dummyet = {NULL};
150         RenderEngine dummyengine = {NULL};
151         PointerRNA dummyptr;
152         int have_function[4];
153
154         /* setup dummy engine & engine type to store static properties in */
155         dummyengine.type = &dummyet;
156         RNA_pointer_create(NULL, &RNA_RenderEngine, &dummyengine, &dummyptr);
157
158         /* validate the python class */
159         if (validate(&dummyptr, data, have_function) != 0)
160                 return NULL;
161
162         if (strlen(identifier) >= sizeof(dummyet.idname)) {
163                 BKE_reportf(reports, RPT_ERROR, "registering render engine class: '%s' is too long, maximum length is %d",
164                             identifier, (int)sizeof(dummyet.idname));
165                 return NULL;
166         }
167
168         /* check if we have registered this engine type before, and remove it */
169         for (et = R_engines.first; et; et = et->next) {
170                 if (strcmp(et->idname, dummyet.idname) == 0) {
171                         if (et->ext.srna)
172                                 rna_RenderEngine_unregister(bmain, et->ext.srna);
173                         break;
174                 }
175         }
176         
177         /* create a new engine type */
178         et = MEM_callocN(sizeof(RenderEngineType), "python render engine");
179         memcpy(et, &dummyet, sizeof(dummyet));
180
181         et->ext.srna = RNA_def_struct(&BLENDER_RNA, et->idname, "RenderEngine");
182         et->ext.data = data;
183         et->ext.call = call;
184         et->ext.free = free;
185         RNA_struct_blender_type_set(et->ext.srna, et);
186
187         et->update = (have_function[0]) ? engine_update : NULL;
188         et->render = (have_function[1]) ? engine_render : NULL;
189         et->view_update = (have_function[2]) ? engine_view_update : NULL;
190         et->view_draw = (have_function[3]) ? engine_view_draw : NULL;
191
192         BLI_addtail(&R_engines, et);
193
194         return et->ext.srna;
195 }
196
197 static void **rna_RenderEngine_instance(PointerRNA *ptr)
198 {
199         RenderEngine *engine = ptr->data;
200         return &engine->py_instance;
201 }
202
203 static StructRNA *rna_RenderEngine_refine(PointerRNA *ptr)
204 {
205         RenderEngine *engine = (RenderEngine *)ptr->data;
206         return (engine->type && engine->type->ext.srna) ? engine->type->ext.srna : &RNA_RenderEngine;
207 }
208
209 static void rna_RenderResult_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
210 {
211         RenderResult *rr = (RenderResult *)ptr->data;
212         rna_iterator_listbase_begin(iter, &rr->layers, NULL);
213 }
214
215 static void rna_RenderLayer_passes_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
216 {
217         RenderLayer *rl = (RenderLayer *)ptr->data;
218         rna_iterator_listbase_begin(iter, &rl->passes, NULL);
219 }
220
221 static int rna_RenderLayer_rect_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
222 {
223         RenderLayer *rl = (RenderLayer *)ptr->data;
224
225         length[0] = rl->rectx * rl->recty;
226         length[1] = 4;
227
228         return length[0] * length[1];
229 }
230
231 static void rna_RenderLayer_rect_get(PointerRNA *ptr, float *values)
232 {
233         RenderLayer *rl = (RenderLayer *)ptr->data;
234         memcpy(values, rl->rectf, sizeof(float) * rl->rectx * rl->recty * 4);
235 }
236
237 void rna_RenderLayer_rect_set(PointerRNA *ptr, const float *values)
238 {
239         RenderLayer *rl = (RenderLayer *)ptr->data;
240         memcpy(rl->rectf, values, sizeof(float) * rl->rectx * rl->recty * 4);
241 }
242
243 static int rna_RenderPass_rect_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
244 {
245         RenderPass *rpass = (RenderPass *)ptr->data;
246
247         length[0] = rpass->rectx * rpass->recty;
248         length[1] = rpass->channels;
249
250         return length[0] * length[1];
251 }
252
253 static void rna_RenderPass_rect_get(PointerRNA *ptr, float *values)
254 {
255         RenderPass *rpass = (RenderPass *)ptr->data;
256         memcpy(values, rpass->rect, sizeof(float) * rpass->rectx * rpass->recty * rpass->channels);
257 }
258
259 void rna_RenderPass_rect_set(PointerRNA *ptr, const float *values)
260 {
261         RenderPass *rpass = (RenderPass *)ptr->data;
262         memcpy(rpass->rect, values, sizeof(float) * rpass->rectx * rpass->recty * rpass->channels);
263 }
264
265 #else /* RNA_RUNTIME */
266
267 static void rna_def_render_engine(BlenderRNA *brna)
268 {
269         StructRNA *srna;
270         PropertyRNA *prop;
271         FunctionRNA *func;
272         
273         srna = RNA_def_struct(brna, "RenderEngine", NULL);
274         RNA_def_struct_sdna(srna, "RenderEngine");
275         RNA_def_struct_ui_text(srna, "Render Engine", "Render engine");
276         RNA_def_struct_refine_func(srna, "rna_RenderEngine_refine");
277         RNA_def_struct_register_funcs(srna, "rna_RenderEngine_register", "rna_RenderEngine_unregister",
278                                       "rna_RenderEngine_instance");
279
280         /* final render callbacks */
281         func = RNA_def_function(srna, "update", NULL);
282         RNA_def_function_ui_description(func, "Export scene data for render");
283         RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
284         RNA_def_pointer(func, "data", "BlendData", "", "");
285         RNA_def_pointer(func, "scene", "Scene", "", "");
286
287         func = RNA_def_function(srna, "render", NULL);
288         RNA_def_function_ui_description(func, "Render scene into an image");
289         RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
290         RNA_def_pointer(func, "scene", "Scene", "", "");
291
292         /* viewport render callbacks */
293         func = RNA_def_function(srna, "view_update", NULL);
294         RNA_def_function_ui_description(func, "Update on data changes for viewport render");
295         RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
296         RNA_def_pointer(func, "context", "Context", "", "");
297
298         func = RNA_def_function(srna, "view_draw", NULL);
299         RNA_def_function_ui_description(func, "Draw viewport render");
300         RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
301         RNA_def_pointer(func, "context", "Context", "", "");
302
303         /* tag for redraw */
304         RNA_def_function(srna, "tag_redraw", "engine_tag_redraw");
305         RNA_def_function_ui_description(func, "Request redraw for viewport rendering");
306
307         /* tag for update */
308         RNA_def_function(srna, "tag_update", "engine_tag_update");
309         RNA_def_function_ui_description(func, "Request update call for viewport rendering");
310
311         func = RNA_def_function(srna, "begin_result", "RE_engine_begin_result");
312         prop = RNA_def_int(func, "x", 0, 0, INT_MAX, "X", "", 0, INT_MAX);
313         RNA_def_property_flag(prop, PROP_REQUIRED);
314         prop = RNA_def_int(func, "y", 0, 0, INT_MAX, "Y", "", 0, INT_MAX);
315         RNA_def_property_flag(prop, PROP_REQUIRED);
316         prop = RNA_def_int(func, "w", 0, 0, INT_MAX, "Width", "", 0, INT_MAX);
317         RNA_def_property_flag(prop, PROP_REQUIRED);
318         prop = RNA_def_int(func, "h", 0, 0, INT_MAX, "Height", "", 0, INT_MAX);
319         RNA_def_property_flag(prop, PROP_REQUIRED);
320         prop = RNA_def_string(func, "layer", "", 0, "Layer", "Single layer to get render result for");
321         prop = RNA_def_pointer(func, "result", "RenderResult", "Result", "");
322         RNA_def_function_return(func, prop);
323
324         func = RNA_def_function(srna, "update_result", "RE_engine_update_result");
325         prop = RNA_def_pointer(func, "result", "RenderResult", "Result", "");
326         RNA_def_property_flag(prop, PROP_REQUIRED);
327
328         func = RNA_def_function(srna, "end_result", "RE_engine_end_result");
329         prop = RNA_def_pointer(func, "result", "RenderResult", "Result", "");
330         prop = RNA_def_boolean(func, "cancel", 0, "Cancel", "Don't merge back results");
331         RNA_def_property_flag(prop, PROP_REQUIRED);
332
333         func = RNA_def_function(srna, "test_break", "RE_engine_test_break");
334         prop = RNA_def_boolean(func, "do_break", 0, "Break", "");
335         RNA_def_function_return(func, prop);
336
337         func = RNA_def_function(srna, "update_stats", "RE_engine_update_stats");
338         prop = RNA_def_string(func, "stats", "", 0, "Stats", "");
339         RNA_def_property_flag(prop, PROP_REQUIRED);
340         prop = RNA_def_string(func, "info", "", 0, "Info", "");
341         RNA_def_property_flag(prop, PROP_REQUIRED);
342
343         func = RNA_def_function(srna, "update_progress", "RE_engine_update_progress");
344         prop = RNA_def_float(func, "progress", 0, 0.0f, 1.0f, "", "Percentage of render that's done", 0.0f, 1.0f);
345         RNA_def_property_flag(prop, PROP_REQUIRED);
346
347         func = RNA_def_function(srna, "report", "RE_engine_report");
348         prop = RNA_def_enum_flag(func, "type", wm_report_items, 0, "Type", "");
349         RNA_def_property_flag(prop, PROP_REQUIRED);
350         prop = RNA_def_string(func, "message", "", 0, "Report Message", "");
351         RNA_def_property_flag(prop, PROP_REQUIRED);
352
353         RNA_define_verify_sdna(0);
354
355         prop = RNA_def_property(srna, "is_animation", PROP_BOOLEAN, PROP_NONE);
356         RNA_def_property_boolean_sdna(prop, NULL, "flag", RE_ENGINE_ANIMATION);
357
358         prop = RNA_def_property(srna, "is_preview", PROP_BOOLEAN, PROP_NONE);
359         RNA_def_property_boolean_sdna(prop, NULL, "flag", RE_ENGINE_PREVIEW);
360
361         prop = RNA_def_property(srna, "camera_override", PROP_POINTER, PROP_NONE);
362         RNA_def_property_pointer_sdna(prop, NULL, "camera_override");
363         RNA_def_property_struct_type(prop, "Object");
364
365         prop = RNA_def_property(srna, "tile_x", PROP_INT, PROP_UNSIGNED);
366         RNA_def_property_int_sdna(prop, NULL, "tile_x");
367         prop = RNA_def_property(srna, "tile_y", PROP_INT, PROP_UNSIGNED);
368         RNA_def_property_int_sdna(prop, NULL, "tile_y");
369
370         prop = RNA_def_property(srna, "resolution_x", PROP_INT, PROP_NONE);
371         RNA_def_property_int_sdna(prop, NULL, "resolution_x");
372         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
373
374         prop = RNA_def_property(srna, "resolution_y", PROP_INT, PROP_NONE);
375         RNA_def_property_int_sdna(prop, NULL, "resolution_y");
376         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
377
378         /* registration */
379
380         prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
381         RNA_def_property_string_sdna(prop, NULL, "type->idname");
382         RNA_def_property_flag(prop, PROP_REGISTER | PROP_NEVER_CLAMP);
383
384         prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_TRANSLATE);
385         RNA_def_property_string_sdna(prop, NULL, "type->name");
386         RNA_def_property_flag(prop, PROP_REGISTER);
387
388         prop = RNA_def_property(srna, "bl_use_preview", PROP_BOOLEAN, PROP_NONE);
389         RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_PREVIEW);
390         RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
391
392         prop = RNA_def_property(srna, "bl_use_postprocess", PROP_BOOLEAN, PROP_NONE);
393         RNA_def_property_boolean_negative_sdna(prop, NULL, "type->flag", RE_USE_POSTPROCESS);
394         RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
395
396         prop = RNA_def_property(srna, "bl_use_shading_nodes", PROP_BOOLEAN, PROP_NONE);
397         RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_SHADING_NODES);
398         RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
399
400         RNA_define_verify_sdna(1);
401 }
402
403 static void rna_def_render_result(BlenderRNA *brna)
404 {
405         StructRNA *srna;
406         FunctionRNA *func;
407         PropertyRNA *parm;
408         
409         srna = RNA_def_struct(brna, "RenderResult", NULL);
410         RNA_def_struct_ui_text(srna, "Render Result", "Result of rendering, including all layers and passes");
411
412         func = RNA_def_function(srna, "load_from_file", "RE_result_load_from_file");
413         RNA_def_function_ui_description(func, "Copies the pixels of this render result from an image file");
414         RNA_def_function_flag(func, FUNC_USE_REPORTS);
415         parm = RNA_def_string_file_name(func, "filename", "", FILE_MAX, "File Name",
416                                         "Filename to load into this render tile, must be no smaller than "
417                                         "the render result");
418         RNA_def_property_flag(parm, PROP_REQUIRED);
419
420         RNA_define_verify_sdna(0);
421
422         parm = RNA_def_property(srna, "resolution_x", PROP_INT, PROP_NONE);
423         RNA_def_property_int_sdna(parm, NULL, "rectx");
424         RNA_def_property_clear_flag(parm, PROP_EDITABLE);
425
426         parm = RNA_def_property(srna, "resolution_y", PROP_INT, PROP_NONE);
427         RNA_def_property_int_sdna(parm, NULL, "recty");
428         RNA_def_property_clear_flag(parm, PROP_EDITABLE);
429
430         parm = RNA_def_property(srna, "layers", PROP_COLLECTION, PROP_NONE);
431         RNA_def_property_struct_type(parm, "RenderLayer");
432         RNA_def_property_collection_funcs(parm, "rna_RenderResult_layers_begin", "rna_iterator_listbase_next",
433                                           "rna_iterator_listbase_end", "rna_iterator_listbase_get",
434                                           NULL, NULL, NULL, NULL);
435
436         RNA_define_verify_sdna(1);
437 }
438
439 static void rna_def_render_layer(BlenderRNA *brna)
440 {
441         StructRNA *srna;
442         PropertyRNA *prop;
443         FunctionRNA *func;
444         
445         srna = RNA_def_struct(brna, "RenderLayer", NULL);
446         RNA_def_struct_ui_text(srna, "Render Layer", "");
447
448         func = RNA_def_function(srna, "load_from_file", "RE_layer_load_from_file");
449         RNA_def_function_ui_description(func, "Copies the pixels of this renderlayer from an image file");
450         RNA_def_function_flag(func, FUNC_USE_REPORTS);
451         prop = RNA_def_string(func, "filename", "", 0, "Filename",
452                               "Filename to load into this render tile, must be no smaller than the renderlayer");
453         RNA_def_property_flag(prop, PROP_REQUIRED);
454         RNA_def_int(func, "x", 0, 0, INT_MAX, "Offset X",
455                     "Offset the position to copy from if the image is larger than the render layer", 0, INT_MAX);
456         RNA_def_int(func, "y", 0, 0, INT_MAX, "Offset Y",
457                     "Offset the position to copy from if the image is larger than the render layer", 0, INT_MAX);
458
459         RNA_define_verify_sdna(0);
460
461         rna_def_render_layer_common(srna, 0);
462
463         prop = RNA_def_property(srna, "passes", PROP_COLLECTION, PROP_NONE);
464         RNA_def_property_struct_type(prop, "RenderPass");
465         RNA_def_property_collection_funcs(prop, "rna_RenderLayer_passes_begin", "rna_iterator_listbase_next",
466                                           "rna_iterator_listbase_end", "rna_iterator_listbase_get",
467                                           NULL, NULL, NULL, NULL);
468
469         prop = RNA_def_property(srna, "rect", PROP_FLOAT, PROP_NONE);
470         RNA_def_property_flag(prop, PROP_DYNAMIC);
471         RNA_def_property_multi_array(prop, 2, NULL);
472         RNA_def_property_dynamic_array_funcs(prop, "rna_RenderLayer_rect_get_length");
473         RNA_def_property_float_funcs(prop, "rna_RenderLayer_rect_get", "rna_RenderLayer_rect_set", NULL);
474
475         RNA_define_verify_sdna(1);
476 }
477
478 static void rna_def_render_pass(BlenderRNA *brna)
479 {
480         StructRNA *srna;
481         PropertyRNA *prop;
482
483         static EnumPropertyItem pass_type_items[] = {
484                 {SCE_PASS_COMBINED, "COMBINED", 0, "Combined", ""},
485                 {SCE_PASS_Z, "Z", 0, "Z", ""},
486                 {SCE_PASS_RGBA, "COLOR", 0, "Color", ""},
487                 {SCE_PASS_DIFFUSE, "DIFFUSE", 0, "Diffuse", ""},
488                 {SCE_PASS_SPEC, "SPECULAR", 0, "Specular", ""},
489                 {SCE_PASS_SHADOW, "SHADOW", 0, "Shadow", ""},
490                 {SCE_PASS_AO, "AO", 0, "AO", ""},
491                 {SCE_PASS_REFLECT, "REFLECTION", 0, "Reflection", ""},
492                 {SCE_PASS_NORMAL, "NORMAL", 0, "Normal", ""},
493                 {SCE_PASS_VECTOR, "VECTOR", 0, "Vector", ""},
494                 {SCE_PASS_REFRACT, "REFRACTION", 0, "Refraction", ""},
495                 {SCE_PASS_INDEXOB, "OBJECT_INDEX", 0, "Object Index", ""},
496                 {SCE_PASS_UV, "UV", 0, "UV", ""},
497                 {SCE_PASS_MIST, "MIST", 0, "Mist", ""},
498                 {SCE_PASS_EMIT, "EMIT", 0, "Emit", ""},
499                 {SCE_PASS_ENVIRONMENT, "ENVIRONMENT", 0, "Environment", ""},
500                 {SCE_PASS_INDEXMA, "MATERIAL_INDEX", 0, "Material Index", ""},
501                 {SCE_PASS_DIFFUSE_DIRECT, "DIFFUSE_DIRECT", 0, "Diffuse Direct", ""},
502                 {SCE_PASS_DIFFUSE_INDIRECT, "DIFFUSE_INDIRECT", 0, "Diffuse Indirect", ""},
503                 {SCE_PASS_DIFFUSE_COLOR, "DIFFUSE_COLOR", 0, "Diffuse Color", ""},
504                 {SCE_PASS_GLOSSY_DIRECT, "GLOSSY_DIRECT", 0, "Glossy Direct", ""},
505                 {SCE_PASS_GLOSSY_INDIRECT, "GLOSSY_INDIRECT", 0, "Glossy Indirect", ""},
506                 {SCE_PASS_GLOSSY_COLOR, "GLOSSY_COLOR", 0, "Glossy Color", ""},
507                 {SCE_PASS_TRANSM_DIRECT, "TRANSMISSION_DIRECT", 0, "Transmission Direct", ""},
508                 {SCE_PASS_TRANSM_INDIRECT, "TRANSMISSION_INDIRECT", 0, "Transmission Indirect", ""},
509                 {SCE_PASS_TRANSM_COLOR, "TRANSMISSION_COLOR", 0, "Transmission Color", ""},
510                 {0, NULL, 0, NULL, NULL}
511         };
512         
513         srna = RNA_def_struct(brna, "RenderPass", NULL);
514         RNA_def_struct_ui_text(srna, "Render Pass", "");
515
516         RNA_define_verify_sdna(0);
517
518         prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
519         RNA_def_property_string_sdna(prop, NULL, "name");
520         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
521         RNA_def_struct_name_property(srna, prop);
522
523         prop = RNA_def_property(srna, "channel_id", PROP_STRING, PROP_NONE);
524         RNA_def_property_string_sdna(prop, NULL, "chan_id");
525         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
526
527         prop = RNA_def_property(srna, "channels", PROP_INT, PROP_NONE);
528         RNA_def_property_int_sdna(prop, NULL, "channels");
529         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
530
531         prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
532         RNA_def_property_enum_sdna(prop, NULL, "passtype");
533         RNA_def_property_enum_items(prop, pass_type_items);
534         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
535
536         prop = RNA_def_property(srna, "rect", PROP_FLOAT, PROP_NONE);
537         RNA_def_property_flag(prop, PROP_DYNAMIC);
538         RNA_def_property_multi_array(prop, 2, NULL);
539         RNA_def_property_dynamic_array_funcs(prop, "rna_RenderPass_rect_get_length");
540         RNA_def_property_float_funcs(prop, "rna_RenderPass_rect_get", "rna_RenderPass_rect_set", NULL);
541
542         RNA_define_verify_sdna(1);
543 }
544
545 void RNA_def_render(BlenderRNA *brna)
546 {
547         rna_def_render_engine(brna);
548         rna_def_render_result(brna);
549         rna_def_render_layer(brna);
550         rna_def_render_pass(brna);
551 }
552
553 #endif /* RNA_RUNTIME */