2012-12-18 00:51:25 +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.
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** \file blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
|
|
|
|
|
* \ingroup freestyle
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "BlenderStrokeRenderer.h"
|
|
|
|
|
#include "BlenderTextureManager.h"
|
|
|
|
|
|
|
|
|
|
#include "../application/AppConfig.h"
|
|
|
|
|
#include "../stroke/Canvas.h"
|
|
|
|
|
|
2013-01-03 23:27:20 +00:00
|
|
|
#include "BKE_global.h"
|
|
|
|
|
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
extern "C" {
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_camera_types.h"
|
|
|
|
|
#include "DNA_customdata_types.h"
|
|
|
|
|
#include "DNA_listBase.h"
|
|
|
|
|
#include "DNA_meshdata_types.h"
|
2012-12-18 00:51:25 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
2010-03-28 18:12:45 +00:00
|
|
|
#include "DNA_object_types.h"
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
|
|
|
|
|
#include "BKE_customdata.h"
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_library.h" /* free_libblock */
|
|
|
|
|
#include "BKE_main.h" /* struct Main */
|
2012-12-18 00:51:25 +00:00
|
|
|
#include "BKE_material.h"
|
2012-06-16 21:49:52 +00:00
|
|
|
#include "BKE_mesh.h"
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
#include "BKE_object.h"
|
|
|
|
|
#include "BKE_scene.h"
|
|
|
|
|
|
|
|
|
|
#include "RE_pipeline.h"
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
namespace Freestyle {
|
|
|
|
|
|
2013-03-07 23:17:23 +00:00
|
|
|
BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : StrokeRenderer()
|
2012-12-18 00:51:25 +00:00
|
|
|
{
|
2013-04-23 22:40:13 +00:00
|
|
|
freestyle_bmain = &re->freestyle_bmain;
|
2013-04-18 08:58:21 +00:00
|
|
|
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
// TEMPORARY - need a texture manager
|
2009-10-18 05:19:46 +00:00
|
|
|
_textureManager = new BlenderTextureManager;
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
_textureManager->load();
|
|
|
|
|
|
2012-12-18 00:51:25 +00:00
|
|
|
// for stroke mesh generation
|
|
|
|
|
_width = re->winx;
|
|
|
|
|
_height = re->winy;
|
2011-11-06 12:23:44 +00:00
|
|
|
|
2009-09-28 03:56:31 +00:00
|
|
|
old_scene = re->scene;
|
2009-07-22 23:27:10 +00:00
|
|
|
|
2013-06-10 10:58:49 +00:00
|
|
|
char name[MAX_ID_NAME - 2];
|
2012-12-18 00:51:25 +00:00
|
|
|
BLI_snprintf(name, sizeof(name), "FRS%d_%s", render_count, re->scene->id.name + 2);
|
2013-04-23 22:40:13 +00:00
|
|
|
freestyle_scene = BKE_scene_add(freestyle_bmain, name);
|
2011-04-17 02:47:32 +00:00
|
|
|
freestyle_scene->r.cfra = old_scene->r.cfra;
|
2012-12-18 00:51:25 +00:00
|
|
|
freestyle_scene->r.mode = old_scene->r.mode &
|
|
|
|
|
~(R_EDGE_FRS | R_SHADOW | R_SSS | R_PANORAMA | R_ENVMAP | R_MBLUR | R_BORDER);
|
|
|
|
|
freestyle_scene->r.xsch = re->rectx; // old_scene->r.xsch
|
|
|
|
|
freestyle_scene->r.ysch = re->recty; // old_scene->r.ysch
|
|
|
|
|
freestyle_scene->r.xasp = 1.0f; // old_scene->r.xasp;
|
|
|
|
|
freestyle_scene->r.yasp = 1.0f; // old_scene->r.yasp;
|
|
|
|
|
freestyle_scene->r.tilex = old_scene->r.tilex;
|
|
|
|
|
freestyle_scene->r.tiley = old_scene->r.tiley;
|
|
|
|
|
freestyle_scene->r.size = 100; // old_scene->r.size
|
2013-03-26 09:59:43 +00:00
|
|
|
//freestyle_scene->r.maximsize = old_scene->r.maximsize; /* DEPRECATED */
|
2010-08-16 16:51:44 +00:00
|
|
|
freestyle_scene->r.ocres = old_scene->r.ocres;
|
2012-01-21 21:58:47 +00:00
|
|
|
freestyle_scene->r.color_mgt_flag = 0; // old_scene->r.color_mgt_flag;
|
2012-12-18 00:51:25 +00:00
|
|
|
freestyle_scene->r.scemode = old_scene->r.scemode & ~(R_SINGLE_LAYER);
|
|
|
|
|
freestyle_scene->r.flag = old_scene->r.flag;
|
|
|
|
|
freestyle_scene->r.threads = old_scene->r.threads;
|
|
|
|
|
freestyle_scene->r.border.xmin = old_scene->r.border.xmin;
|
|
|
|
|
freestyle_scene->r.border.ymin = old_scene->r.border.ymin;
|
|
|
|
|
freestyle_scene->r.border.xmax = old_scene->r.border.xmax;
|
|
|
|
|
freestyle_scene->r.border.ymax = old_scene->r.border.ymax;
|
2010-08-16 16:51:44 +00:00
|
|
|
strcpy(freestyle_scene->r.pic, old_scene->r.pic);
|
2012-12-18 00:51:25 +00:00
|
|
|
freestyle_scene->r.safety.xmin = old_scene->r.safety.xmin;
|
|
|
|
|
freestyle_scene->r.safety.ymin = old_scene->r.safety.ymin;
|
|
|
|
|
freestyle_scene->r.safety.xmax = old_scene->r.safety.xmax;
|
|
|
|
|
freestyle_scene->r.safety.ymax = old_scene->r.safety.ymax;
|
|
|
|
|
freestyle_scene->r.osa = old_scene->r.osa;
|
|
|
|
|
freestyle_scene->r.filtertype = old_scene->r.filtertype;
|
|
|
|
|
freestyle_scene->r.gauss = old_scene->r.gauss;
|
|
|
|
|
freestyle_scene->r.dither_intensity = old_scene->r.dither_intensity;
|
2010-08-16 16:51:44 +00:00
|
|
|
BLI_strncpy(freestyle_scene->r.engine, old_scene->r.engine, sizeof(freestyle_scene->r.engine));
|
2011-11-26 13:11:55 +00:00
|
|
|
freestyle_scene->r.im_format.planes = R_IMF_PLANES_RGBA;
|
|
|
|
|
freestyle_scene->r.im_format.imtype = R_IMF_IMTYPE_PNG;
|
2012-10-20 20:46:42 +00:00
|
|
|
BKE_scene_disable_color_management(freestyle_scene);
|
|
|
|
|
|
2013-01-18 02:13:36 +00:00
|
|
|
if (G.debug & G_DEBUG_FREESTYLE) {
|
|
|
|
|
printf("%s: %d threads\n", __func__, freestyle_scene->r.threads);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-05 22:24:05 +00:00
|
|
|
// Render layer
|
|
|
|
|
SceneRenderLayer *srl = (SceneRenderLayer *)freestyle_scene->r.layers.first;
|
|
|
|
|
srl->layflag = SCE_LAY_SOLID | SCE_LAY_ZTRA;
|
|
|
|
|
|
2013-04-23 22:40:13 +00:00
|
|
|
BKE_scene_set_background(freestyle_bmain, freestyle_scene);
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
|
|
|
|
|
// Camera
|
2013-04-23 22:40:13 +00:00
|
|
|
Object *object_camera = BKE_object_add(freestyle_bmain, freestyle_scene, OB_CAMERA);
|
2012-12-18 00:51:25 +00:00
|
|
|
|
2013-03-07 23:17:23 +00:00
|
|
|
Camera *camera = (Camera *)object_camera->data;
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
camera->type = CAM_ORTHO;
|
2011-11-06 12:23:44 +00:00
|
|
|
camera->ortho_scale = max(re->rectx, re->recty);
|
2012-12-18 00:51:25 +00:00
|
|
|
camera->clipsta = 0.1f;
|
|
|
|
|
camera->clipend = 100.0f;
|
2010-02-16 02:10:27 +00:00
|
|
|
|
2012-12-18 00:51:25 +00:00
|
|
|
_z_delta = 0.00001f;
|
|
|
|
|
_z = camera->clipsta + _z_delta;
|
2010-02-16 02:10:27 +00:00
|
|
|
|
2011-11-06 12:23:44 +00:00
|
|
|
object_camera->loc[0] = re->disprect.xmin + 0.5f * re->rectx;
|
|
|
|
|
object_camera->loc[1] = re->disprect.ymin + 0.5f * re->recty;
|
2012-12-18 00:51:25 +00:00
|
|
|
object_camera->loc[2] = 1.0f;
|
|
|
|
|
|
2009-09-28 03:56:31 +00:00
|
|
|
freestyle_scene->camera = object_camera;
|
2012-12-18 00:51:25 +00:00
|
|
|
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
// Material
|
2013-04-23 22:40:13 +00:00
|
|
|
material = BKE_material_add(freestyle_bmain, "stroke_material");
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
material->mode |= MA_VERTEXCOLP;
|
2010-02-16 02:10:27 +00:00
|
|
|
material->mode |= MA_TRANSP;
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
material->mode |= MA_SHLESS;
|
2010-02-16 02:10:27 +00:00
|
|
|
material->vcol_alpha = 1;
|
2013-02-14 19:19:44 +00:00
|
|
|
|
|
|
|
|
// Reset serial mesh ID (used for BlenderStrokeRenderer::NewMesh())
|
|
|
|
|
_mesh_id = 0xffffffff;
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
}
|
|
|
|
|
|
2012-12-18 00:51:25 +00:00
|
|
|
BlenderStrokeRenderer::~BlenderStrokeRenderer()
|
|
|
|
|
{
|
|
|
|
|
if (0 != _textureManager) {
|
2010-03-28 18:12:45 +00:00
|
|
|
delete _textureManager;
|
2012-12-18 00:51:25 +00:00
|
|
|
_textureManager = NULL;
|
2010-03-28 18:12:45 +00:00
|
|
|
}
|
2009-07-22 00:01:34 +00:00
|
|
|
|
2010-06-26 16:35:56 +00:00
|
|
|
// The freestyle_scene object is not released here. Instead,
|
|
|
|
|
// the scene is released in free_all_freestyle_renders() in
|
|
|
|
|
// source/blender/render/intern/source/pipeline.c, after the
|
|
|
|
|
// compositor has finished.
|
|
|
|
|
|
2009-07-22 23:27:10 +00:00
|
|
|
// release objects and data blocks
|
2013-03-07 23:17:23 +00:00
|
|
|
for (Base *b = (Base *)freestyle_scene->base.first; b; b = b->next) {
|
2010-03-28 18:12:45 +00:00
|
|
|
Object *ob = b->object;
|
2009-07-22 23:27:10 +00:00
|
|
|
void *data = ob->data;
|
2013-03-02 18:43:06 +00:00
|
|
|
char *name = ob->id.name;
|
2013-01-03 23:27:20 +00:00
|
|
|
#if 0
|
|
|
|
|
if (G.debug & G_DEBUG_FREESTYLE) {
|
|
|
|
|
cout << "removing " << name[0] << name[1] << ":" << (name+2) << endl;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2009-07-22 23:27:10 +00:00
|
|
|
switch (ob->type) {
|
2009-07-22 00:01:34 +00:00
|
|
|
case OB_MESH:
|
2013-04-23 22:40:13 +00:00
|
|
|
BKE_libblock_free(&freestyle_bmain->object, ob);
|
|
|
|
|
BKE_libblock_free(&freestyle_bmain->mesh, data);
|
2009-07-22 00:01:34 +00:00
|
|
|
break;
|
|
|
|
|
case OB_CAMERA:
|
2013-04-23 22:40:13 +00:00
|
|
|
BKE_libblock_free(&freestyle_bmain->object, ob);
|
|
|
|
|
BKE_libblock_free(&freestyle_bmain->camera, data);
|
2010-03-28 18:12:45 +00:00
|
|
|
freestyle_scene->camera = NULL;
|
2009-07-22 00:01:34 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
2013-03-07 23:17:23 +00:00
|
|
|
cerr << "Warning: unexpected object in the scene: " << name[0] << name[1] << ":" << (name + 2) << endl;
|
2009-07-22 00:01:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-12-18 00:51:25 +00:00
|
|
|
BLI_freelistN(&freestyle_scene->base);
|
2009-07-22 23:27:10 +00:00
|
|
|
|
|
|
|
|
// release material
|
2013-04-23 22:40:13 +00:00
|
|
|
BKE_libblock_free(&freestyle_bmain->mat, material);
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
}
|
|
|
|
|
|
2012-12-18 00:51:25 +00:00
|
|
|
float BlenderStrokeRenderer::get_stroke_vertex_z(void) const
|
|
|
|
|
{
|
|
|
|
|
float z = _z;
|
|
|
|
|
BlenderStrokeRenderer *self = const_cast<BlenderStrokeRenderer *>(this);
|
|
|
|
|
if (!(_z < _z_delta * 100000.0f))
|
|
|
|
|
self->_z_delta *= 10.0f;
|
|
|
|
|
self->_z += _z_delta;
|
|
|
|
|
return -z;
|
2010-02-16 02:10:27 +00:00
|
|
|
}
|
|
|
|
|
|
2013-02-14 19:19:44 +00:00
|
|
|
unsigned int BlenderStrokeRenderer::get_stroke_mesh_id(void) const
|
|
|
|
|
{
|
|
|
|
|
unsigned mesh_id = _mesh_id;
|
|
|
|
|
BlenderStrokeRenderer *self = const_cast<BlenderStrokeRenderer *>(this);
|
|
|
|
|
self->_mesh_id--;
|
|
|
|
|
return mesh_id;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-18 00:51:25 +00:00
|
|
|
void BlenderStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const
|
|
|
|
|
{
|
|
|
|
|
RenderStrokeRepBasic(iStrokeRep);
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
}
|
|
|
|
|
|
2012-12-18 00:51:25 +00:00
|
|
|
void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
|
|
|
|
|
{
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
////////////////////
|
|
|
|
|
// Build up scene
|
|
|
|
|
////////////////////
|
2012-12-18 00:51:25 +00:00
|
|
|
|
|
|
|
|
vector<Strip*>& strips = iStrokeRep->getStrips();
|
|
|
|
|
Strip::vertex_container::iterator v[3];
|
|
|
|
|
StrokeVertexRep *svRep[3];
|
2013-01-18 02:13:36 +00:00
|
|
|
/* Vec3r color[3]; */ /* UNUSED */
|
2012-12-18 00:51:25 +00:00
|
|
|
unsigned int vertex_index, edge_index, loop_index;
|
|
|
|
|
Vec2r p;
|
|
|
|
|
|
2013-03-07 23:17:23 +00:00
|
|
|
for (vector<Strip*>::iterator s = strips.begin(), send = strips.end(); s != send; ++s) {
|
2012-12-18 00:51:25 +00:00
|
|
|
Strip::vertex_container& strip_vertices = (*s)->vertices();
|
2010-01-26 22:24:53 +00:00
|
|
|
int strip_vertex_count = (*s)->sizeStrip();
|
2012-06-16 21:49:52 +00:00
|
|
|
int xl, xu, yl, yu, n, visible_faces, visible_segments;
|
2010-01-26 22:24:53 +00:00
|
|
|
bool visible;
|
|
|
|
|
|
|
|
|
|
// iterate over all vertices and count visible faces and strip segments
|
|
|
|
|
// (note: a strip segment is a series of visible faces, while two strip
|
|
|
|
|
// segments are separated by one or more invisible faces)
|
|
|
|
|
v[0] = strip_vertices.begin();
|
2012-12-18 00:51:25 +00:00
|
|
|
v[1] = v[0] + 1;
|
|
|
|
|
v[2] = v[0] + 2;
|
2010-01-26 22:24:53 +00:00
|
|
|
visible_faces = visible_segments = 0;
|
|
|
|
|
visible = false;
|
2012-12-18 00:51:25 +00:00
|
|
|
for (n = 2; n < strip_vertex_count; n++, v[0]++, v[1]++, v[2]++) {
|
2010-01-26 22:24:53 +00:00
|
|
|
svRep[0] = *(v[0]);
|
|
|
|
|
svRep[1] = *(v[1]);
|
|
|
|
|
svRep[2] = *(v[2]);
|
2012-06-16 21:49:52 +00:00
|
|
|
xl = xu = yl = yu = 0;
|
2010-01-26 22:24:53 +00:00
|
|
|
for (int j = 0; j < 3; j++) {
|
|
|
|
|
p = svRep[j]->point2d();
|
2012-12-18 00:51:25 +00:00
|
|
|
if (p[0] < 0.0)
|
|
|
|
|
xl++;
|
|
|
|
|
else if (p[0] > _width)
|
|
|
|
|
xu++;
|
|
|
|
|
if (p[1] < 0.0)
|
|
|
|
|
yl++;
|
|
|
|
|
else if (p[1] > _height)
|
|
|
|
|
yu++;
|
2010-01-26 22:24:53 +00:00
|
|
|
}
|
2012-06-16 21:49:52 +00:00
|
|
|
if (xl == 3 || xu == 3 || yl == 3 || yu == 3) {
|
2010-01-26 22:24:53 +00:00
|
|
|
visible = false;
|
2012-12-18 00:51:25 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2010-01-26 22:24:53 +00:00
|
|
|
visible_faces++;
|
|
|
|
|
if (!visible)
|
|
|
|
|
visible_segments++;
|
|
|
|
|
visible = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (visible_faces == 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
2012-12-18 00:51:25 +00:00
|
|
|
//me = Mesh.New()
|
2012-10-06 14:06:40 +00:00
|
|
|
#if 0
|
2013-04-23 22:40:13 +00:00
|
|
|
Object *object_mesh = BKE_object_add(freestyle_bmain, freestyle_scene, OB_MESH);
|
2012-10-06 14:06:40 +00:00
|
|
|
#else
|
2013-03-07 23:17:23 +00:00
|
|
|
Object *object_mesh = NewMesh();
|
2012-10-06 14:06:40 +00:00
|
|
|
#endif
|
2013-03-07 23:17:23 +00:00
|
|
|
Mesh *mesh = (Mesh *)object_mesh->data;
|
|
|
|
|
mesh->mat = (Material **)MEM_mallocN(1 * sizeof(Material *), "MaterialList");
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
mesh->mat[0] = material;
|
|
|
|
|
mesh->totcol = 1;
|
2013-04-23 22:40:13 +00:00
|
|
|
test_object_materials(freestyle_bmain, (ID *)mesh);
|
2012-06-16 21:49:52 +00:00
|
|
|
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
// vertices allocation
|
2010-01-26 22:24:53 +00:00
|
|
|
mesh->totvert = visible_faces + visible_segments * 2;
|
2013-03-07 23:17:23 +00:00
|
|
|
mesh->mvert = (MVert *)CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_CALLOC, NULL, mesh->totvert);
|
2012-12-18 00:51:25 +00:00
|
|
|
|
2012-06-16 21:49:52 +00:00
|
|
|
// edges allocation
|
|
|
|
|
mesh->totedge = visible_faces * 2 + visible_segments;
|
2013-03-07 23:17:23 +00:00
|
|
|
mesh->medge = (MEdge *)CustomData_add_layer(&mesh->edata, CD_MEDGE, CD_CALLOC, NULL, mesh->totedge);
|
2012-06-16 21:49:52 +00:00
|
|
|
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
// faces allocation
|
2012-06-16 21:49:52 +00:00
|
|
|
mesh->totpoly = visible_faces;
|
2013-03-07 23:17:23 +00:00
|
|
|
mesh->mpoly = (MPoly *)CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CALLOC, NULL, mesh->totpoly);
|
2012-06-16 21:49:52 +00:00
|
|
|
|
|
|
|
|
// loops allocation
|
|
|
|
|
mesh->totloop = visible_faces * 3;
|
2013-03-07 23:17:23 +00:00
|
|
|
mesh->mloop = (MLoop *)CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_CALLOC, NULL, mesh->totloop);
|
2012-12-18 00:51:25 +00:00
|
|
|
|
2012-06-16 21:49:52 +00:00
|
|
|
// colors allocation
|
2013-03-07 23:17:23 +00:00
|
|
|
mesh->mloopcol = (MLoopCol *)CustomData_add_layer(&mesh->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, mesh->totloop);
|
2009-07-22 00:01:34 +00:00
|
|
|
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
////////////////////
|
|
|
|
|
// Data copy
|
|
|
|
|
////////////////////
|
2012-12-18 00:51:25 +00:00
|
|
|
|
|
|
|
|
MVert *vertices = mesh->mvert;
|
|
|
|
|
MEdge *edges = mesh->medge;
|
|
|
|
|
MPoly *polys = mesh->mpoly;
|
|
|
|
|
MLoop *loops = mesh->mloop;
|
|
|
|
|
MLoopCol *colors = mesh->mloopcol;
|
2012-06-16 21:49:52 +00:00
|
|
|
|
|
|
|
|
v[0] = strip_vertices.begin();
|
2012-12-18 00:51:25 +00:00
|
|
|
v[1] = v[0] + 1;
|
|
|
|
|
v[2] = v[0] + 2;
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
|
2012-06-16 21:49:52 +00:00
|
|
|
vertex_index = edge_index = loop_index = 0;
|
2010-01-26 22:24:53 +00:00
|
|
|
visible = false;
|
2012-06-16 21:49:52 +00:00
|
|
|
|
|
|
|
|
// Note: Mesh generation in the following loop assumes stroke strips
|
|
|
|
|
// to be triangle strips.
|
2012-12-18 00:51:25 +00:00
|
|
|
for (n = 2; n < strip_vertex_count; n++, v[0]++, v[1]++, v[2]++) {
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
svRep[0] = *(v[0]);
|
|
|
|
|
svRep[1] = *(v[1]);
|
|
|
|
|
svRep[2] = *(v[2]);
|
2012-06-16 21:49:52 +00:00
|
|
|
xl = xu = yl = yu = 0;
|
2010-01-26 22:24:53 +00:00
|
|
|
for (int j = 0; j < 3; j++) {
|
|
|
|
|
p = svRep[j]->point2d();
|
2012-12-18 00:51:25 +00:00
|
|
|
if (p[0] < 0.0)
|
|
|
|
|
xl++;
|
|
|
|
|
else if (p[0] > _width)
|
|
|
|
|
xu++;
|
|
|
|
|
if (p[1] < 0.0)
|
|
|
|
|
yl++;
|
|
|
|
|
else if (p[1] > _height)
|
|
|
|
|
yu++;
|
2010-01-26 22:24:53 +00:00
|
|
|
}
|
2012-06-16 21:49:52 +00:00
|
|
|
if (xl == 3 || xu == 3 || yl == 3 || yu == 3) {
|
2010-01-26 22:24:53 +00:00
|
|
|
visible = false;
|
2012-12-18 00:51:25 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2010-01-26 22:24:53 +00:00
|
|
|
if (!visible) {
|
|
|
|
|
// first vertex
|
|
|
|
|
vertices->co[0] = svRep[0]->point2d()[0];
|
|
|
|
|
vertices->co[1] = svRep[0]->point2d()[1];
|
2010-02-16 02:10:27 +00:00
|
|
|
vertices->co[2] = get_stroke_vertex_z();
|
2010-01-26 22:24:53 +00:00
|
|
|
++vertices;
|
2012-06-16 21:49:52 +00:00
|
|
|
++vertex_index;
|
2012-12-18 00:51:25 +00:00
|
|
|
|
2010-01-26 22:24:53 +00:00
|
|
|
// second vertex
|
|
|
|
|
vertices->co[0] = svRep[1]->point2d()[0];
|
|
|
|
|
vertices->co[1] = svRep[1]->point2d()[1];
|
2010-02-16 02:10:27 +00:00
|
|
|
vertices->co[2] = get_stroke_vertex_z();
|
2010-01-26 22:24:53 +00:00
|
|
|
++vertices;
|
2012-06-16 21:49:52 +00:00
|
|
|
++vertex_index;
|
|
|
|
|
|
|
|
|
|
// first edge
|
|
|
|
|
edges->v1 = vertex_index - 2;
|
|
|
|
|
edges->v2 = vertex_index - 1;
|
|
|
|
|
++edges;
|
|
|
|
|
++edge_index;
|
2010-01-26 22:24:53 +00:00
|
|
|
}
|
|
|
|
|
visible = true;
|
|
|
|
|
|
|
|
|
|
// vertex
|
|
|
|
|
vertices->co[0] = svRep[2]->point2d()[0];
|
|
|
|
|
vertices->co[1] = svRep[2]->point2d()[1];
|
2010-02-16 02:10:27 +00:00
|
|
|
vertices->co[2] = get_stroke_vertex_z();
|
2012-06-16 21:49:52 +00:00
|
|
|
++vertices;
|
2010-01-26 22:24:53 +00:00
|
|
|
++vertex_index;
|
2012-06-16 21:49:52 +00:00
|
|
|
|
|
|
|
|
// edges
|
|
|
|
|
edges->v1 = vertex_index - 1;
|
|
|
|
|
edges->v2 = vertex_index - 3;
|
|
|
|
|
++edges;
|
|
|
|
|
++edge_index;
|
|
|
|
|
|
|
|
|
|
edges->v1 = vertex_index - 1;
|
|
|
|
|
edges->v2 = vertex_index - 2;
|
|
|
|
|
++edges;
|
|
|
|
|
++edge_index;
|
|
|
|
|
|
|
|
|
|
// poly
|
|
|
|
|
polys->loopstart = loop_index;
|
|
|
|
|
polys->totloop = 3;
|
|
|
|
|
++polys;
|
|
|
|
|
|
|
|
|
|
// loops
|
|
|
|
|
if (n % 2 == 0) {
|
|
|
|
|
loops[0].v = vertex_index - 1;
|
|
|
|
|
loops[0].e = edge_index - 1;
|
|
|
|
|
|
|
|
|
|
loops[1].v = vertex_index - 2;
|
|
|
|
|
loops[1].e = edge_index - 3;
|
|
|
|
|
|
|
|
|
|
loops[2].v = vertex_index - 3;
|
|
|
|
|
loops[2].e = edge_index - 2;
|
2012-12-18 00:51:25 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-06-16 21:49:52 +00:00
|
|
|
loops[0].v = vertex_index - 1;
|
|
|
|
|
loops[0].e = edge_index - 2;
|
|
|
|
|
|
|
|
|
|
loops[1].v = vertex_index - 3;
|
|
|
|
|
loops[1].e = edge_index - 3;
|
|
|
|
|
|
|
|
|
|
loops[2].v = vertex_index - 2;
|
|
|
|
|
loops[2].e = edge_index - 1;
|
|
|
|
|
}
|
|
|
|
|
loops += 3;
|
|
|
|
|
loop_index += 3;
|
|
|
|
|
|
|
|
|
|
// colors
|
|
|
|
|
if (n % 2 == 0) {
|
2012-12-18 00:51:25 +00:00
|
|
|
colors[0].r = (short)(255.0f * svRep[2]->color()[0]);
|
|
|
|
|
colors[0].g = (short)(255.0f * svRep[2]->color()[1]);
|
|
|
|
|
colors[0].b = (short)(255.0f * svRep[2]->color()[2]);
|
|
|
|
|
colors[0].a = (short)(255.0f * svRep[2]->alpha());
|
|
|
|
|
|
|
|
|
|
colors[1].r = (short)(255.0f * svRep[1]->color()[0]);
|
|
|
|
|
colors[1].g = (short)(255.0f * svRep[1]->color()[1]);
|
|
|
|
|
colors[1].b = (short)(255.0f * svRep[1]->color()[2]);
|
|
|
|
|
colors[1].a = (short)(255.0f * svRep[1]->alpha());
|
|
|
|
|
|
|
|
|
|
colors[2].r = (short)(255.0f * svRep[0]->color()[0]);
|
|
|
|
|
colors[2].g = (short)(255.0f * svRep[0]->color()[1]);
|
|
|
|
|
colors[2].b = (short)(255.0f * svRep[0]->color()[2]);
|
|
|
|
|
colors[2].a = (short)(255.0f * svRep[0]->alpha());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
colors[0].r = (short)(255.0f * svRep[2]->color()[0]);
|
|
|
|
|
colors[0].g = (short)(255.0f * svRep[2]->color()[1]);
|
|
|
|
|
colors[0].b = (short)(255.0f * svRep[2]->color()[2]);
|
|
|
|
|
colors[0].a = (short)(255.0f * svRep[2]->alpha());
|
|
|
|
|
|
|
|
|
|
colors[1].r = (short)(255.0f * svRep[0]->color()[0]);
|
|
|
|
|
colors[1].g = (short)(255.0f * svRep[0]->color()[1]);
|
|
|
|
|
colors[1].b = (short)(255.0f * svRep[0]->color()[2]);
|
|
|
|
|
colors[1].a = (short)(255.0f * svRep[0]->alpha());
|
|
|
|
|
|
|
|
|
|
colors[2].r = (short)(255.0f * svRep[1]->color()[0]);
|
|
|
|
|
colors[2].g = (short)(255.0f * svRep[1]->color()[1]);
|
|
|
|
|
colors[2].b = (short)(255.0f * svRep[1]->color()[2]);
|
|
|
|
|
colors[2].a = (short)(255.0f * svRep[1]->alpha());
|
2012-06-16 21:49:52 +00:00
|
|
|
}
|
|
|
|
|
colors += 3;
|
2010-01-26 22:24:53 +00:00
|
|
|
}
|
2012-12-18 00:51:25 +00:00
|
|
|
} // loop over strip vertices
|
2012-06-16 21:49:52 +00:00
|
|
|
#if 0
|
|
|
|
|
BKE_mesh_validate(mesh, TRUE);
|
|
|
|
|
#endif
|
2012-12-18 00:51:25 +00:00
|
|
|
} // loop over strips
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-06 14:06:40 +00:00
|
|
|
// A replacement of BKE_object_add() for better performance.
|
2012-12-18 00:51:25 +00:00
|
|
|
Object *BlenderStrokeRenderer::NewMesh() const
|
|
|
|
|
{
|
2012-10-06 14:06:40 +00:00
|
|
|
Object *ob;
|
|
|
|
|
Base *base;
|
|
|
|
|
char name[MAX_ID_NAME];
|
2013-02-14 19:19:44 +00:00
|
|
|
unsigned int mesh_id = get_stroke_mesh_id();
|
2012-10-06 14:06:40 +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
|
|
|
/* XXX this is for later review, for now we start names with 27 (DEL)
|
|
|
|
|
to allow ignoring them in DAG_ids_check_recalc() */
|
|
|
|
|
BLI_snprintf(name, MAX_ID_NAME, "%c0%08xOB", 27, mesh_id);
|
2013-04-23 22:40:13 +00:00
|
|
|
ob = BKE_object_add_only_object(freestyle_bmain, OB_MESH, name);
|
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
|
|
|
BLI_snprintf(name, MAX_ID_NAME, "%c0%08xME", 27, mesh_id);
|
2013-04-23 22:40:13 +00:00
|
|
|
ob->data = BKE_mesh_add(freestyle_bmain, name);
|
2012-10-06 14:06:40 +00:00
|
|
|
ob->lay = 1;
|
|
|
|
|
|
|
|
|
|
base = BKE_scene_base_add(freestyle_scene, ob);
|
2012-12-18 00:51:25 +00:00
|
|
|
#if 0
|
|
|
|
|
BKE_scene_base_deselect_all(scene);
|
|
|
|
|
BKE_scene_base_select(scene, base);
|
2013-01-18 02:13:36 +00:00
|
|
|
#else
|
|
|
|
|
(void)base;
|
2012-12-18 00:51:25 +00:00
|
|
|
#endif
|
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
|
|
|
ob->recalc = OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
|
2012-10-06 14:06:40 +00:00
|
|
|
|
|
|
|
|
return ob;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-11 02:32:01 +00:00
|
|
|
Render *BlenderStrokeRenderer::RenderScene(Render *re, bool render)
|
2012-12-18 00:51:25 +00:00
|
|
|
{
|
2013-03-07 23:17:23 +00:00
|
|
|
Camera *camera = (Camera *)freestyle_scene->camera->data;
|
2012-12-18 00:51:25 +00:00
|
|
|
if (camera->clipend < _z)
|
|
|
|
|
camera->clipend = _z + _z_delta * 100.0f;
|
2013-01-03 23:27:20 +00:00
|
|
|
#if 0
|
|
|
|
|
if (G.debug & G_DEBUG_FREESTYLE) {
|
|
|
|
|
cout << "clipsta " << camera->clipsta << ", clipend " << camera->clipend << endl;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2010-02-16 02:10:27 +00:00
|
|
|
|
2010-03-28 22:45:14 +00:00
|
|
|
Render *freestyle_render = RE_NewRender(freestyle_scene->id.name);
|
2010-02-08 02:19:17 +00:00
|
|
|
|
2013-06-11 02:32:01 +00:00
|
|
|
RE_RenderFreestyleStrokes(freestyle_render, freestyle_bmain, freestyle_scene, render);
|
2013-04-18 12:11:50 +00:00
|
|
|
|
2010-02-15 00:07:15 +00:00
|
|
|
return freestyle_render;
|
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
2008-12-01 21:30:44 +00:00
|
|
|
}
|
2013-04-09 00:46:49 +00:00
|
|
|
|
|
|
|
|
} /* namespace Freestyle */
|