2011-10-22 16:24:28 +00:00
|
|
|
/*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2006 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file RE_engine.h
|
|
|
|
* \ingroup render
|
|
|
|
*/
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __RE_ENGINE_H__
|
|
|
|
#define __RE_ENGINE_H__
|
2011-10-22 16:24:28 +00:00
|
|
|
|
|
|
|
#include "DNA_listBase.h"
|
2013-03-14 07:38:37 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2011-10-22 16:24:28 +00:00
|
|
|
#include "RNA_types.h"
|
Bake API - bpy.ops.object.bake()
New operator that can calls a bake function to the current render engine when available. This commit provides no feature for the users, but allows external engines to be accessed by the operator and be integrated with the baking api.
The API itself is simple. Blender sends a populated array of BakePixels to the renderer, and gets back an array of floats with the result.
The Blender Internal (and multires) system is still running independent, but we eventually will pipe it through the API as well. Cycles baking will come next as a separated commit
Python Operator:
----------------
The operator can be called with some arguments, or a user interface can be created for it. In that case the arguments can be ommited and the interface can expose the settings from bpy.context.scene.render.bake
bpy.ops.object.bake(type='COMBINED', filepath="", width=512, height=512, margin=16, use_selected_to_active=False, cage_extrusion=0, cage="", normal_space='TANGENT', normal_r='POS_X', normal_g='POS_Y', normal_b='POS_Z', save_mode='INTERNAL', use_clear=False, use_split_materials=False, use_automatic_name=False)
Note: external save mode is currently disabled.
Supported Features:
------------------
* Margin - Baked result is extended this many pixels beyond the border of each UV "island," to soften seams in the texture.
* Selected to Active - bake shading on the surface of selected object to the active object. The rays are cast from the lowpoly object inwards towards the highpoly object. If the highpoly object is not entirely involved by the lowpoly object, you can tweak the rays start point with Cage Extrusion. For even more control of the cage you can use a Cage object.
* Cage Extrusion - distance to use for the inward ray cast when using selected to active
* Custom Cage - object to use as cage (instead of the lowpoly object).
* Normal swizzle - change the axis that gets mapped to RGB
* Normal space - save as tangent or object normal spaces
Supported Passes:
-----------------
Any pass that is supported by Blender renderlayer system. Though it's up to the external engine to provide a valid enum with its supported passes. Normal passes get a special treatment since we post-process them to converted and "swizzled"
Development Notes for External Engines:
---------------------------------------
(read them in bake_api.c)
* For a complete implementation example look at the Cycles Bake commit (next).
Review: D421
Reviewed by: Campbell Barton, Brecht van Lommel, Sergey Sharybin, Thomas Dinge
Normal map pipeline "consulting" by Andy Davies (metalliandy)
Original design by Brecht van Lommel.
The entire commit history can be found on the branch: bake-cycles
2014-01-02 19:05:07 -02:00
|
|
|
#include "RE_bake.h"
|
2011-10-22 16:24:28 +00:00
|
|
|
|
2012-11-03 14:32:26 +00:00
|
|
|
struct bNode;
|
|
|
|
struct bNodeTree;
|
2011-10-22 16:24:28 +00:00
|
|
|
struct Object;
|
|
|
|
struct Render;
|
2013-03-14 07:38:37 +00:00
|
|
|
struct RenderData;
|
2011-10-22 16:24:28 +00:00
|
|
|
struct RenderEngine;
|
|
|
|
struct RenderEngineType;
|
|
|
|
struct RenderLayer;
|
|
|
|
struct RenderResult;
|
|
|
|
struct ReportList;
|
|
|
|
struct Scene;
|
Bake API - bpy.ops.object.bake()
New operator that can calls a bake function to the current render engine when available. This commit provides no feature for the users, but allows external engines to be accessed by the operator and be integrated with the baking api.
The API itself is simple. Blender sends a populated array of BakePixels to the renderer, and gets back an array of floats with the result.
The Blender Internal (and multires) system is still running independent, but we eventually will pipe it through the API as well. Cycles baking will come next as a separated commit
Python Operator:
----------------
The operator can be called with some arguments, or a user interface can be created for it. In that case the arguments can be ommited and the interface can expose the settings from bpy.context.scene.render.bake
bpy.ops.object.bake(type='COMBINED', filepath="", width=512, height=512, margin=16, use_selected_to_active=False, cage_extrusion=0, cage="", normal_space='TANGENT', normal_r='POS_X', normal_g='POS_Y', normal_b='POS_Z', save_mode='INTERNAL', use_clear=False, use_split_materials=False, use_automatic_name=False)
Note: external save mode is currently disabled.
Supported Features:
------------------
* Margin - Baked result is extended this many pixels beyond the border of each UV "island," to soften seams in the texture.
* Selected to Active - bake shading on the surface of selected object to the active object. The rays are cast from the lowpoly object inwards towards the highpoly object. If the highpoly object is not entirely involved by the lowpoly object, you can tweak the rays start point with Cage Extrusion. For even more control of the cage you can use a Cage object.
* Cage Extrusion - distance to use for the inward ray cast when using selected to active
* Custom Cage - object to use as cage (instead of the lowpoly object).
* Normal swizzle - change the axis that gets mapped to RGB
* Normal space - save as tangent or object normal spaces
Supported Passes:
-----------------
Any pass that is supported by Blender renderlayer system. Though it's up to the external engine to provide a valid enum with its supported passes. Normal passes get a special treatment since we post-process them to converted and "swizzled"
Development Notes for External Engines:
---------------------------------------
(read them in bake_api.c)
* For a complete implementation example look at the Cycles Bake commit (next).
Review: D421
Reviewed by: Campbell Barton, Brecht van Lommel, Sergey Sharybin, Thomas Dinge
Normal map pipeline "consulting" by Andy Davies (metalliandy)
Original design by Brecht van Lommel.
The entire commit history can be found on the branch: bake-cycles
2014-01-02 19:05:07 -02:00
|
|
|
struct BakePixel;
|
2011-10-22 16:24:28 +00:00
|
|
|
|
|
|
|
/* External Engine */
|
|
|
|
|
2011-11-02 13:36:28 +00:00
|
|
|
/* RenderEngineType.flag */
|
2011-10-22 17:01:54 +00:00
|
|
|
#define RE_INTERNAL 1
|
|
|
|
#define RE_GAME 2
|
|
|
|
#define RE_USE_PREVIEW 4
|
|
|
|
#define RE_USE_POSTPROCESS 8
|
2011-11-02 19:24:30 +00:00
|
|
|
#define RE_USE_SHADING_NODES 16
|
2013-06-10 13:53:38 +00:00
|
|
|
#define RE_USE_EXCLUDE_LAYERS 32
|
2013-07-11 12:22:29 +00:00
|
|
|
#define RE_USE_SAVE_BUFFERS 64
|
2011-10-22 16:24:28 +00:00
|
|
|
|
2011-11-02 13:36:28 +00:00
|
|
|
/* RenderEngine.flag */
|
|
|
|
#define RE_ENGINE_ANIMATION 1
|
|
|
|
#define RE_ENGINE_PREVIEW 2
|
2011-11-02 14:33:14 +00:00
|
|
|
#define RE_ENGINE_DO_DRAW 4
|
|
|
|
#define RE_ENGINE_DO_UPDATE 8
|
2012-11-13 11:00:46 +00:00
|
|
|
#define RE_ENGINE_RENDERING 16
|
2013-01-01 16:15:13 +00:00
|
|
|
#define RE_ENGINE_HIGHLIGHT_TILES 32
|
2013-01-24 08:14:20 +00:00
|
|
|
#define RE_ENGINE_USED_FOR_VIEWPORT 64
|
2011-11-02 13:36:28 +00:00
|
|
|
|
Blender Internal Render in viewport
Because of our release soon, feature has been added behind the Debug Menu.
CTRL+ALT+D and set it to -1. Or commandline --debug-value -1.
When debug set to -1, you can put the viewport to 'render' mode, just like
for Cycles. Notes for testers: (and please no bugs in tracker for this :)
- It renders without AA, MBlur, Panorama, Sequence, Composite
- Only active render layer gets rendered. Select another layer will re-render.
- But yes: it works for FreeStyle renders!
- Also does great for local view.
- BI is not well suited for incremental renders on view changes. This only
works for non-raytrace scenes, or zoom in ortho or camera mode, or for
Material changes. In most cases a full re-render is being done.
- ESC works to stop the preview render.
- Borders render as well. (CTRL+B)
- Force a refresh with arrow key left/right. A lot of settings don't trigger
re-render yet.
Tech notes:
- FreeStyle is adding a lot of temp objects/meshes in the Main database. This
caused DepsGraph to trigger changes (and redraws). I've prepended the names
for these temp objects with char number 27 (ESC), and made these names be
ignored for tag update checking.
- Fixed some bugs that were noticable with such excessive re-renders, like
for opening file window, quit during renders.
2013-04-16 17:39:20 +00:00
|
|
|
/* RenderEngine.update_flag, used by internal now */
|
|
|
|
#define RE_ENGINE_UPDATE_MA 1
|
|
|
|
#define RE_ENGINE_UPDATE_OTHER 2
|
2013-07-08 22:26:10 +00:00
|
|
|
#define RE_ENGINE_UPDATE_DATABASE 4
|
Blender Internal Render in viewport
Because of our release soon, feature has been added behind the Debug Menu.
CTRL+ALT+D and set it to -1. Or commandline --debug-value -1.
When debug set to -1, you can put the viewport to 'render' mode, just like
for Cycles. Notes for testers: (and please no bugs in tracker for this :)
- It renders without AA, MBlur, Panorama, Sequence, Composite
- Only active render layer gets rendered. Select another layer will re-render.
- But yes: it works for FreeStyle renders!
- Also does great for local view.
- BI is not well suited for incremental renders on view changes. This only
works for non-raytrace scenes, or zoom in ortho or camera mode, or for
Material changes. In most cases a full re-render is being done.
- ESC works to stop the preview render.
- Borders render as well. (CTRL+B)
- Force a refresh with arrow key left/right. A lot of settings don't trigger
re-render yet.
Tech notes:
- FreeStyle is adding a lot of temp objects/meshes in the Main database. This
caused DepsGraph to trigger changes (and redraws). I've prepended the names
for these temp objects with char number 27 (ESC), and made these names be
ignored for tag update checking.
- Fixed some bugs that were noticable with such excessive re-renders, like
for opening file window, quit during renders.
2013-04-16 17:39:20 +00:00
|
|
|
|
2011-10-22 16:24:28 +00:00
|
|
|
extern ListBase R_engines;
|
|
|
|
|
|
|
|
typedef struct RenderEngineType {
|
|
|
|
struct RenderEngineType *next, *prev;
|
|
|
|
|
|
|
|
/* type info */
|
|
|
|
char idname[64]; // best keep the same size as BKE_ST_MAXNAME
|
|
|
|
char name[64];
|
|
|
|
int flag;
|
|
|
|
|
2011-11-02 14:33:14 +00:00
|
|
|
void (*update)(struct RenderEngine *engine, struct Main *bmain, struct Scene *scene);
|
2011-10-22 16:24:28 +00:00
|
|
|
void (*render)(struct RenderEngine *engine, struct Scene *scene);
|
Bake API - bpy.ops.object.bake()
New operator that can calls a bake function to the current render engine when available. This commit provides no feature for the users, but allows external engines to be accessed by the operator and be integrated with the baking api.
The API itself is simple. Blender sends a populated array of BakePixels to the renderer, and gets back an array of floats with the result.
The Blender Internal (and multires) system is still running independent, but we eventually will pipe it through the API as well. Cycles baking will come next as a separated commit
Python Operator:
----------------
The operator can be called with some arguments, or a user interface can be created for it. In that case the arguments can be ommited and the interface can expose the settings from bpy.context.scene.render.bake
bpy.ops.object.bake(type='COMBINED', filepath="", width=512, height=512, margin=16, use_selected_to_active=False, cage_extrusion=0, cage="", normal_space='TANGENT', normal_r='POS_X', normal_g='POS_Y', normal_b='POS_Z', save_mode='INTERNAL', use_clear=False, use_split_materials=False, use_automatic_name=False)
Note: external save mode is currently disabled.
Supported Features:
------------------
* Margin - Baked result is extended this many pixels beyond the border of each UV "island," to soften seams in the texture.
* Selected to Active - bake shading on the surface of selected object to the active object. The rays are cast from the lowpoly object inwards towards the highpoly object. If the highpoly object is not entirely involved by the lowpoly object, you can tweak the rays start point with Cage Extrusion. For even more control of the cage you can use a Cage object.
* Cage Extrusion - distance to use for the inward ray cast when using selected to active
* Custom Cage - object to use as cage (instead of the lowpoly object).
* Normal swizzle - change the axis that gets mapped to RGB
* Normal space - save as tangent or object normal spaces
Supported Passes:
-----------------
Any pass that is supported by Blender renderlayer system. Though it's up to the external engine to provide a valid enum with its supported passes. Normal passes get a special treatment since we post-process them to converted and "swizzled"
Development Notes for External Engines:
---------------------------------------
(read them in bake_api.c)
* For a complete implementation example look at the Cycles Bake commit (next).
Review: D421
Reviewed by: Campbell Barton, Brecht van Lommel, Sergey Sharybin, Thomas Dinge
Normal map pipeline "consulting" by Andy Davies (metalliandy)
Original design by Brecht van Lommel.
The entire commit history can be found on the branch: bake-cycles
2014-01-02 19:05:07 -02:00
|
|
|
void (*bake)(struct RenderEngine *engine, struct Scene *scene, struct Object *object, const int pass_type, const struct BakePixel *pixel_array, const int num_pixels, const int depth, void *result);
|
2011-10-22 16:24:28 +00:00
|
|
|
|
2011-11-02 18:20:53 +00:00
|
|
|
void (*view_update)(struct RenderEngine *engine, const struct bContext *context);
|
|
|
|
void (*view_draw)(struct RenderEngine *engine, const struct bContext *context);
|
|
|
|
|
2012-11-03 14:32:26 +00:00
|
|
|
void (*update_script_node)(struct RenderEngine *engine, struct bNodeTree *ntree, struct bNode *node);
|
|
|
|
|
2011-10-22 16:24:28 +00:00
|
|
|
/* RNA integration */
|
|
|
|
ExtensionRNA ext;
|
|
|
|
} RenderEngineType;
|
|
|
|
|
|
|
|
typedef struct RenderEngine {
|
|
|
|
RenderEngineType *type;
|
2011-11-02 14:33:14 +00:00
|
|
|
void *py_instance;
|
2011-10-22 17:01:54 +00:00
|
|
|
|
2013-07-08 22:26:10 +00:00
|
|
|
int flag;
|
2012-04-13 17:42:03 +00:00
|
|
|
struct Object *camera_override;
|
2011-11-02 13:36:28 +00:00
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
int tile_x;
|
|
|
|
int tile_y;
|
|
|
|
|
2011-10-22 16:24:28 +00:00
|
|
|
struct Render *re;
|
|
|
|
ListBase fullresult;
|
2013-07-12 20:31:30 +00:00
|
|
|
char text[512]; /* IMA_MAX_RENDER_TEXT */
|
2012-09-04 13:29:07 +00:00
|
|
|
|
|
|
|
int resolution_x, resolution_y;
|
2012-11-03 14:32:26 +00:00
|
|
|
|
|
|
|
struct ReportList *reports;
|
2013-07-08 22:26:10 +00:00
|
|
|
|
|
|
|
/* for blender internal only */
|
|
|
|
int update_flag;
|
|
|
|
int job_update_flag;
|
|
|
|
|
|
|
|
rctf last_viewplane;
|
|
|
|
rcti last_disprect;
|
|
|
|
float last_viewmat[4][4];
|
|
|
|
int last_winx, last_winy;
|
2011-10-22 16:24:28 +00:00
|
|
|
} RenderEngine;
|
|
|
|
|
2011-10-22 17:01:54 +00:00
|
|
|
RenderEngine *RE_engine_create(RenderEngineType *type);
|
2013-03-20 23:14:18 +00:00
|
|
|
RenderEngine *RE_engine_create_ex(RenderEngineType *type, bool use_for_viewport);
|
2011-10-22 17:01:54 +00:00
|
|
|
void RE_engine_free(RenderEngine *engine);
|
|
|
|
|
2011-10-22 16:24:28 +00:00
|
|
|
void RE_layer_load_from_file(struct RenderLayer *layer, struct ReportList *reports, const char *filename, int x, int y);
|
|
|
|
void RE_result_load_from_file(struct RenderResult *result, struct ReportList *reports, const char *filename);
|
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
struct RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, int h, const char *layername);
|
2011-10-22 16:24:28 +00:00
|
|
|
void RE_engine_update_result(RenderEngine *engine, struct RenderResult *result);
|
2013-12-17 23:42:38 +06:00
|
|
|
void RE_engine_end_result(RenderEngine *engine, struct RenderResult *result, int cancel, int merge_results);
|
2011-10-22 16:24:28 +00:00
|
|
|
|
|
|
|
int RE_engine_test_break(RenderEngine *engine);
|
|
|
|
void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info);
|
2011-10-22 17:01:54 +00:00
|
|
|
void RE_engine_update_progress(RenderEngine *engine, float progress);
|
2012-11-05 08:04:57 +00:00
|
|
|
void RE_engine_update_memory_stats(RenderEngine *engine, float mem_used, float mem_peak);
|
2011-10-22 16:24:28 +00:00
|
|
|
void RE_engine_report(RenderEngine *engine, int type, const char *msg);
|
|
|
|
|
|
|
|
int RE_engine_render(struct Render *re, int do_all);
|
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
bool RE_engine_is_external(struct Render *re);
|
2011-11-26 18:33:31 +00:00
|
|
|
|
2014-05-21 15:47:11 +02:00
|
|
|
void RE_engine_frame_set(struct RenderEngine *engine, int frame, float subframe);
|
|
|
|
|
2011-10-22 16:24:28 +00:00
|
|
|
/* Engine Types */
|
|
|
|
|
|
|
|
void RE_engines_init(void);
|
|
|
|
void RE_engines_exit(void);
|
|
|
|
|
2011-10-22 17:01:54 +00:00
|
|
|
RenderEngineType *RE_engines_find(const char *idname);
|
|
|
|
|
2013-01-01 16:15:13 +00:00
|
|
|
void RE_engine_get_current_tiles(struct Render *re, int *total_tiles_r, rcti **tiles_r);
|
2013-03-14 07:38:37 +00:00
|
|
|
struct RenderData *RE_engine_get_render_data(struct Render *re);
|
Bake API - bpy.ops.object.bake()
New operator that can calls a bake function to the current render engine when available. This commit provides no feature for the users, but allows external engines to be accessed by the operator and be integrated with the baking api.
The API itself is simple. Blender sends a populated array of BakePixels to the renderer, and gets back an array of floats with the result.
The Blender Internal (and multires) system is still running independent, but we eventually will pipe it through the API as well. Cycles baking will come next as a separated commit
Python Operator:
----------------
The operator can be called with some arguments, or a user interface can be created for it. In that case the arguments can be ommited and the interface can expose the settings from bpy.context.scene.render.bake
bpy.ops.object.bake(type='COMBINED', filepath="", width=512, height=512, margin=16, use_selected_to_active=False, cage_extrusion=0, cage="", normal_space='TANGENT', normal_r='POS_X', normal_g='POS_Y', normal_b='POS_Z', save_mode='INTERNAL', use_clear=False, use_split_materials=False, use_automatic_name=False)
Note: external save mode is currently disabled.
Supported Features:
------------------
* Margin - Baked result is extended this many pixels beyond the border of each UV "island," to soften seams in the texture.
* Selected to Active - bake shading on the surface of selected object to the active object. The rays are cast from the lowpoly object inwards towards the highpoly object. If the highpoly object is not entirely involved by the lowpoly object, you can tweak the rays start point with Cage Extrusion. For even more control of the cage you can use a Cage object.
* Cage Extrusion - distance to use for the inward ray cast when using selected to active
* Custom Cage - object to use as cage (instead of the lowpoly object).
* Normal swizzle - change the axis that gets mapped to RGB
* Normal space - save as tangent or object normal spaces
Supported Passes:
-----------------
Any pass that is supported by Blender renderlayer system. Though it's up to the external engine to provide a valid enum with its supported passes. Normal passes get a special treatment since we post-process them to converted and "swizzled"
Development Notes for External Engines:
---------------------------------------
(read them in bake_api.c)
* For a complete implementation example look at the Cycles Bake commit (next).
Review: D421
Reviewed by: Campbell Barton, Brecht van Lommel, Sergey Sharybin, Thomas Dinge
Normal map pipeline "consulting" by Andy Davies (metalliandy)
Original design by Brecht van Lommel.
The entire commit history can be found on the branch: bake-cycles
2014-01-02 19:05:07 -02:00
|
|
|
void RE_bake_engine_set_engine_parameters(struct Render *re, struct Main *bmain, struct Scene *scene);
|
2013-01-01 16:15:13 +00:00
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#endif /* __RE_ENGINE_H__ */
|
2011-10-22 16:24:28 +00:00
|
|
|
|