2012-04-30 14:24:11 +00:00
|
|
|
/*
|
2009-01-20 11:09:26 +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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-01-20 11:09:26 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/render/render_preview.c
|
|
|
|
* \ingroup edrend
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-01-20 11:09:26 +00:00
|
|
|
/* global includes */
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#ifndef WIN32
|
|
|
|
#include <unistd.h>
|
|
|
|
#else
|
|
|
|
#include <io.h>
|
|
|
|
#endif
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2009-01-20 11:09:26 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2009-01-20 11:09:26 +00:00
|
|
|
|
2013-04-05 17:56:54 +00:00
|
|
|
#include "BLO_readfile.h"
|
|
|
|
|
2009-01-20 11:09:26 +00:00
|
|
|
#include "DNA_world_types.h"
|
|
|
|
#include "DNA_camera_types.h"
|
|
|
|
#include "DNA_material_types.h"
|
2010-12-20 13:02:33 +00:00
|
|
|
#include "DNA_node_types.h"
|
2009-01-20 11:09:26 +00:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_lamp_types.h"
|
|
|
|
#include "DNA_space_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_brush_types.h"
|
2009-01-20 11:09:26 +00:00
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
2014-11-23 14:37:13 +01:00
|
|
|
#include "BKE_appdir.h"
|
2011-08-28 05:06:30 +00:00
|
|
|
#include "BKE_brush.h"
|
2009-01-20 11:09:26 +00:00
|
|
|
#include "BKE_context.h"
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
#include "BKE_colortools.h"
|
2009-01-20 11:09:26 +00:00
|
|
|
#include "BKE_global.h"
|
2011-03-03 18:53:07 +00:00
|
|
|
#include "BKE_idprop.h"
|
2009-01-20 11:09:26 +00:00
|
|
|
#include "BKE_image.h"
|
|
|
|
#include "BKE_icons.h"
|
2011-11-05 13:11:49 +00:00
|
|
|
#include "BKE_lamp.h"
|
2009-01-20 11:09:26 +00:00
|
|
|
#include "BKE_library.h"
|
|
|
|
#include "BKE_main.h"
|
|
|
|
#include "BKE_material.h"
|
|
|
|
#include "BKE_node.h"
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
#include "BKE_scene.h"
|
2011-03-03 18:53:07 +00:00
|
|
|
#include "BKE_texture.h"
|
2011-05-19 11:37:08 +00:00
|
|
|
#include "BKE_world.h"
|
2009-01-20 11:09:26 +00:00
|
|
|
|
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
2013-01-05 17:57:17 +00:00
|
|
|
|
2009-01-20 11:09:26 +00:00
|
|
|
#include "BIF_gl.h"
|
|
|
|
#include "BIF_glutil.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "RE_pipeline.h"
|
2014-10-07 14:21:10 +02:00
|
|
|
#include "RE_engine.h"
|
2009-01-20 11:09:26 +00:00
|
|
|
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
2013-01-28 17:37:51 +00:00
|
|
|
#include "ED_datafiles.h"
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
#include "ED_render.h"
|
2009-01-20 11:09:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
ImBuf *get_brush_icon(Brush *brush)
|
2010-07-20 13:42:27 +00:00
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
static const int flags = IB_rect | IB_multilayer | IB_metadata;
|
2010-07-20 13:42:27 +00:00
|
|
|
|
2012-01-12 13:16:30 +00:00
|
|
|
char path[FILE_MAX];
|
2013-03-05 03:17:46 +00:00
|
|
|
const char *folder;
|
2010-07-20 13:42:27 +00:00
|
|
|
|
|
|
|
if (!(brush->icon_imbuf)) {
|
2010-07-26 04:00:09 +00:00
|
|
|
if (brush->flag & BRUSH_CUSTOM_ICON) {
|
2010-07-20 13:42:27 +00:00
|
|
|
|
|
|
|
if (brush->icon_filepath[0]) {
|
|
|
|
// first use the path directly to try and load the file
|
|
|
|
|
|
|
|
BLI_strncpy(path, brush->icon_filepath, sizeof(brush->icon_filepath));
|
2010-10-18 06:41:16 +00:00
|
|
|
BLI_path_abs(path, G.main->name);
|
2010-07-20 13:42:27 +00:00
|
|
|
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
/* use default colorspaces for brushes */
|
|
|
|
brush->icon_imbuf = IMB_loadiffname(path, flags, NULL);
|
2010-07-20 13:42:27 +00:00
|
|
|
|
|
|
|
// otherwise lets try to find it in other directories
|
|
|
|
if (!(brush->icon_imbuf)) {
|
2014-11-23 15:54:29 +01:00
|
|
|
folder = BKE_appdir_folder_id(BLENDER_DATAFILES, "brushicons");
|
2010-07-20 13:42:27 +00:00
|
|
|
|
2010-10-18 06:41:16 +00:00
|
|
|
BLI_make_file_string(G.main->name, path, folder, brush->icon_filepath);
|
2010-07-20 13:42:27 +00:00
|
|
|
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
if (path[0]) {
|
|
|
|
/* use fefault color spaces */
|
|
|
|
brush->icon_imbuf = IMB_loadiffname(path, flags, NULL);
|
|
|
|
}
|
2010-07-20 13:42:27 +00:00
|
|
|
}
|
2011-04-27 01:16:24 +00:00
|
|
|
|
|
|
|
if (brush->icon_imbuf)
|
|
|
|
BKE_icon_changed(BKE_icon_getid(&brush->id));
|
2010-07-20 13:42:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(brush->icon_imbuf))
|
2010-07-26 04:00:09 +00:00
|
|
|
brush->id.icon_id = 0;
|
2010-07-20 13:42:27 +00:00
|
|
|
|
|
|
|
return brush->icon_imbuf;
|
|
|
|
}
|
|
|
|
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
typedef struct ShaderPreview {
|
|
|
|
/* from wmJob */
|
|
|
|
void *owner;
|
|
|
|
short *stop, *do_update;
|
|
|
|
|
|
|
|
Scene *scene;
|
|
|
|
ID *id;
|
2009-07-21 01:57:46 +00:00
|
|
|
ID *parent;
|
2009-08-18 19:58:27 +00:00
|
|
|
MTex *slot;
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
|
2011-05-19 11:37:08 +00:00
|
|
|
/* datablocks with nodes need full copy during preview render, glsl uses it too */
|
2010-12-03 14:26:03 +00:00
|
|
|
Material *matcopy;
|
2011-03-03 18:53:07 +00:00
|
|
|
Tex *texcopy;
|
2011-05-19 11:37:08 +00:00
|
|
|
Lamp *lampcopy;
|
|
|
|
World *worldcopy;
|
2011-03-03 18:53:07 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
float col[4]; /* active object color */
|
2010-12-03 14:26:03 +00:00
|
|
|
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
int sizex, sizey;
|
2009-09-28 18:33:45 +00:00
|
|
|
unsigned int *pr_rect;
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
int pr_method;
|
2013-01-28 17:37:51 +00:00
|
|
|
|
|
|
|
Main *pr_main;
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
} ShaderPreview;
|
|
|
|
|
2012-02-17 16:06:32 +00:00
|
|
|
typedef struct IconPreviewSize {
|
|
|
|
struct IconPreviewSize *next, *prev;
|
|
|
|
int sizex, sizey;
|
|
|
|
unsigned int *rect;
|
|
|
|
} IconPreviewSize;
|
|
|
|
|
|
|
|
typedef struct IconPreview {
|
|
|
|
Scene *scene;
|
|
|
|
void *owner;
|
|
|
|
ID *id;
|
|
|
|
ListBase sizes;
|
|
|
|
} IconPreview;
|
|
|
|
|
2009-01-20 11:09:26 +00:00
|
|
|
/* *************************** Preview for buttons *********************** */
|
|
|
|
|
2013-03-15 22:55:10 +00:00
|
|
|
static Main *G_pr_main = NULL;
|
|
|
|
static Main *G_pr_main_cycles = NULL;
|
2009-01-20 11:09:26 +00:00
|
|
|
|
2011-07-13 19:27:42 +00:00
|
|
|
#ifndef WITH_HEADLESS
|
2013-03-17 19:13:04 +00:00
|
|
|
static Main *load_main_from_memory(const void *blend, int blend_size)
|
2013-01-28 17:37:51 +00:00
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
const int fileflags = G.fileflags;
|
2013-01-28 17:37:51 +00:00
|
|
|
Main *bmain = NULL;
|
|
|
|
BlendFileData *bfd;
|
|
|
|
|
2009-01-20 11:09:26 +00:00
|
|
|
G.fileflags |= G_FILE_NO_UI;
|
2013-01-28 17:37:51 +00:00
|
|
|
bfd = BLO_read_from_memory(blend, blend_size, NULL);
|
2009-01-20 11:09:26 +00:00
|
|
|
if (bfd) {
|
2013-01-28 17:37:51 +00:00
|
|
|
bmain = bfd->main;
|
|
|
|
|
2009-01-20 11:09:26 +00:00
|
|
|
MEM_freeN(bfd);
|
|
|
|
}
|
2012-03-29 22:42:32 +00:00
|
|
|
G.fileflags = fileflags;
|
2013-01-28 17:37:51 +00:00
|
|
|
|
|
|
|
return bmain;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void ED_preview_init_dbase(void)
|
|
|
|
{
|
|
|
|
#ifndef WITH_HEADLESS
|
2013-03-15 22:55:10 +00:00
|
|
|
G_pr_main = load_main_from_memory(datatoc_preview_blend, datatoc_preview_blend_size);
|
|
|
|
G_pr_main_cycles = load_main_from_memory(datatoc_preview_cycles_blend, datatoc_preview_cycles_blend_size);
|
2011-07-13 19:27:42 +00:00
|
|
|
#endif
|
2009-01-20 11:09:26 +00:00
|
|
|
}
|
|
|
|
|
2014-10-07 14:21:10 +02:00
|
|
|
static bool check_engine_supports_textures(Scene *scene)
|
|
|
|
{
|
|
|
|
RenderEngineType *type = RE_engines_find(scene->r.engine);
|
|
|
|
return type->flag & RE_USE_TEXTURE_PREVIEW;
|
|
|
|
}
|
|
|
|
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
void ED_preview_free_dbase(void)
|
2009-01-20 11:09:26 +00:00
|
|
|
{
|
2013-03-15 22:55:10 +00:00
|
|
|
if (G_pr_main)
|
2013-12-30 13:25:27 +11:00
|
|
|
BKE_main_free(G_pr_main);
|
2013-01-28 17:37:51 +00:00
|
|
|
|
2013-03-15 22:55:10 +00:00
|
|
|
if (G_pr_main_cycles)
|
2013-12-30 13:25:27 +11:00
|
|
|
BKE_main_free(G_pr_main_cycles);
|
2009-01-20 11:09:26 +00:00
|
|
|
}
|
|
|
|
|
2010-12-20 13:02:33 +00:00
|
|
|
static int preview_mat_has_sss(Material *mat, bNodeTree *ntree)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mat) {
|
|
|
|
if (mat->sss_flag & MA_DIFF_SSS)
|
2010-12-20 13:02:33 +00:00
|
|
|
return 1;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mat->nodetree)
|
2012-03-29 22:42:32 +00:00
|
|
|
if (preview_mat_has_sss(NULL, mat->nodetree))
|
2010-12-20 13:02:33 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ntree) {
|
2010-12-20 13:02:33 +00:00
|
|
|
bNode *node;
|
2012-03-29 22:42:32 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->type == NODE_GROUP && node->id) {
|
|
|
|
if (preview_mat_has_sss(NULL, (bNodeTree *)node->id))
|
2010-12-20 13:02:33 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (node->id && ELEM(node->type, SH_NODE_MATERIAL, SH_NODE_MATERIAL_EXT)) {
|
2012-03-29 22:42:32 +00:00
|
|
|
mat = (Material *)node->id;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mat->sss_flag & MA_DIFF_SSS)
|
2010-12-20 13:02:33 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-01-28 17:37:51 +00:00
|
|
|
static Scene *preview_get_scene(Main *pr_main)
|
2012-11-06 15:54:04 +00:00
|
|
|
{
|
|
|
|
if (pr_main == NULL) return NULL;
|
|
|
|
|
|
|
|
return pr_main->scene.first;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
/* call this with a pointer to initialize preview scene */
|
|
|
|
/* call this with NULL to restore assigned ID pointers in preview scene */
|
2009-07-21 01:57:46 +00:00
|
|
|
static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPreview *sp)
|
2009-01-20 11:09:26 +00:00
|
|
|
{
|
|
|
|
Scene *sce;
|
|
|
|
Base *base;
|
2013-01-28 17:37:51 +00:00
|
|
|
Main *pr_main = sp->pr_main;
|
2009-01-20 11:09:26 +00:00
|
|
|
|
2013-01-28 17:37:51 +00:00
|
|
|
sce = preview_get_scene(pr_main);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sce) {
|
2011-01-02 19:46:32 +00:00
|
|
|
|
2009-01-20 11:09:26 +00:00
|
|
|
/* this flag tells render to not execute depsgraph or ipos etc */
|
2013-05-15 17:09:45 +00:00
|
|
|
sce->r.scemode |= R_BUTS_PREVIEW;
|
2009-01-20 11:09:26 +00:00
|
|
|
/* set world always back, is used now */
|
2012-03-29 22:42:32 +00:00
|
|
|
sce->world = pr_main->world.first;
|
2009-01-20 11:09:26 +00:00
|
|
|
/* now: exposure copy */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scene->world) {
|
2012-03-29 22:42:32 +00:00
|
|
|
sce->world->exp = scene->world->exp;
|
|
|
|
sce->world->range = scene->world->range;
|
2009-01-20 11:09:26 +00:00
|
|
|
}
|
|
|
|
|
2009-07-17 02:43:15 +00:00
|
|
|
sce->r.color_mgt_flag = scene->r.color_mgt_flag;
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
BKE_color_managed_display_settings_copy(&sce->display_settings, &scene->display_settings);
|
|
|
|
|
|
|
|
BKE_color_managed_view_settings_free(&sce->view_settings);
|
|
|
|
BKE_color_managed_view_settings_copy(&sce->view_settings, &scene->view_settings);
|
2011-01-02 19:46:32 +00:00
|
|
|
|
|
|
|
/* prevent overhead for small renders and icons (32) */
|
2012-11-05 08:05:14 +00:00
|
|
|
if (id && sp->sizex < 40) {
|
|
|
|
sce->r.tilex = sce->r.tiley = 64;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sce->r.tilex = sce->r.xsch / 4;
|
|
|
|
sce->r.tiley = sce->r.ysch / 4;
|
|
|
|
}
|
2011-01-02 19:46:32 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if ((id && sp->pr_method == PR_ICON_RENDER) && id_type != ID_WO)
|
|
|
|
sce->r.alphamode = R_ALPHAPREMUL;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
else
|
2012-03-29 22:42:32 +00:00
|
|
|
sce->r.alphamode = R_ADDSKY;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
sce->r.cfra = scene->r.cfra;
|
2013-03-22 09:42:16 +00:00
|
|
|
|
2014-10-07 14:21:10 +02:00
|
|
|
if (id_type == ID_TE && !check_engine_supports_textures(scene)) {
|
2014-06-14 01:06:49 +10:00
|
|
|
/* Force blender internal for texture icons and nodes render,
|
2013-03-22 09:42:16 +00:00
|
|
|
* seems commonly used render engines does not support
|
2014-06-14 01:06:49 +10:00
|
|
|
* such kind of rendering.
|
2013-03-22 09:42:16 +00:00
|
|
|
*/
|
2014-10-28 12:49:04 +01:00
|
|
|
BLI_strncpy(sce->r.engine, RE_engine_id_BLENDER_RENDER, sizeof(sce->r.engine));
|
2013-03-22 09:42:16 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_strncpy(sce->r.engine, scene->r.engine, sizeof(sce->r.engine));
|
|
|
|
}
|
2009-01-20 11:09:26 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (id_type == ID_MA) {
|
|
|
|
Material *mat = NULL, *origmat = (Material *)id;
|
2009-01-20 11:09:26 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (origmat) {
|
2010-12-03 14:26:03 +00:00
|
|
|
/* work on a copy */
|
2012-03-29 22:42:32 +00:00
|
|
|
mat = localize_material(origmat);
|
|
|
|
sp->matcopy = mat;
|
2010-12-19 11:39:55 +00:00
|
|
|
BLI_addtail(&pr_main->mat, mat);
|
2010-12-03 14:26:03 +00:00
|
|
|
|
2013-01-28 17:37:51 +00:00
|
|
|
if (!BKE_scene_use_new_shading_nodes(scene)) {
|
|
|
|
init_render_material(mat, 0, NULL); /* call that retrieves mode_l */
|
|
|
|
end_render_material(mat);
|
|
|
|
|
|
|
|
/* un-useful option */
|
|
|
|
if (sp->pr_method == PR_ICON_RENDER)
|
|
|
|
mat->shade_flag &= ~MA_OBCOLOR;
|
|
|
|
|
|
|
|
/* turn on raytracing if needed */
|
|
|
|
if (mat->mode_l & MA_RAYMIRROR)
|
|
|
|
sce->r.mode |= R_RAYTRACE;
|
|
|
|
if (mat->material_type == MA_TYPE_VOLUME)
|
|
|
|
sce->r.mode |= R_RAYTRACE;
|
|
|
|
if ((mat->mode_l & MA_RAYTRANSP) && (mat->mode_l & MA_TRANSP))
|
|
|
|
sce->r.mode |= R_RAYTRACE;
|
|
|
|
if (preview_mat_has_sss(mat, NULL))
|
|
|
|
sce->r.mode |= R_SSS;
|
|
|
|
|
|
|
|
/* turn off fake shadows if needed */
|
|
|
|
/* this only works in a specific case where the preview.blend contains
|
|
|
|
* an object starting with 'c' which has a material linked to it (not the obdata)
|
|
|
|
* and that material has a fake shadow texture in the active texture slot */
|
|
|
|
for (base = sce->base.first; base; base = base->next) {
|
|
|
|
if (base->object->id.name[2] == 'c') {
|
|
|
|
Material *shadmat = give_current_material(base->object, base->object->actcol);
|
|
|
|
if (shadmat) {
|
2014-04-23 15:02:06 +09:00
|
|
|
if (mat->mode2 & MA_CASTSHADOW) shadmat->septex = 0;
|
2013-01-28 17:37:51 +00:00
|
|
|
else shadmat->septex |= 1;
|
|
|
|
}
|
2009-01-20 11:09:26 +00:00
|
|
|
}
|
|
|
|
}
|
2013-01-28 17:37:51 +00:00
|
|
|
|
|
|
|
/* turn off bounce lights for volume,
|
|
|
|
* doesn't make much visual difference and slows it down too */
|
2013-11-26 15:33:31 +09:00
|
|
|
for (base = sce->base.first; base; base = base->next) {
|
|
|
|
if (base->object->type == OB_LAMP) {
|
|
|
|
/* if doesn't match 'Lamp.002' --> main key light */
|
|
|
|
if (strcmp(base->object->id.name + 2, "Lamp.002") != 0) {
|
|
|
|
if (mat->material_type == MA_TYPE_VOLUME)
|
2013-01-28 17:37:51 +00:00
|
|
|
base->object->restrictflag |= OB_RESTRICT_RENDER;
|
2013-11-26 15:33:31 +09:00
|
|
|
else
|
|
|
|
base->object->restrictflag &= ~OB_RESTRICT_RENDER;
|
Rework of volume shading
After code review and experimentation, this commit makes some changes to the way that volumes are shaded. Previously, there were problems with the 'scattering' component, in that it wasn't physically correct - it didn't conserve energy and was just acting as a brightness multiplier. This has been changed to be more correct, so that as the light is scattered out of the volume, there is less remaining to penetrate through.
Since this behaviour is very similar to absorption but more useful, absorption has been removed and has been replaced by a 'transmission colour' - controlling the colour of light penetrating through the volume after it has been scattered/absorbed. As well as this, there's now 'reflection', a non-physically correct RGB multiplier for out-scattered light. This is handy for tweaking the overall colour of the volume, without having to worry about wavelength dependent absorption, and its effects on transmitted light. Now at least, even though there is the ability to tweak things non-physically, volume shading is physically based by default, and has a better combination of correctness and ease of use.
There's more detailed information and example images here:
http://wiki.blender.org/index.php/User:Broken/VolumeRendering
Also did some tweaks/optimisation:
* Removed shading step size (was a bit annoying, if it comes back, it will be in a different form)
* Removed phase function options, now just one asymmetry slider controls the range between back-scattering, isotropic scattering, and forward scattering. (note, more extreme values gives artifacts with light cache, will fix...)
* Disabled the extra 'bounce lights' from the preview render for volumes, speeds updates significantly
* Enabled voxeldata texture in preview render
* Fixed volume shadows (they were too dark, fixed by avoiding using the shadfac/AddAlphaLight stuff)
More revisions to come later...
2009-09-29 22:01:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-02-14 16:01:34 +00:00
|
|
|
else {
|
|
|
|
/* use current scene world to light sphere */
|
2013-02-14 16:11:47 +00:00
|
|
|
if (mat->pr_type == MA_SPHERE_A)
|
2013-02-14 16:01:34 +00:00
|
|
|
sce->world = scene->world;
|
|
|
|
}
|
2009-01-20 11:09:26 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (sp->pr_method == PR_ICON_RENDER) {
|
2009-05-20 13:34:04 +00:00
|
|
|
if (mat->material_type == MA_TYPE_HALO) {
|
2012-03-29 22:42:32 +00:00
|
|
|
sce->lay = 1 << MA_FLAT;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-01-20 11:09:26 +00:00
|
|
|
else {
|
2012-03-29 22:42:32 +00:00
|
|
|
sce->lay = 1 << MA_SPHERE_A;
|
2013-04-11 12:49:57 +00:00
|
|
|
|
|
|
|
/* same as above, use current scene world to light sphere */
|
|
|
|
if (BKE_scene_use_new_shading_nodes(scene))
|
|
|
|
sce->world = scene->world;
|
2009-01-20 11:09:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-03-29 22:42:32 +00:00
|
|
|
sce->lay = 1 << mat->pr_type;
|
|
|
|
if (mat->nodetree && sp->pr_method == PR_NODE_RENDER) {
|
2010-12-19 20:12:12 +00:00
|
|
|
/* two previews, they get copied by wmJob */
|
2014-04-01 11:34:00 +11:00
|
|
|
BKE_node_preview_init_tree(mat->nodetree, sp->sizex, sp->sizey, true);
|
|
|
|
BKE_node_preview_init_tree(origmat->nodetree, sp->sizex, sp->sizey, true);
|
2010-12-19 20:12:12 +00:00
|
|
|
}
|
2009-01-20 11:09:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-03-29 22:42:32 +00:00
|
|
|
sce->r.mode &= ~(R_OSA | R_RAYTRACE | R_SSS);
|
2010-12-03 14:26:03 +00:00
|
|
|
|
2009-01-20 11:09:26 +00:00
|
|
|
}
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
for (base = sce->base.first; base; base = base->next) {
|
|
|
|
if (base->object->id.name[2] == 'p') {
|
2011-01-05 15:10:35 +00:00
|
|
|
/* copy over object color, in case material uses it */
|
|
|
|
copy_v4_v4(base->object->col, sp->col);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (OB_TYPE_SUPPORT_MATERIAL(base->object->type)) {
|
2009-09-04 21:02:43 +00:00
|
|
|
/* don't use assign_material, it changed mat->id.us, which shows in the UI */
|
2012-03-29 22:42:32 +00:00
|
|
|
Material ***matar = give_matarar(base->object);
|
2012-10-23 16:21:55 +00:00
|
|
|
int actcol = max_ii(base->object->actcol - 1, 0);
|
2009-09-04 21:02:43 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (matar && actcol < base->object->totcol)
|
2012-03-29 22:42:32 +00:00
|
|
|
(*matar)[actcol] = mat;
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else if (base->object->type == OB_LAMP) {
|
Rework of volume shading
After code review and experimentation, this commit makes some changes to the way that volumes are shaded. Previously, there were problems with the 'scattering' component, in that it wasn't physically correct - it didn't conserve energy and was just acting as a brightness multiplier. This has been changed to be more correct, so that as the light is scattered out of the volume, there is less remaining to penetrate through.
Since this behaviour is very similar to absorption but more useful, absorption has been removed and has been replaced by a 'transmission colour' - controlling the colour of light penetrating through the volume after it has been scattered/absorbed. As well as this, there's now 'reflection', a non-physically correct RGB multiplier for out-scattered light. This is handy for tweaking the overall colour of the volume, without having to worry about wavelength dependent absorption, and its effects on transmitted light. Now at least, even though there is the ability to tweak things non-physically, volume shading is physically based by default, and has a better combination of correctness and ease of use.
There's more detailed information and example images here:
http://wiki.blender.org/index.php/User:Broken/VolumeRendering
Also did some tweaks/optimisation:
* Removed shading step size (was a bit annoying, if it comes back, it will be in a different form)
* Removed phase function options, now just one asymmetry slider controls the range between back-scattering, isotropic scattering, and forward scattering. (note, more extreme values gives artifacts with light cache, will fix...)
* Disabled the extra 'bounce lights' from the preview render for volumes, speeds updates significantly
* Enabled voxeldata texture in preview render
* Fixed volume shadows (they were too dark, fixed by avoiding using the shadfac/AddAlphaLight stuff)
More revisions to come later...
2009-09-29 22:01:32 +00:00
|
|
|
base->object->restrictflag &= ~OB_RESTRICT_RENDER;
|
2009-09-04 21:02:43 +00:00
|
|
|
}
|
2009-01-20 11:09:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-29 22:42:32 +00:00
|
|
|
else if (id_type == ID_TE) {
|
|
|
|
Tex *tex = NULL, *origtex = (Tex *)id;
|
2009-01-20 11:09:26 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (origtex) {
|
2012-03-29 22:42:32 +00:00
|
|
|
tex = localize_texture(origtex);
|
|
|
|
sp->texcopy = tex;
|
2011-03-03 18:53:07 +00:00
|
|
|
BLI_addtail(&pr_main->tex, tex);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2012-03-29 22:42:32 +00:00
|
|
|
sce->lay = 1 << MA_TEXTURE;
|
2009-01-20 11:09:26 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
for (base = sce->base.first; base; base = base->next) {
|
|
|
|
if (base->object->id.name[2] == 't') {
|
|
|
|
Material *mat = give_current_material(base->object, base->object->actcol);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mat && mat->mtex[0]) {
|
2012-03-29 22:42:32 +00:00
|
|
|
mat->mtex[0]->tex = tex;
|
2009-08-18 19:58:27 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (tex && sp->slot)
|
2009-08-18 19:58:27 +00:00
|
|
|
mat->mtex[0]->which_output = sp->slot->which_output;
|
2013-03-04 16:37:05 +00:00
|
|
|
|
|
|
|
mat->mtex[0]->mapto &= ~MAP_ALPHA;
|
|
|
|
mat->alpha = 1.0f;
|
|
|
|
|
2009-01-20 11:09:26 +00:00
|
|
|
/* show alpha in this case */
|
2012-03-29 22:42:32 +00:00
|
|
|
if (tex == NULL || (tex->flag & TEX_PRV_ALPHA)) {
|
2013-03-05 14:47:49 +00:00
|
|
|
if (!(tex && tex->type == TEX_IMAGE && (tex->imaflag & (TEX_USEALPHA | TEX_CALCALPHA)) == 0)) {
|
2013-03-04 16:37:05 +00:00
|
|
|
mat->mtex[0]->mapto |= MAP_ALPHA;
|
|
|
|
mat->alpha = 0.0f;
|
|
|
|
}
|
2009-01-20 11:09:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-10-07 14:48:29 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (tex && tex->nodetree && sp->pr_method == PR_NODE_RENDER) {
|
2011-03-03 18:53:07 +00:00
|
|
|
/* two previews, they get copied by wmJob */
|
2014-04-01 11:34:00 +11:00
|
|
|
BKE_node_preview_init_tree(origtex->nodetree, sp->sizex, sp->sizey, true);
|
|
|
|
BKE_node_preview_init_tree(tex->nodetree, sp->sizex, sp->sizey, true);
|
2011-03-03 18:53:07 +00:00
|
|
|
}
|
2009-01-20 11:09:26 +00:00
|
|
|
}
|
2012-03-29 22:42:32 +00:00
|
|
|
else if (id_type == ID_LA) {
|
|
|
|
Lamp *la = NULL, *origla = (Lamp *)id;
|
2011-05-19 11:37:08 +00:00
|
|
|
|
|
|
|
/* work on a copy */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (origla) {
|
2012-03-29 22:42:32 +00:00
|
|
|
la = localize_lamp(origla);
|
|
|
|
sp->lampcopy = la;
|
2011-05-19 11:37:08 +00:00
|
|
|
BLI_addtail(&pr_main->lamp, la);
|
|
|
|
}
|
2013-01-28 17:37:51 +00:00
|
|
|
|
|
|
|
sce->lay = 1 << MA_LAMP;
|
|
|
|
|
|
|
|
if (!BKE_scene_use_new_shading_nodes(scene)) {
|
|
|
|
if (la && la->type == LA_SUN && (la->sun_effect_type & LA_SUN_EFFECT_SKY)) {
|
|
|
|
sce->lay = 1 << MA_ATMOS;
|
|
|
|
sce->world = scene->world;
|
|
|
|
sce->camera = (Object *)BLI_findstring(&pr_main->object, "CameraAtmo", offsetof(ID, name) + 2);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sce->world = NULL;
|
|
|
|
sce->camera = (Object *)BLI_findstring(&pr_main->object, "Camera", offsetof(ID, name) + 2);
|
|
|
|
}
|
2009-01-20 11:09:26 +00:00
|
|
|
}
|
2013-01-28 17:37:51 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
for (base = sce->base.first; base; base = base->next) {
|
|
|
|
if (base->object->id.name[2] == 'p') {
|
|
|
|
if (base->object->type == OB_LAMP)
|
|
|
|
base->object->data = la;
|
2009-01-20 11:09:26 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-02 18:55:32 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (la && la->nodetree && sp->pr_method == PR_NODE_RENDER) {
|
2011-11-02 18:55:32 +00:00
|
|
|
/* two previews, they get copied by wmJob */
|
2014-04-01 11:34:00 +11:00
|
|
|
BKE_node_preview_init_tree(origla->nodetree, sp->sizex, sp->sizey, true);
|
|
|
|
BKE_node_preview_init_tree(la->nodetree, sp->sizex, sp->sizey, true);
|
2011-11-02 18:55:32 +00:00
|
|
|
}
|
2009-01-20 11:09:26 +00:00
|
|
|
}
|
2012-03-29 22:42:32 +00:00
|
|
|
else if (id_type == ID_WO) {
|
|
|
|
World *wrld = NULL, *origwrld = (World *)id;
|
2011-05-19 11:37:08 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (origwrld) {
|
2012-03-29 22:42:32 +00:00
|
|
|
wrld = localize_world(origwrld);
|
|
|
|
sp->worldcopy = wrld;
|
2011-05-19 11:37:08 +00:00
|
|
|
BLI_addtail(&pr_main->world, wrld);
|
|
|
|
}
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
sce->lay = 1 << MA_SKY;
|
|
|
|
sce->world = wrld;
|
2011-11-02 18:55:32 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (wrld && wrld->nodetree && sp->pr_method == PR_NODE_RENDER) {
|
2011-11-02 18:55:32 +00:00
|
|
|
/* two previews, they get copied by wmJob */
|
2014-04-01 11:34:00 +11:00
|
|
|
BKE_node_preview_init_tree(wrld->nodetree, sp->sizex, sp->sizey, true);
|
|
|
|
BKE_node_preview_init_tree(origwrld->nodetree, sp->sizex, sp->sizey, true);
|
2011-11-02 18:55:32 +00:00
|
|
|
}
|
2009-01-20 11:09:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return sce;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-06-07 11:12:35 +00:00
|
|
|
/* new UI convention: draw is in pixel space already. */
|
2014-11-09 21:20:40 +01:00
|
|
|
/* uses UI_BTYPE_ROUNDBOX button in block to get the rect */
|
2014-04-11 11:25:41 +10:00
|
|
|
static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect, rcti *newrect)
|
2009-07-21 01:57:46 +00:00
|
|
|
{
|
2009-09-30 18:18:32 +00:00
|
|
|
Render *re;
|
2009-07-21 01:57:46 +00:00
|
|
|
RenderResult rres;
|
|
|
|
char name[32];
|
2012-08-20 23:06:17 +00:00
|
|
|
int offx = 0;
|
2012-09-15 11:48:20 +00:00
|
|
|
int newx = BLI_rcti_size_x(rect);
|
|
|
|
int newy = BLI_rcti_size_y(rect);
|
2014-04-11 11:25:41 +10:00
|
|
|
bool ok = false;
|
2009-07-21 01:57:46 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!split || first) sprintf(name, "Preview %p", (void *)sa);
|
2010-12-03 01:52:28 +00:00
|
|
|
else sprintf(name, "SecondPreview %p", (void *)sa);
|
2009-07-21 01:57:46 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (split) {
|
|
|
|
if (first) {
|
2012-03-29 22:42:32 +00:00
|
|
|
offx = 0;
|
|
|
|
newx = newx / 2;
|
2009-07-21 01:57:46 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-29 22:42:32 +00:00
|
|
|
offx = newx / 2;
|
|
|
|
newx = newx - newx / 2;
|
2009-07-21 01:57:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-01 19:02:08 +00:00
|
|
|
/* test if something rendered ok */
|
2012-03-29 22:42:32 +00:00
|
|
|
re = RE_GetRender(name);
|
2009-09-30 18:18:32 +00:00
|
|
|
RE_AcquireResultImage(re, &rres);
|
2009-07-21 01:57:46 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (rres.rectf) {
|
2009-07-21 01:57:46 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (ABS(rres.rectx - newx) < 2 && ABS(rres.recty - newy) < 2) {
|
2011-12-30 14:17:11 +00:00
|
|
|
|
2012-10-23 16:21:55 +00:00
|
|
|
newrect->xmax = max_ii(newrect->xmax, rect->xmin + rres.rectx + offx);
|
|
|
|
newrect->ymax = max_ii(newrect->ymax, rect->ymin + rres.recty);
|
2009-07-21 01:57:46 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (rres.rectx && rres.recty) {
|
2013-01-01 19:02:08 +00:00
|
|
|
unsigned char *rect_byte = MEM_mallocN(rres.rectx * rres.recty * sizeof(int), "ed_preview_draw_rect");
|
2012-03-29 22:42:32 +00:00
|
|
|
float fx = rect->xmin + offx;
|
|
|
|
float fy = rect->ymin;
|
2014-12-06 12:30:59 +01:00
|
|
|
if (re)
|
|
|
|
RE_AcquiredResultGet32(re, &rres, (unsigned int *)rect_byte);
|
2013-01-01 19:02:08 +00:00
|
|
|
|
2011-12-30 14:17:11 +00:00
|
|
|
glaDrawPixelsSafe(fx, fy, rres.rectx, rres.recty, rres.rectx, GL_RGBA, GL_UNSIGNED_BYTE, rect_byte);
|
2013-01-01 19:02:08 +00:00
|
|
|
|
2011-12-30 14:17:11 +00:00
|
|
|
MEM_freeN(rect_byte);
|
2013-01-01 19:02:08 +00:00
|
|
|
|
2013-04-24 19:21:14 +00:00
|
|
|
ok = 1;
|
2011-12-30 14:17:11 +00:00
|
|
|
}
|
2009-07-21 01:57:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-24 19:21:14 +00:00
|
|
|
RE_ReleaseResultImage(re);
|
|
|
|
|
|
|
|
return ok;
|
2009-07-21 01:57:46 +00:00
|
|
|
}
|
|
|
|
|
2009-08-18 19:58:27 +00:00
|
|
|
void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, rcti *rect)
|
2009-01-20 11:09:26 +00:00
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (idp) {
|
2013-04-26 13:47:57 +00:00
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
2012-03-29 22:42:32 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
2009-07-17 02:43:15 +00:00
|
|
|
ID *id = (ID *)idp;
|
2012-03-29 22:42:32 +00:00
|
|
|
ID *parent = (ID *)parentp;
|
|
|
|
MTex *slot = (MTex *)slotp;
|
|
|
|
SpaceButs *sbuts = sa->spacedata.first;
|
2013-08-28 19:22:48 +00:00
|
|
|
ShaderPreview *sp = WM_jobs_customdata(wm, sa);
|
2009-07-21 01:57:46 +00:00
|
|
|
rcti newrect;
|
|
|
|
int ok;
|
2012-09-15 11:48:20 +00:00
|
|
|
int newx = BLI_rcti_size_x(rect);
|
|
|
|
int newy = BLI_rcti_size_y(rect);
|
2009-06-11 17:21:27 +00:00
|
|
|
|
2012-03-24 02:51:46 +00:00
|
|
|
newrect.xmin = rect->xmin;
|
|
|
|
newrect.xmax = rect->xmin;
|
|
|
|
newrect.ymin = rect->ymin;
|
|
|
|
newrect.ymax = rect->ymin;
|
2009-07-21 01:57:46 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (parent) {
|
2013-01-01 19:02:08 +00:00
|
|
|
ok = ed_preview_draw_rect(sa, 1, 1, rect, &newrect);
|
|
|
|
ok &= ed_preview_draw_rect(sa, 1, 0, rect, &newrect);
|
2009-07-21 18:29:37 +00:00
|
|
|
}
|
|
|
|
else
|
2013-01-01 19:02:08 +00:00
|
|
|
ok = ed_preview_draw_rect(sa, 0, 0, rect, &newrect);
|
2009-07-21 01:57:46 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ok)
|
2012-03-29 22:42:32 +00:00
|
|
|
*rect = newrect;
|
2009-06-07 12:12:55 +00:00
|
|
|
|
2013-04-26 13:47:57 +00:00
|
|
|
/* start a new preview render job if signalled through sbuts->preview,
|
2013-08-28 19:22:48 +00:00
|
|
|
* if no render result was found and no preview render job is running,
|
|
|
|
* or if the job is running and the size of preview changed */
|
2013-04-26 13:47:57 +00:00
|
|
|
if ((sbuts->spacetype == SPACE_BUTS && sbuts->preview) ||
|
2013-08-28 19:22:48 +00:00
|
|
|
(!ok && !WM_jobs_test(wm, sa, WM_JOB_TYPE_RENDER_PREVIEW)) ||
|
2014-01-12 22:05:24 +11:00
|
|
|
(sp && (ABS(sp->sizex - newx) >= 2 || ABS(sp->sizey - newy) > 2)))
|
2013-04-28 15:37:18 +00:00
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
sbuts->preview = 0;
|
2009-10-07 14:48:29 +00:00
|
|
|
ED_preview_shader_job(C, sa, id, parent, slot, newx, newy, PR_BUTS_RENDER);
|
2009-06-11 17:21:27 +00:00
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-01-20 11:09:26 +00:00
|
|
|
}
|
|
|
|
|
2009-09-28 18:33:45 +00:00
|
|
|
/* **************************** new shader preview system ****************** */
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
|
2009-06-07 11:12:35 +00:00
|
|
|
/* inside thread, called by renderer, sets job update value */
|
2013-12-17 23:42:38 +06:00
|
|
|
static void shader_preview_update(void *spv, RenderResult *UNUSED(rr), volatile struct rcti *UNUSED(rect))
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
ShaderPreview *sp = spv;
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
*(sp->do_update) = true;
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* called by renderer, checks job value */
|
|
|
|
static int shader_preview_break(void *spv)
|
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
ShaderPreview *sp = spv;
|
2011-01-02 19:46:32 +00:00
|
|
|
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
return *(sp->stop);
|
|
|
|
}
|
|
|
|
|
2009-06-07 11:12:35 +00:00
|
|
|
/* outside thread, called before redraw notifiers, it moves finished preview over */
|
2010-12-19 20:12:12 +00:00
|
|
|
static void shader_preview_updatejob(void *spv)
|
2009-06-07 11:12:35 +00:00
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
ShaderPreview *sp = spv;
|
2009-06-07 11:12:35 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sp->id) {
|
2012-03-29 22:42:32 +00:00
|
|
|
if (sp->pr_method == PR_NODE_RENDER) {
|
|
|
|
if (GS(sp->id->name) == ID_MA) {
|
|
|
|
Material *mat = (Material *)sp->id;
|
2011-03-04 12:59:09 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sp->matcopy && mat->nodetree && sp->matcopy->nodetree)
|
2011-03-04 12:59:09 +00:00
|
|
|
ntreeLocalSync(sp->matcopy->nodetree, mat->nodetree);
|
|
|
|
}
|
2012-03-29 22:42:32 +00:00
|
|
|
else if (GS(sp->id->name) == ID_TE) {
|
|
|
|
Tex *tex = (Tex *)sp->id;
|
2011-03-04 12:59:09 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sp->texcopy && tex->nodetree && sp->texcopy->nodetree)
|
2011-03-04 12:59:09 +00:00
|
|
|
ntreeLocalSync(sp->texcopy->nodetree, tex->nodetree);
|
|
|
|
}
|
2012-03-29 22:42:32 +00:00
|
|
|
else if (GS(sp->id->name) == ID_WO) {
|
|
|
|
World *wrld = (World *)sp->id;
|
2011-11-02 18:55:32 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sp->worldcopy && wrld->nodetree && sp->worldcopy->nodetree)
|
2011-11-02 18:55:32 +00:00
|
|
|
ntreeLocalSync(sp->worldcopy->nodetree, wrld->nodetree);
|
|
|
|
}
|
2012-03-29 22:42:32 +00:00
|
|
|
else if (GS(sp->id->name) == ID_LA) {
|
|
|
|
Lamp *la = (Lamp *)sp->id;
|
2011-11-02 18:55:32 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sp->lampcopy && la->nodetree && sp->lampcopy->nodetree)
|
2011-11-02 18:55:32 +00:00
|
|
|
ntreeLocalSync(sp->lampcopy->nodetree, la->nodetree);
|
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2010-12-20 11:33:52 +00:00
|
|
|
}
|
2009-06-07 11:12:35 +00:00
|
|
|
}
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
|
2009-07-21 01:57:46 +00:00
|
|
|
static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int first)
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
{
|
|
|
|
Render *re;
|
|
|
|
Scene *sce;
|
2009-06-07 11:12:35 +00:00
|
|
|
float oldlens;
|
2012-03-29 22:42:32 +00:00
|
|
|
short idtype = GS(id->name);
|
2009-07-21 01:57:46 +00:00
|
|
|
char name[32];
|
|
|
|
int sizex;
|
2013-01-28 17:37:51 +00:00
|
|
|
Main *pr_main = sp->pr_main;
|
2011-01-02 19:46:32 +00:00
|
|
|
|
2012-11-06 15:54:04 +00:00
|
|
|
/* in case of split preview, use border render */
|
|
|
|
if (split) {
|
|
|
|
if (first) sizex = sp->sizex / 2;
|
|
|
|
else sizex = sp->sizex - sp->sizex / 2;
|
|
|
|
}
|
2013-03-09 03:46:30 +00:00
|
|
|
else {
|
|
|
|
sizex = sp->sizex;
|
|
|
|
}
|
|
|
|
|
2012-11-06 15:54:04 +00:00
|
|
|
/* we have to set preview variables first */
|
2013-01-28 17:37:51 +00:00
|
|
|
sce = preview_get_scene(pr_main);
|
2012-11-06 15:54:04 +00:00
|
|
|
if (sce) {
|
|
|
|
sce->r.xsch = sizex;
|
|
|
|
sce->r.ysch = sp->sizey;
|
|
|
|
sce->r.size = 100;
|
|
|
|
}
|
|
|
|
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
/* get the stuff from the builtin preview dbase */
|
2012-11-06 15:54:04 +00:00
|
|
|
sce = preview_prepare_scene(sp->scene, id, idtype, sp);
|
2012-03-29 22:42:32 +00:00
|
|
|
if (sce == NULL) return;
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!split || first) sprintf(name, "Preview %p", sp->owner);
|
2009-07-21 01:57:46 +00:00
|
|
|
else sprintf(name, "SecondPreview %p", sp->owner);
|
2012-03-29 22:42:32 +00:00
|
|
|
re = RE_GetRender(name);
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
|
|
|
|
/* full refreshed render from first tile */
|
2012-03-29 22:42:32 +00:00
|
|
|
if (re == NULL)
|
|
|
|
re = RE_NewRender(name);
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
|
2009-06-07 11:12:35 +00:00
|
|
|
/* sce->r gets copied in RE_InitState! */
|
2012-03-29 22:42:32 +00:00
|
|
|
sce->r.scemode &= ~(R_MATNODE_PREVIEW | R_TEXNODE_PREVIEW);
|
2009-10-07 14:48:29 +00:00
|
|
|
sce->r.scemode &= ~R_NO_IMAGE_LOAD;
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (sp->pr_method == PR_ICON_RENDER) {
|
2009-10-07 14:48:29 +00:00
|
|
|
sce->r.scemode |= R_NO_IMAGE_LOAD;
|
2010-04-23 18:02:50 +00:00
|
|
|
sce->r.mode |= R_OSA;
|
2009-10-07 14:48:29 +00:00
|
|
|
}
|
2012-03-29 22:42:32 +00:00
|
|
|
else if (sp->pr_method == PR_NODE_RENDER) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (idtype == ID_MA) sce->r.scemode |= R_MATNODE_PREVIEW;
|
|
|
|
else if (idtype == ID_TE) sce->r.scemode |= R_TEXNODE_PREVIEW;
|
2011-01-03 15:50:08 +00:00
|
|
|
sce->r.mode &= ~R_OSA;
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
}
|
2012-03-29 22:42:32 +00:00
|
|
|
else { /* PR_BUTS_RENDER */
|
2009-10-07 14:48:29 +00:00
|
|
|
sce->r.mode |= R_OSA;
|
2009-06-07 11:12:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
/* callbacs are cleared on GetRender() */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ELEM(sp->pr_method, PR_BUTS_RENDER, PR_NODE_RENDER)) {
|
2013-12-17 23:42:38 +06:00
|
|
|
RE_display_update_cb(re, sp, shader_preview_update);
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
}
|
2012-08-08 18:37:06 +00:00
|
|
|
/* set this for all previews, default is react to G.is_break still */
|
2011-03-11 17:59:40 +00:00
|
|
|
RE_test_break_cb(re, sp, shader_preview_break);
|
|
|
|
|
2009-06-07 11:12:35 +00:00
|
|
|
/* lens adjust */
|
2012-03-29 22:42:32 +00:00
|
|
|
oldlens = ((Camera *)sce->camera->data)->lens;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sizex > sp->sizey)
|
2012-03-29 22:42:32 +00:00
|
|
|
((Camera *)sce->camera->data)->lens *= (float)sp->sizey / (float)sizex;
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
|
|
|
|
/* entire cycle for render engine */
|
2010-12-19 11:39:55 +00:00
|
|
|
RE_PreviewRender(re, pr_main, sce);
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
((Camera *)sce->camera->data)->lens = oldlens;
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
|
|
|
|
/* handle results */
|
2012-03-29 22:42:32 +00:00
|
|
|
if (sp->pr_method == PR_ICON_RENDER) {
|
2011-01-03 06:13:50 +00:00
|
|
|
// char *rct= (char *)(sp->pr_rect + 32*16 + 16);
|
2011-01-02 19:46:32 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sp->pr_rect)
|
2009-09-28 18:33:45 +00:00
|
|
|
RE_ResultGet32(re, sp->pr_rect);
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* unassign the pointers, reset vars */
|
2010-12-03 14:26:03 +00:00
|
|
|
preview_prepare_scene(sp->scene, NULL, GS(id->name), sp);
|
2011-02-26 13:53:15 +00:00
|
|
|
|
|
|
|
/* XXX bad exception, end-exec is not being called in render, because it uses local main */
|
2012-03-24 06:38:07 +00:00
|
|
|
// if (idtype == ID_TE) {
|
2011-03-03 18:53:07 +00:00
|
|
|
// Tex *tex= (Tex *)id;
|
2012-03-24 06:38:07 +00:00
|
|
|
// if (tex->use_nodes && tex->nodetree)
|
2011-03-03 18:53:07 +00:00
|
|
|
// ntreeEndExecTree(tex->nodetree);
|
|
|
|
// }
|
2011-02-26 13:53:15 +00:00
|
|
|
|
2009-07-21 01:57:46 +00:00
|
|
|
}
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
|
2009-09-28 18:33:45 +00:00
|
|
|
/* runs inside thread for material and icons */
|
2009-07-21 01:57:46 +00:00
|
|
|
static void shader_preview_startjob(void *customdata, short *stop, short *do_update)
|
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
ShaderPreview *sp = customdata;
|
2009-07-21 01:57:46 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
sp->stop = stop;
|
|
|
|
sp->do_update = do_update;
|
2009-07-21 01:57:46 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sp->parent) {
|
2010-08-20 10:17:39 +00:00
|
|
|
shader_preview_render(sp, sp->id, 1, 1);
|
|
|
|
shader_preview_render(sp, sp->parent, 1, 0);
|
2009-07-21 01:57:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
shader_preview_render(sp, sp->id, 0, 0);
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
*do_update = true;
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void shader_preview_free(void *customdata)
|
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
ShaderPreview *sp = customdata;
|
2013-01-28 17:37:51 +00:00
|
|
|
Main *pr_main = sp->pr_main;
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sp->matcopy) {
|
2011-02-21 02:07:26 +00:00
|
|
|
struct IDProperty *properties;
|
2011-04-04 13:47:34 +00:00
|
|
|
|
2010-12-19 20:12:12 +00:00
|
|
|
/* node previews */
|
|
|
|
shader_preview_updatejob(sp);
|
|
|
|
|
|
|
|
/* get rid of copied material */
|
|
|
|
BLI_remlink(&pr_main->mat, sp->matcopy);
|
2011-04-04 13:47:34 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
BKE_material_free_ex(sp->matcopy, false);
|
2011-02-21 02:07:26 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
properties = IDP_GetProperties((ID *)sp->matcopy, false);
|
2011-02-21 02:07:26 +00:00
|
|
|
if (properties) {
|
|
|
|
IDP_FreeProperty(properties);
|
|
|
|
MEM_freeN(properties);
|
|
|
|
}
|
2010-12-19 20:12:12 +00:00
|
|
|
MEM_freeN(sp->matcopy);
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sp->texcopy) {
|
2011-03-03 18:53:07 +00:00
|
|
|
struct IDProperty *properties;
|
|
|
|
/* node previews */
|
|
|
|
shader_preview_updatejob(sp);
|
|
|
|
|
|
|
|
/* get rid of copied texture */
|
|
|
|
BLI_remlink(&pr_main->tex, sp->texcopy);
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_texture_free(sp->texcopy);
|
2011-03-03 18:53:07 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
properties = IDP_GetProperties((ID *)sp->texcopy, false);
|
2011-03-03 18:53:07 +00:00
|
|
|
if (properties) {
|
|
|
|
IDP_FreeProperty(properties);
|
|
|
|
MEM_freeN(properties);
|
|
|
|
}
|
|
|
|
MEM_freeN(sp->texcopy);
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sp->worldcopy) {
|
2011-05-19 11:37:08 +00:00
|
|
|
struct IDProperty *properties;
|
|
|
|
/* node previews */
|
|
|
|
shader_preview_updatejob(sp);
|
|
|
|
|
|
|
|
/* get rid of copied world */
|
|
|
|
BLI_remlink(&pr_main->world, sp->worldcopy);
|
2014-04-01 11:34:00 +11:00
|
|
|
BKE_world_free_ex(sp->worldcopy, true); /* [#32865] - we need to unlink the texture copies, unlike for materials */
|
2011-05-19 11:37:08 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
properties = IDP_GetProperties((ID *)sp->worldcopy, false);
|
2011-05-19 11:37:08 +00:00
|
|
|
if (properties) {
|
|
|
|
IDP_FreeProperty(properties);
|
|
|
|
MEM_freeN(properties);
|
|
|
|
}
|
|
|
|
MEM_freeN(sp->worldcopy);
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sp->lampcopy) {
|
2011-05-19 11:37:08 +00:00
|
|
|
struct IDProperty *properties;
|
|
|
|
/* node previews */
|
|
|
|
shader_preview_updatejob(sp);
|
|
|
|
|
|
|
|
/* get rid of copied lamp */
|
|
|
|
BLI_remlink(&pr_main->lamp, sp->lampcopy);
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_lamp_free(sp->lampcopy);
|
2011-05-19 11:37:08 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
properties = IDP_GetProperties((ID *)sp->lampcopy, false);
|
2011-05-19 11:37:08 +00:00
|
|
|
if (properties) {
|
|
|
|
IDP_FreeProperty(properties);
|
|
|
|
MEM_freeN(properties);
|
|
|
|
}
|
|
|
|
MEM_freeN(sp->lampcopy);
|
|
|
|
}
|
2010-12-19 20:12:12 +00:00
|
|
|
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
MEM_freeN(sp);
|
|
|
|
}
|
|
|
|
|
2009-09-28 18:33:45 +00:00
|
|
|
/* ************************* icon preview ********************** */
|
|
|
|
|
|
|
|
static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned int *rect)
|
|
|
|
{
|
|
|
|
struct ImBuf *ima;
|
|
|
|
unsigned int *drect, *srect;
|
|
|
|
float scaledx, scaledy;
|
|
|
|
short ex, ey, dx, dy;
|
|
|
|
|
|
|
|
/* paranoia test */
|
2012-03-29 22:42:32 +00:00
|
|
|
if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL))
|
2009-09-28 18:33:45 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* waste of cpu cyles... but the imbuf API has no other way to scale fast (ton) */
|
|
|
|
ima = IMB_dupImBuf(ibuf);
|
|
|
|
|
|
|
|
if (!ima)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ima->x > ima->y) {
|
|
|
|
scaledx = (float)w;
|
2012-03-29 22:42:32 +00:00
|
|
|
scaledy = ( (float)ima->y / (float)ima->x) * (float)w;
|
2009-09-28 18:33:45 +00:00
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
else {
|
2012-03-29 22:42:32 +00:00
|
|
|
scaledx = ( (float)ima->x / (float)ima->y) * (float)h;
|
2009-09-28 18:33:45 +00:00
|
|
|
scaledy = (float)h;
|
|
|
|
}
|
|
|
|
|
|
|
|
ex = (short)scaledx;
|
|
|
|
ey = (short)scaledy;
|
|
|
|
|
|
|
|
dx = (w - ex) / 2;
|
|
|
|
dy = (h - ey) / 2;
|
|
|
|
|
|
|
|
IMB_scalefastImBuf(ima, ex, ey);
|
|
|
|
|
|
|
|
/* if needed, convert to 32 bits */
|
2012-03-29 22:42:32 +00:00
|
|
|
if (ima->rect == NULL)
|
2009-09-28 18:33:45 +00:00
|
|
|
IMB_rect_from_float(ima);
|
|
|
|
|
|
|
|
srect = ima->rect;
|
|
|
|
drect = rect;
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
drect += dy * w + dx;
|
|
|
|
for (; ey > 0; ey--) {
|
|
|
|
memcpy(drect, srect, ex * sizeof(int));
|
2009-09-28 18:33:45 +00:00
|
|
|
drect += w;
|
|
|
|
srect += ima->x;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMB_freeImBuf(ima);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_alpha(char *cp, int sizex, int sizey, char alpha)
|
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
int a, size = sizex * sizey;
|
2009-09-28 18:33:45 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
for (a = 0; a < size; a++, cp += 4)
|
|
|
|
cp[3] = alpha;
|
2009-09-28 18:33:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void icon_preview_startjob(void *customdata, short *stop, short *do_update)
|
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
ShaderPreview *sp = customdata;
|
|
|
|
ID *id = sp->id;
|
|
|
|
short idtype = GS(id->name);
|
2013-01-05 17:57:17 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (idtype == ID_IM) {
|
2012-03-29 22:42:32 +00:00
|
|
|
Image *ima = (Image *)id;
|
|
|
|
ImBuf *ibuf = NULL;
|
|
|
|
ImageUser iuser = {NULL};
|
2009-09-28 18:33:45 +00:00
|
|
|
|
|
|
|
/* ima->ok is zero when Image cannot load */
|
2012-03-29 22:42:32 +00:00
|
|
|
if (ima == NULL || ima->ok == 0)
|
2009-09-28 18:33:45 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* setup dummy image user */
|
2012-03-29 22:42:32 +00:00
|
|
|
iuser.ok = iuser.framenr = 1;
|
|
|
|
iuser.scene = sp->scene;
|
2009-09-28 18:33:45 +00:00
|
|
|
|
|
|
|
/* elubie: this needs to be changed: here image is always loaded if not
|
2012-03-03 16:31:46 +00:00
|
|
|
* already there. Very expensive for large images. Need to find a way to
|
|
|
|
* only get existing ibuf */
|
2012-11-15 15:59:58 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
|
2013-02-12 15:49:48 +00:00
|
|
|
if (ibuf == NULL || ibuf->rect == NULL) {
|
|
|
|
BKE_image_release_ibuf(ima, ibuf, NULL);
|
2009-09-28 18:33:45 +00:00
|
|
|
return;
|
2013-02-12 15:49:48 +00:00
|
|
|
}
|
2009-09-28 18:33:45 +00:00
|
|
|
|
|
|
|
icon_copy_rect(ibuf, sp->sizex, sp->sizey, sp->pr_rect);
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
*do_update = true;
|
2012-11-15 15:59:58 +00:00
|
|
|
|
|
|
|
BKE_image_release_ibuf(ima, ibuf, NULL);
|
2009-09-28 18:33:45 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (idtype == ID_BR) {
|
2012-03-29 22:42:32 +00:00
|
|
|
Brush *br = (Brush *)id;
|
2010-07-20 11:32:30 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
br->icon_imbuf = get_brush_icon(br);
|
2010-07-20 11:32:30 +00:00
|
|
|
|
2013-07-29 04:45:40 +00:00
|
|
|
memset(sp->pr_rect, 0x88, sp->sizex * sp->sizey * sizeof(unsigned int));
|
2011-04-27 01:16:24 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!(br->icon_imbuf) || !(br->icon_imbuf->rect))
|
2010-07-20 11:32:30 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
icon_copy_rect(br->icon_imbuf, sp->sizex, sp->sizey, sp->pr_rect);
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
*do_update = true;
|
2010-07-20 11:32:30 +00:00
|
|
|
}
|
2009-09-28 18:33:45 +00:00
|
|
|
else {
|
|
|
|
/* re-use shader job */
|
|
|
|
shader_preview_startjob(customdata, stop, do_update);
|
|
|
|
|
|
|
|
/* world is rendered with alpha=0, so it wasn't displayed
|
2012-03-03 16:31:46 +00:00
|
|
|
* this could be render option for sky to, for later */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (idtype == ID_WO) {
|
2012-03-29 22:42:32 +00:00
|
|
|
set_alpha((char *)sp->pr_rect, sp->sizex, sp->sizey, 255);
|
2009-09-28 18:33:45 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (idtype == ID_MA) {
|
2012-03-29 22:42:32 +00:00
|
|
|
Material *ma = (Material *)id;
|
2009-09-28 18:33:45 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ma->material_type == MA_TYPE_HALO)
|
2012-03-29 22:42:32 +00:00
|
|
|
set_alpha((char *)sp->pr_rect, sp->sizex, sp->sizey, 255);
|
2009-09-28 18:33:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* use same function for icon & shader, so the job manager
|
2012-03-03 16:31:46 +00:00
|
|
|
* does not run two of them at the same time. */
|
2009-09-28 18:33:45 +00:00
|
|
|
|
2010-10-16 14:32:17 +00:00
|
|
|
static void common_preview_startjob(void *customdata, short *stop, short *do_update, float *UNUSED(progress))
|
2009-09-28 18:33:45 +00:00
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
ShaderPreview *sp = customdata;
|
2009-09-28 18:33:45 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sp->pr_method == PR_ICON_RENDER)
|
2009-09-28 18:33:45 +00:00
|
|
|
icon_preview_startjob(customdata, stop, do_update);
|
|
|
|
else
|
|
|
|
shader_preview_startjob(customdata, stop, do_update);
|
|
|
|
}
|
|
|
|
|
2012-02-17 16:06:32 +00:00
|
|
|
/* exported functions */
|
|
|
|
|
|
|
|
static void icon_preview_add_size(IconPreview *ip, unsigned int *rect, int sizex, int sizey)
|
2010-07-20 13:42:27 +00:00
|
|
|
{
|
2012-02-17 16:06:32 +00:00
|
|
|
IconPreviewSize *cur_size = ip->sizes.first, *new_size;
|
2010-07-20 13:42:27 +00:00
|
|
|
|
2012-02-17 16:06:32 +00:00
|
|
|
while (cur_size) {
|
|
|
|
if (cur_size->sizex == sizex && cur_size->sizey == sizey) {
|
|
|
|
/* requested size is already in list, no need to add it again */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cur_size = cur_size->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
new_size = MEM_callocN(sizeof(IconPreviewSize), "IconPreviewSize");
|
|
|
|
new_size->sizex = sizex;
|
|
|
|
new_size->sizey = sizey;
|
|
|
|
new_size->rect = rect;
|
|
|
|
|
|
|
|
BLI_addtail(&ip->sizes, new_size);
|
2010-07-20 13:42:27 +00:00
|
|
|
}
|
|
|
|
|
2012-02-17 16:06:32 +00:00
|
|
|
static void icon_preview_startjob_all_sizes(void *customdata, short *stop, short *do_update, float *progress)
|
|
|
|
{
|
|
|
|
IconPreview *ip = (IconPreview *)customdata;
|
|
|
|
IconPreviewSize *cur_size = ip->sizes.first;
|
2014-02-03 18:55:59 +11:00
|
|
|
const bool use_new_shading = BKE_scene_use_new_shading_nodes(ip->scene);
|
2012-02-17 16:06:32 +00:00
|
|
|
|
|
|
|
while (cur_size) {
|
2012-04-13 12:12:54 +00:00
|
|
|
ShaderPreview *sp = MEM_callocN(sizeof(ShaderPreview), "Icon ShaderPreview");
|
2012-02-17 16:06:32 +00:00
|
|
|
|
|
|
|
/* construct shader preview from image size and previewcustomdata */
|
2012-04-13 12:12:54 +00:00
|
|
|
sp->scene = ip->scene;
|
|
|
|
sp->owner = ip->owner;
|
|
|
|
sp->sizex = cur_size->sizex;
|
|
|
|
sp->sizey = cur_size->sizey;
|
|
|
|
sp->pr_method = PR_ICON_RENDER;
|
|
|
|
sp->pr_rect = cur_size->rect;
|
|
|
|
sp->id = ip->id;
|
2013-04-11 12:49:57 +00:00
|
|
|
|
2013-04-14 14:54:08 +00:00
|
|
|
if (use_new_shading) {
|
|
|
|
/* texture icon rendering is hardcoded to use BI,
|
|
|
|
* so don't even think of using cycle's bmain for
|
|
|
|
* texture icons
|
|
|
|
*/
|
|
|
|
if (GS(ip->id->name) != ID_TE)
|
|
|
|
sp->pr_main = G_pr_main_cycles;
|
|
|
|
else
|
|
|
|
sp->pr_main = G_pr_main;
|
|
|
|
}
|
|
|
|
else {
|
2013-04-11 12:49:57 +00:00
|
|
|
sp->pr_main = G_pr_main;
|
2013-04-14 14:54:08 +00:00
|
|
|
}
|
2012-04-13 12:12:54 +00:00
|
|
|
|
|
|
|
common_preview_startjob(sp, stop, do_update, progress);
|
|
|
|
shader_preview_free(sp);
|
2012-02-17 16:06:32 +00:00
|
|
|
|
|
|
|
cur_size = cur_size->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void icon_preview_endjob(void *customdata)
|
|
|
|
{
|
|
|
|
IconPreview *ip = customdata;
|
|
|
|
|
2013-01-05 17:57:17 +00:00
|
|
|
if (ip->id) {
|
|
|
|
|
|
|
|
if (GS(ip->id->name) == ID_BR)
|
|
|
|
WM_main_add_notifier(NC_BRUSH | NA_EDITED, ip->id);
|
2013-01-05 18:23:05 +00:00
|
|
|
#if 0
|
2013-01-05 17:57:17 +00:00
|
|
|
if (GS(ip->id->name) == ID_MA) {
|
|
|
|
Material *ma = (Material *)ip->id;
|
|
|
|
PreviewImage *prv_img = ma->preview;
|
|
|
|
int i;
|
2013-01-05 18:23:05 +00:00
|
|
|
|
2013-01-05 17:57:17 +00:00
|
|
|
/* signal to gpu texture */
|
|
|
|
for (i = 0; i < NUM_ICON_SIZES; ++i) {
|
|
|
|
if (prv_img->gputexture[i]) {
|
|
|
|
GPU_texture_free(prv_img->gputexture[i]);
|
|
|
|
prv_img->gputexture[i] = NULL;
|
|
|
|
WM_main_add_notifier(NC_MATERIAL|ND_SHADING_DRAW, ip->id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-01-05 18:23:05 +00:00
|
|
|
#endif
|
2013-01-05 17:57:17 +00:00
|
|
|
}
|
2012-02-17 16:06:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void icon_preview_free(void *customdata)
|
|
|
|
{
|
|
|
|
IconPreview *ip = (IconPreview *)customdata;
|
|
|
|
|
|
|
|
BLI_freelistN(&ip->sizes);
|
|
|
|
MEM_freeN(ip);
|
|
|
|
}
|
2009-09-28 18:33:45 +00:00
|
|
|
|
2015-01-07 12:31:25 +01:00
|
|
|
void ED_preview_icon_render(const bContext *C, void *UNUSED(owner), ID *id, unsigned int *rect, int sizex, int sizey)
|
|
|
|
{
|
|
|
|
IconPreview ip = {0};
|
|
|
|
short stop = false, update = false;
|
|
|
|
float progress = 0.0f;
|
|
|
|
|
|
|
|
/* customdata for preview thread */
|
|
|
|
ip.scene = CTX_data_scene(C);
|
|
|
|
ip.owner = id;
|
|
|
|
ip.id = id;
|
|
|
|
|
|
|
|
icon_preview_add_size(&ip, rect, sizex, sizey);
|
|
|
|
|
|
|
|
icon_preview_startjob_all_sizes(&ip, &stop, &update, &progress);
|
|
|
|
|
|
|
|
icon_preview_endjob(&ip);
|
|
|
|
|
|
|
|
BLI_freelistN(&ip.sizes);
|
|
|
|
}
|
|
|
|
|
2009-09-28 18:33:45 +00:00
|
|
|
void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *rect, int sizex, int sizey)
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
{
|
2012-08-15 10:03:29 +00:00
|
|
|
wmJob *wm_job;
|
2012-02-17 16:06:32 +00:00
|
|
|
IconPreview *ip, *old_ip;
|
2011-01-05 15:10:35 +00:00
|
|
|
|
2011-01-04 14:59:55 +00:00
|
|
|
/* suspended start means it starts after 1 timer step, see WM_jobs_timer below */
|
2012-08-15 10:03:29 +00:00
|
|
|
wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Icon Preview",
|
|
|
|
WM_JOB_EXCL_RENDER | WM_JOB_SUSPEND, WM_JOB_TYPE_RENDER_PREVIEW);
|
2012-02-17 16:06:32 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
ip = MEM_callocN(sizeof(IconPreview), "icon preview");
|
2012-02-17 16:06:32 +00:00
|
|
|
|
|
|
|
/* render all resolutions from suspended job too */
|
2012-08-15 10:03:29 +00:00
|
|
|
old_ip = WM_jobs_customdata_get(wm_job);
|
2012-02-17 16:06:32 +00:00
|
|
|
if (old_ip)
|
|
|
|
BLI_movelisttolist(&ip->sizes, &old_ip->sizes);
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
|
|
|
|
/* customdata for preview thread */
|
2012-03-29 22:42:32 +00:00
|
|
|
ip->scene = CTX_data_scene(C);
|
|
|
|
ip->owner = id;
|
|
|
|
ip->id = id;
|
2012-02-17 16:06:32 +00:00
|
|
|
|
|
|
|
icon_preview_add_size(ip, rect, sizex, sizey);
|
2011-01-02 19:46:32 +00:00
|
|
|
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
/* setup job */
|
2012-08-15 10:03:29 +00:00
|
|
|
WM_jobs_customdata_set(wm_job, ip, icon_preview_free);
|
2013-01-05 17:57:17 +00:00
|
|
|
WM_jobs_timer(wm_job, 0.1, NC_MATERIAL, NC_MATERIAL);
|
2012-08-15 10:03:29 +00:00
|
|
|
WM_jobs_callbacks(wm_job, icon_preview_startjob_all_sizes, NULL, NULL, icon_preview_endjob);
|
2010-02-22 10:29:49 +00:00
|
|
|
|
2012-08-15 10:03:29 +00:00
|
|
|
WM_jobs_start(CTX_wm_manager(C), wm_job);
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
}
|
|
|
|
|
2009-10-07 14:48:29 +00:00
|
|
|
void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, MTex *slot, int sizex, int sizey, int method)
|
2009-06-25 15:41:27 +00:00
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
Object *ob = CTX_data_active_object(C);
|
2012-08-15 10:03:29 +00:00
|
|
|
wmJob *wm_job;
|
2009-07-21 01:57:46 +00:00
|
|
|
ShaderPreview *sp;
|
2013-01-28 17:37:51 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2014-06-19 13:11:58 +06:00
|
|
|
short id_type = GS(id->name);
|
2014-06-25 15:36:45 +06:00
|
|
|
bool use_new_shading = BKE_scene_use_new_shading_nodes(scene);
|
|
|
|
|
|
|
|
/* Only texture node preview is supported with Cycles. */
|
|
|
|
if (use_new_shading && method == PR_NODE_RENDER && id_type != ID_TE) {
|
|
|
|
return;
|
|
|
|
}
|
2009-07-21 01:57:46 +00:00
|
|
|
|
2012-08-15 10:03:29 +00:00
|
|
|
wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Shader Preview",
|
2012-08-15 09:42:06 +00:00
|
|
|
WM_JOB_EXCL_RENDER, WM_JOB_TYPE_RENDER_PREVIEW);
|
2012-03-29 22:42:32 +00:00
|
|
|
sp = MEM_callocN(sizeof(ShaderPreview), "shader preview");
|
2009-09-28 18:33:45 +00:00
|
|
|
|
2009-06-25 15:41:27 +00:00
|
|
|
/* customdata for preview thread */
|
2013-01-28 17:37:51 +00:00
|
|
|
sp->scene = scene;
|
2012-03-29 22:42:32 +00:00
|
|
|
sp->owner = owner;
|
|
|
|
sp->sizex = sizex;
|
|
|
|
sp->sizey = sizey;
|
|
|
|
sp->pr_method = method;
|
2009-06-25 15:41:27 +00:00
|
|
|
sp->id = id;
|
2012-03-29 22:42:32 +00:00
|
|
|
sp->parent = parent;
|
|
|
|
sp->slot = slot;
|
2013-01-28 17:37:51 +00:00
|
|
|
|
|
|
|
/* hardcoded preview .blend for cycles/internal, this should be solved
|
|
|
|
* once with custom preview .blend path for external engines */
|
2014-06-25 15:36:45 +06:00
|
|
|
if ((method != PR_NODE_RENDER) && id_type != ID_TE && use_new_shading) {
|
2013-03-15 22:55:10 +00:00
|
|
|
sp->pr_main = G_pr_main_cycles;
|
2014-06-19 13:11:58 +06:00
|
|
|
}
|
|
|
|
else {
|
2013-03-15 22:55:10 +00:00
|
|
|
sp->pr_main = G_pr_main;
|
2014-06-19 13:11:58 +06:00
|
|
|
}
|
2013-01-28 17:37:51 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob && ob->totcol) copy_v4_v4(sp->col, ob->col);
|
2012-03-29 22:42:32 +00:00
|
|
|
else sp->col[0] = sp->col[1] = sp->col[2] = sp->col[3] = 1.0f;
|
2009-06-25 15:41:27 +00:00
|
|
|
|
2009-09-28 18:33:45 +00:00
|
|
|
/* setup job */
|
2012-08-15 10:03:29 +00:00
|
|
|
WM_jobs_customdata_set(wm_job, sp, shader_preview_free);
|
|
|
|
WM_jobs_timer(wm_job, 0.1, NC_MATERIAL, NC_MATERIAL);
|
|
|
|
WM_jobs_callbacks(wm_job, common_preview_startjob, NULL, shader_preview_updatejob, NULL);
|
2009-09-28 18:33:45 +00:00
|
|
|
|
2012-08-15 10:03:29 +00:00
|
|
|
WM_jobs_start(CTX_wm_manager(C), wm_job);
|
2009-06-25 15:41:27 +00:00
|
|
|
}
|
|
|
|
|
2014-11-18 15:51:31 +01:00
|
|
|
void ED_preview_kill_jobs(wmWindowManager *wm, Main *bmain)
|
2010-07-04 19:58:52 +00:00
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (wm)
|
2010-07-04 19:58:52 +00:00
|
|
|
WM_jobs_kill(wm, NULL, common_preview_startjob);
|
2014-11-18 15:51:31 +01:00
|
|
|
|
|
|
|
ED_viewport_render_kill_jobs(wm, bmain, false);
|
2010-07-04 19:58:52 +00:00
|
|
|
}
|
2009-06-25 15:41:27 +00:00
|
|
|
|