2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2010-03-08 16:36:53 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/render/render_opengl.c
|
|
|
|
* \ingroup edrend
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-03-08 16:36:53 +00:00
|
|
|
#include <math.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
#include <GL/glew.h>
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "BLI_math.h"
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_dlrbTree.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2012-01-12 17:04:09 +00:00
|
|
|
#include "BLI_jitter.h"
|
2010-03-08 16:36:53 +00:00
|
|
|
|
|
|
|
#include "DNA_scene_types.h"
|
2010-05-23 10:47:19 +00:00
|
|
|
#include "DNA_object_types.h"
|
2013-01-05 15:33:18 +00:00
|
|
|
#include "DNA_world_types.h"
|
2010-03-08 16:36:53 +00:00
|
|
|
|
|
|
|
#include "BKE_context.h"
|
2012-01-13 06:59:16 +00:00
|
|
|
#include "BKE_global.h"
|
2010-03-08 16:36:53 +00:00
|
|
|
#include "BKE_image.h"
|
|
|
|
#include "BKE_main.h"
|
|
|
|
#include "BKE_report.h"
|
|
|
|
#include "BKE_scene.h"
|
2012-03-29 23:33:50 +00:00
|
|
|
#include "BKE_sequencer.h"
|
2010-03-08 16:36:53 +00:00
|
|
|
#include "BKE_writeavi.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "ED_screen.h"
|
|
|
|
#include "ED_view3d.h"
|
2010-06-25 11:53:52 +00:00
|
|
|
#include "ED_image.h"
|
2010-03-08 16:36:53 +00:00
|
|
|
|
|
|
|
#include "RE_pipeline.h"
|
|
|
|
#include "IMB_imbuf_types.h"
|
2010-05-23 10:47:19 +00:00
|
|
|
#include "IMB_imbuf.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 "IMB_colormanagement.h"
|
2010-03-08 16:36:53 +00:00
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
2013-04-02 17:28:37 +00:00
|
|
|
#include "BIF_gl.h"
|
|
|
|
#include "BIF_glutil.h"
|
2010-03-08 16:36:53 +00:00
|
|
|
|
|
|
|
#include "GPU_extensions.h"
|
|
|
|
|
|
|
|
#include "wm_window.h"
|
|
|
|
|
|
|
|
#include "render_intern.h"
|
|
|
|
|
|
|
|
typedef struct OGLRender {
|
2011-11-20 14:38:11 +00:00
|
|
|
Main *bmain;
|
2010-03-08 16:36:53 +00:00
|
|
|
Render *re;
|
|
|
|
Scene *scene;
|
|
|
|
|
|
|
|
View3D *v3d;
|
|
|
|
RegionView3D *rv3d;
|
|
|
|
ARegion *ar;
|
|
|
|
|
2012-01-13 15:35:36 +00:00
|
|
|
ScrArea *prevsa;
|
|
|
|
ARegion *prevar;
|
|
|
|
|
2012-01-09 03:16:30 +00:00
|
|
|
short obcenter_dia_back; /* temp overwrite */
|
|
|
|
|
2014-01-28 03:52:21 +11:00
|
|
|
bool is_sequencer;
|
2012-03-29 23:33:50 +00:00
|
|
|
SpaceSeq *sseq;
|
|
|
|
|
|
|
|
|
2010-03-08 16:36:53 +00:00
|
|
|
Image *ima;
|
|
|
|
ImageUser iuser;
|
|
|
|
|
|
|
|
GPUOffScreen *ofs;
|
|
|
|
int sizex, sizey;
|
2010-11-16 15:15:20 +00:00
|
|
|
int write_still;
|
2010-03-08 16:36:53 +00:00
|
|
|
|
|
|
|
ReportList *reports;
|
|
|
|
bMovieHandle *mh;
|
|
|
|
int cfrao, nfra;
|
|
|
|
|
2013-07-17 09:57:02 +00:00
|
|
|
/* wm vars for timer and progress cursor */
|
|
|
|
wmWindowManager *wm;
|
|
|
|
wmWindow *win;
|
|
|
|
|
2010-03-08 16:36:53 +00:00
|
|
|
wmTimer *timer; /* use to check if running modal or not (invoke'd or exec'd)*/
|
|
|
|
} OGLRender;
|
|
|
|
|
2010-05-23 10:47:19 +00:00
|
|
|
/* added because v3d is not always valid */
|
|
|
|
static unsigned int screen_opengl_layers(OGLRender *oglrender)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (oglrender->v3d) {
|
2010-05-23 10:47:19 +00:00
|
|
|
return oglrender->scene->lay | oglrender->v3d->lay;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return oglrender->scene->lay;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-08 16:36:53 +00:00
|
|
|
static void screen_opengl_render_apply(OGLRender *oglrender)
|
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
Scene *scene = oglrender->scene;
|
|
|
|
ARegion *ar = oglrender->ar;
|
|
|
|
View3D *v3d = oglrender->v3d;
|
|
|
|
RegionView3D *rv3d = oglrender->rv3d;
|
2010-03-08 16:36:53 +00:00
|
|
|
RenderResult *rr;
|
2012-03-29 22:42:32 +00:00
|
|
|
Object *camera = NULL;
|
2010-03-08 16:36:53 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
void *lock;
|
|
|
|
float winmat[4][4];
|
2012-03-29 22:42:32 +00:00
|
|
|
int sizex = oglrender->sizex;
|
|
|
|
int sizey = oglrender->sizey;
|
|
|
|
const short view_context = (v3d != NULL);
|
2013-04-11 15:15:06 +00:00
|
|
|
bool draw_bgpic = true;
|
|
|
|
bool draw_sky = (scene->r.alphamode == R_ADDSKY);
|
|
|
|
unsigned char *rect = NULL;
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
rr = RE_AcquireResultRead(oglrender->re);
|
2012-03-29 23:33:50 +00:00
|
|
|
|
|
|
|
if (oglrender->is_sequencer) {
|
|
|
|
SeqRenderData context;
|
|
|
|
int chanshown = oglrender->sseq ? oglrender->sseq->chanshown : 0;
|
|
|
|
|
2013-12-26 17:24:42 +06:00
|
|
|
context = BKE_sequencer_new_render_data(oglrender->bmain->eval_ctx, oglrender->bmain,
|
|
|
|
scene, oglrender->sizex, oglrender->sizey, 100.0f);
|
2012-03-29 23:33:50 +00:00
|
|
|
|
2014-01-19 00:16:19 +06:00
|
|
|
ibuf = BKE_sequencer_give_ibuf(&context, CFRA, chanshown);
|
2012-03-29 23:33:50 +00:00
|
|
|
|
|
|
|
if (ibuf) {
|
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
|
|
|
ImBuf *linear_ibuf;
|
|
|
|
|
2012-03-29 23:33:50 +00:00
|
|
|
BLI_assert((oglrender->sizex == ibuf->x) && (oglrender->sizey == ibuf->y));
|
|
|
|
|
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
|
|
|
linear_ibuf = IMB_dupImBuf(ibuf);
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
|
|
|
|
if (linear_ibuf->rect_float == NULL) {
|
|
|
|
/* internally sequencer working in display space and stores both bytes and float buffers in that space.
|
|
|
|
* It is possible that byte->float onversion didn't happen in sequencer (e.g. when adding image sequence/movie
|
|
|
|
* into sequencer) there'll be only byte buffer. Create float buffer from existing byte buffer, making it linear
|
|
|
|
*/
|
|
|
|
|
|
|
|
IMB_float_from_rect(linear_ibuf);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* ensure float buffer is in linear space, not in display space */
|
|
|
|
BKE_sequencer_imbuf_from_sequencer_space(scene, linear_ibuf);
|
2012-03-29 23:33:50 +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
|
|
|
memcpy(rr->rectf, linear_ibuf->rect_float, sizeof(float) * 4 * oglrender->sizex * oglrender->sizey);
|
|
|
|
|
|
|
|
IMB_freeImBuf(linear_ibuf);
|
2012-03-29 23:33:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (view_context) {
|
2012-10-23 12:25:08 +00:00
|
|
|
ED_view3d_draw_offscreen_init(scene, v3d);
|
|
|
|
|
2010-05-23 10:47:19 +00:00
|
|
|
GPU_offscreen_bind(oglrender->ofs); /* bind */
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2010-05-23 10:47:19 +00:00
|
|
|
/* render 3d view */
|
2012-03-29 22:42:32 +00:00
|
|
|
if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
|
2012-10-23 03:38:26 +00:00
|
|
|
/*int is_ortho = scene->r.mode & R_ORTHO;*/
|
2012-03-29 22:42:32 +00:00
|
|
|
camera = v3d->camera;
|
2011-04-30 05:26:09 +00:00
|
|
|
RE_GetCameraWindow(oglrender->re, camera, scene->r.cfra, winmat);
|
2010-10-02 17:10:28 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rctf viewplane;
|
|
|
|
float clipsta, clipend;
|
2011-01-13 04:53:55 +00:00
|
|
|
|
2013-05-25 11:52:52 +00:00
|
|
|
int is_ortho = ED_view3d_viewplane_get(v3d, rv3d, sizex, sizey, &viewplane, &clipsta, &clipend, NULL);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (is_ortho) orthographic_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, -clipend, clipend);
|
2012-03-29 22:42:32 +00:00
|
|
|
else perspective_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend);
|
2010-10-02 17:10:28 +00:00
|
|
|
}
|
|
|
|
|
2013-04-11 15:15:06 +00:00
|
|
|
rect = MEM_mallocN(sizex * sizey * sizeof(unsigned char) * 4, "offscreen rect");
|
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
if ((scene->r.mode & R_OSA) == 0) {
|
2013-04-11 15:15:06 +00:00
|
|
|
ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat, draw_bgpic, draw_sky);
|
|
|
|
GPU_offscreen_read_pixels(oglrender->ofs, GL_UNSIGNED_BYTE, rect);
|
2010-05-23 10:47:19 +00:00
|
|
|
}
|
|
|
|
else {
|
2010-10-02 17:10:28 +00:00
|
|
|
/* simple accumulation, less hassle then FSAA FBO's */
|
2012-01-12 17:04:09 +00:00
|
|
|
static float jit_ofs[32][2];
|
2010-10-02 17:10:28 +00:00
|
|
|
float winmat_jitter[4][4];
|
2013-04-11 15:21:03 +00:00
|
|
|
int *accum_buffer = MEM_mallocN(sizex * sizey * sizeof(int) * 4, "accum1");
|
2013-04-11 15:15:06 +00:00
|
|
|
int i, j;
|
2010-10-02 17:10:28 +00:00
|
|
|
|
2012-05-05 00:23:55 +00:00
|
|
|
BLI_jitter_init(jit_ofs[0], scene->r.osa);
|
2012-01-12 17:04:09 +00:00
|
|
|
|
2010-10-02 17:10:28 +00:00
|
|
|
/* first sample buffer, also initializes 'rv3d->persmat' */
|
2013-04-11 15:15:06 +00:00
|
|
|
ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat, draw_bgpic, draw_sky);
|
|
|
|
GPU_offscreen_read_pixels(oglrender->ofs, GL_UNSIGNED_BYTE, rect);
|
|
|
|
|
|
|
|
for (i = 0; i < sizex * sizey * 4; i++)
|
|
|
|
accum_buffer[i] = rect[i];
|
2010-10-02 17:10:28 +00:00
|
|
|
|
|
|
|
/* skip the first sample */
|
2012-03-29 22:42:32 +00:00
|
|
|
for (j = 1; j < scene->r.osa; j++) {
|
2010-10-02 17:10:28 +00:00
|
|
|
copy_m4_m4(winmat_jitter, winmat);
|
2012-01-12 17:04:09 +00:00
|
|
|
window_translate_m4(winmat_jitter, rv3d->persmat,
|
|
|
|
(jit_ofs[j][0] * 2.0f) / sizex,
|
|
|
|
(jit_ofs[j][1] * 2.0f) / sizey);
|
2010-10-02 17:10:28 +00:00
|
|
|
|
2013-04-11 15:15:06 +00:00
|
|
|
ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat_jitter, draw_bgpic, draw_sky);
|
|
|
|
GPU_offscreen_read_pixels(oglrender->ofs, GL_UNSIGNED_BYTE, rect);
|
|
|
|
|
|
|
|
for (i = 0; i < sizex * sizey * 4; i++)
|
|
|
|
accum_buffer[i] += rect[i];
|
2010-10-02 17:10:28 +00:00
|
|
|
}
|
|
|
|
|
2013-04-11 15:15:06 +00:00
|
|
|
for (i = 0; i < sizex * sizey * 4; i++)
|
|
|
|
rect[i] = accum_buffer[i] / scene->r.osa;
|
2010-10-02 17:10:28 +00:00
|
|
|
|
|
|
|
MEM_freeN(accum_buffer);
|
2010-05-23 10:47:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GPU_offscreen_unbind(oglrender->ofs); /* unbind */
|
2010-03-08 16:36:53 +00:00
|
|
|
}
|
2010-05-23 10:47:19 +00:00
|
|
|
else {
|
2011-03-06 23:12:12 +00:00
|
|
|
/* shouldnt suddenly give errors mid-render but possible */
|
2012-03-29 22:42:32 +00:00
|
|
|
char err_out[256] = "unknown";
|
2013-01-05 15:33:18 +00:00
|
|
|
ImBuf *ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, oglrender->sizex, oglrender->sizey,
|
2013-04-11 15:15:06 +00:00
|
|
|
IB_rect, OB_SOLID, FALSE, TRUE,
|
2014-01-12 22:27:55 +11:00
|
|
|
(draw_sky) ? R_ADDSKY : R_ALPHAPREMUL, err_out);
|
2012-03-29 22:42:32 +00:00
|
|
|
camera = scene->camera;
|
2011-03-06 23:12:12 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ibuf_view) {
|
2013-04-11 15:15:06 +00:00
|
|
|
/* steal rect reference from ibuf */
|
2013-04-12 00:50:40 +00:00
|
|
|
rect = (unsigned char *)ibuf_view->rect;
|
2013-04-11 15:15:06 +00:00
|
|
|
ibuf_view->mall &= ~IB_rect;
|
|
|
|
|
2011-03-06 23:12:12 +00:00
|
|
|
IMB_freeImBuf(ibuf_view);
|
|
|
|
}
|
|
|
|
else {
|
2012-03-29 23:33:50 +00:00
|
|
|
fprintf(stderr, "%s: failed to get buffer, %s\n", __func__, err_out);
|
2011-03-06 23:12:12 +00:00
|
|
|
}
|
2010-05-23 10:47:19 +00:00
|
|
|
}
|
2013-01-05 15:33:18 +00:00
|
|
|
|
2011-11-29 22:37:16 +00:00
|
|
|
/* note on color management:
|
|
|
|
*
|
|
|
|
* OpenGL renders into sRGB colors, but render buffers are expected to be
|
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
|
|
|
* linear So we convert to linear here, so the conversion back to bytes can make it
|
|
|
|
* sRGB (or other display space) again, and so that e.g. openexr saving also saves the
|
|
|
|
* correct linear float buffer.
|
|
|
|
*/
|
2011-11-29 22:37:16 +00:00
|
|
|
|
2013-04-11 15:15:06 +00:00
|
|
|
if (rect) {
|
2013-06-24 23:24:39 +00:00
|
|
|
int profile_to;
|
|
|
|
|
2013-06-25 10:44:30 +00:00
|
|
|
if (BKE_scene_check_color_management_enabled(scene))
|
2013-06-24 23:24:39 +00:00
|
|
|
profile_to = IB_PROFILE_LINEAR_RGB;
|
|
|
|
else
|
|
|
|
profile_to = IB_PROFILE_SRGB;
|
|
|
|
|
2013-04-02 17:28:37 +00:00
|
|
|
/* sequencer has got trickier conversion happened above
|
2013-04-11 15:15:06 +00:00
|
|
|
* also assume opengl's space matches byte buffer color space */
|
|
|
|
IMB_buffer_float_from_byte(rr->rectf, rect,
|
2013-06-24 23:24:39 +00:00
|
|
|
profile_to, IB_PROFILE_SRGB, true,
|
2013-04-12 00:50:40 +00:00
|
|
|
oglrender->sizex, oglrender->sizey, oglrender->sizex, oglrender->sizex);
|
2011-11-29 22:37:16 +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
|
|
|
/* rr->rectf is now filled with image data */
|
|
|
|
|
|
|
|
if ((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW))
|
2013-04-11 15:15:06 +00:00
|
|
|
BKE_stamp_buf(scene, camera, rect, rr->rectf, rr->rectx, rr->recty, 4);
|
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
|
|
|
|
2010-03-08 16:36:53 +00:00
|
|
|
RE_ReleaseResult(oglrender->re);
|
|
|
|
|
|
|
|
/* update byte from float buffer */
|
2012-03-29 22:42:32 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock);
|
2010-11-16 15:15:20 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ibuf) {
|
2013-12-18 15:20:07 +06:00
|
|
|
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
|
2013-04-11 15:15:06 +00:00
|
|
|
|
|
|
|
/* write file for animation */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (oglrender->write_still) {
|
2010-11-16 15:15:20 +00:00
|
|
|
char name[FILE_MAX];
|
|
|
|
int ok;
|
2011-06-24 03:49:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scene->r.im_format.planes == R_IMF_CHAN_DEPTH_8) {
|
2011-06-24 03:49:56 +00:00
|
|
|
IMB_color_to_bw(ibuf);
|
|
|
|
}
|
|
|
|
|
2012-12-23 13:57:09 +00:00
|
|
|
BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, &scene->r.im_format, scene->r.scemode & R_EXTENSION, FALSE);
|
2012-05-05 16:03:57 +00:00
|
|
|
ok = BKE_imbuf_write_as(ibuf, name, &scene->r.im_format, TRUE); /* no need to stamp here */
|
2012-03-29 22:42:32 +00:00
|
|
|
if (ok) printf("OpenGL Render written to '%s'\n", name);
|
|
|
|
else printf("OpenGL Render failed to write '%s'\n", name);
|
2010-11-16 15:15:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_image_release_ibuf(oglrender->ima, ibuf, lock);
|
2013-04-11 15:15:06 +00:00
|
|
|
|
|
|
|
if (rect)
|
|
|
|
MEM_freeN(rect);
|
2010-03-08 16:36:53 +00:00
|
|
|
}
|
|
|
|
|
2014-01-28 03:52:21 +11:00
|
|
|
static bool screen_opengl_render_init(bContext *C, wmOperator *op)
|
2010-03-08 16:36:53 +00:00
|
|
|
{
|
|
|
|
/* new render clears all callbacks */
|
2013-07-17 09:57:02 +00:00
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
ScrArea *prevsa = CTX_wm_area(C);
|
|
|
|
ARegion *prevar = CTX_wm_region(C);
|
2010-03-08 16:36:53 +00:00
|
|
|
RenderResult *rr;
|
|
|
|
GPUOffScreen *ofs;
|
|
|
|
OGLRender *oglrender;
|
|
|
|
int sizex, sizey;
|
2014-01-28 03:52:21 +11:00
|
|
|
bool is_view_context = RNA_boolean_get(op->ptr, "view_context");
|
|
|
|
const bool is_animation = RNA_boolean_get(op->ptr, "animation");
|
|
|
|
const bool is_sequencer = RNA_boolean_get(op->ptr, "sequencer");
|
|
|
|
const bool is_write_still = RNA_boolean_get(op->ptr, "write_still");
|
2012-03-29 22:42:32 +00:00
|
|
|
char err_out[256] = "unknown";
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (G.background) {
|
2012-10-26 17:32:50 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Cannot use OpenGL render in background mode (no opengl context)");
|
2014-01-28 03:52:21 +11:00
|
|
|
return false;
|
2012-01-13 06:59:16 +00:00
|
|
|
}
|
|
|
|
|
2010-03-08 16:36:53 +00:00
|
|
|
/* ensure we have a 3d view */
|
2010-11-16 15:15:20 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!ED_view3d_context_activate(C)) {
|
2012-01-16 16:12:03 +00:00
|
|
|
RNA_boolean_set(op->ptr, "view_context", FALSE);
|
2014-01-28 03:52:21 +11:00
|
|
|
is_view_context = false;
|
2010-05-23 10:47:19 +00:00
|
|
|
}
|
2010-03-08 16:36:53 +00:00
|
|
|
|
|
|
|
/* only one render job at a time */
|
2013-07-17 09:57:02 +00:00
|
|
|
if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER))
|
2014-01-28 03:52:21 +11:00
|
|
|
return false;
|
2010-05-23 10:47:19 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (!is_view_context && scene->camera == NULL) {
|
2011-09-19 12:26:20 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Scene has no camera");
|
2014-01-28 03:52:21 +11:00
|
|
|
return false;
|
2010-05-23 10:47:19 +00:00
|
|
|
}
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) {
|
2012-10-26 17:32:50 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Cannot write a single file with an animation format selected");
|
2014-01-28 03:52:21 +11:00
|
|
|
return false;
|
2010-11-16 15:15:20 +00:00
|
|
|
}
|
|
|
|
|
2012-10-29 17:41:19 +00:00
|
|
|
/* stop all running jobs, except screen one. currently previews frustrate Render */
|
2013-07-17 09:57:02 +00:00
|
|
|
WM_jobs_kill_all_except(wm, CTX_wm_screen(C));
|
2010-03-08 16:36:53 +00:00
|
|
|
|
|
|
|
/* create offscreen buffer */
|
2012-03-29 22:42:32 +00:00
|
|
|
sizex = (scene->r.size * scene->r.xsch) / 100;
|
|
|
|
sizey = (scene->r.size * scene->r.ysch) / 100;
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2010-12-16 19:05:47 +00:00
|
|
|
/* corrects render size with actual size, not every card supports non-power-of-two dimensions */
|
2012-03-29 22:42:32 +00:00
|
|
|
ofs = GPU_offscreen_create(sizex, sizey, err_out);
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!ofs) {
|
2012-10-13 13:40:05 +00:00
|
|
|
BKE_reportf(op->reports, RPT_ERROR, "Failed to create OpenGL off-screen buffer, %s", err_out);
|
2014-01-28 03:52:21 +11:00
|
|
|
return false;
|
2010-03-08 16:36:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate opengl render */
|
2012-03-29 22:42:32 +00:00
|
|
|
oglrender = MEM_callocN(sizeof(OGLRender), "OGLRender");
|
|
|
|
op->customdata = oglrender;
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
oglrender->ofs = ofs;
|
|
|
|
oglrender->sizex = sizex;
|
|
|
|
oglrender->sizey = sizey;
|
|
|
|
oglrender->bmain = CTX_data_main(C);
|
|
|
|
oglrender->scene = scene;
|
|
|
|
oglrender->cfrao = scene->r.cfra;
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
oglrender->write_still = is_write_still && !is_animation;
|
2010-11-16 15:15:20 +00:00
|
|
|
|
2012-03-29 23:33:50 +00:00
|
|
|
oglrender->is_sequencer = is_sequencer;
|
|
|
|
if (is_sequencer) {
|
2012-04-29 15:47:02 +00:00
|
|
|
oglrender->sseq = CTX_wm_space_seq(C);
|
2012-03-29 23:33:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-09 03:16:30 +00:00
|
|
|
oglrender->obcenter_dia_back = U.obcenter_dia;
|
|
|
|
U.obcenter_dia = 0;
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
oglrender->prevsa = prevsa;
|
|
|
|
oglrender->prevar = prevar;
|
2012-01-13 15:35:36 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (is_view_context) {
|
2012-01-14 12:24:25 +00:00
|
|
|
ED_view3d_context_user_region(C, &oglrender->v3d, &oglrender->ar); /* so quad view renders camera */
|
2012-03-29 22:42:32 +00:00
|
|
|
oglrender->rv3d = oglrender->ar->regiondata;
|
2011-03-13 02:44:25 +00:00
|
|
|
|
|
|
|
/* MUST be cleared on exit */
|
2013-05-01 14:34:12 +00:00
|
|
|
oglrender->scene->customdata_mask_modal = ED_view3d_datamask(oglrender->scene, oglrender->v3d);
|
2012-01-09 02:50:09 +00:00
|
|
|
|
2012-03-09 00:41:09 +00:00
|
|
|
/* apply immediately in case we're rendering from a script,
|
2012-01-09 02:50:09 +00:00
|
|
|
* running notifiers again will overwrite */
|
|
|
|
oglrender->scene->customdata_mask |= oglrender->scene->customdata_mask_modal;
|
|
|
|
|
2010-05-23 10:47:19 +00:00
|
|
|
}
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2011-11-29 22:37:16 +00:00
|
|
|
/* create render */
|
2012-03-29 22:42:32 +00:00
|
|
|
oglrender->re = RE_NewRender(scene->id.name);
|
2011-11-29 22:37:16 +00:00
|
|
|
|
2010-03-08 16:36:53 +00:00
|
|
|
/* create image and image user */
|
2012-03-29 22:42:32 +00:00
|
|
|
oglrender->ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
|
2010-03-08 16:36:53 +00:00
|
|
|
BKE_image_signal(oglrender->ima, NULL, IMA_SIGNAL_FREE);
|
2011-11-29 22:37:16 +00:00
|
|
|
BKE_image_backup_render(oglrender->scene, oglrender->ima);
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
oglrender->iuser.scene = scene;
|
|
|
|
oglrender->iuser.ok = 1;
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2011-11-29 22:37:16 +00:00
|
|
|
/* create render result */
|
2010-03-08 16:36:53 +00:00
|
|
|
RE_InitState(oglrender->re, NULL, &scene->r, NULL, sizex, sizey, NULL);
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
rr = RE_AcquireResultWrite(oglrender->re);
|
|
|
|
if (rr->rectf == NULL)
|
|
|
|
rr->rectf = MEM_callocN(sizeof(float) * 4 * sizex * sizey, "screen_opengl_render_init rect");
|
2010-03-08 16:36:53 +00:00
|
|
|
RE_ReleaseResult(oglrender->re);
|
|
|
|
|
2013-07-17 09:57:02 +00:00
|
|
|
/* wm vars */
|
|
|
|
oglrender->wm = wm;
|
|
|
|
oglrender->win = win;
|
|
|
|
|
2014-01-28 03:52:21 +11:00
|
|
|
return true;
|
2010-03-08 16:36:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void screen_opengl_render_end(bContext *C, OGLRender *oglrender)
|
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = oglrender->scene;
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (oglrender->mh) {
|
|
|
|
if (BKE_imtype_is_movie(scene->r.im_format.imtype))
|
2010-03-08 16:36:53 +00:00
|
|
|
oglrender->mh->end_movie();
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (oglrender->timer) { /* exec will not have a timer */
|
2012-03-29 22:42:32 +00:00
|
|
|
scene->r.cfra = oglrender->cfrao;
|
2013-12-26 17:24:42 +06:00
|
|
|
BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene, screen_opengl_layers(oglrender));
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2013-07-17 09:57:02 +00:00
|
|
|
WM_event_remove_timer(oglrender->wm, oglrender->win, oglrender->timer);
|
|
|
|
}
|
|
|
|
|
2013-09-06 22:34:29 +00:00
|
|
|
WM_cursor_modal_restore(oglrender->win);
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, oglrender->scene);
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-01-09 03:16:30 +00:00
|
|
|
U.obcenter_dia = oglrender->obcenter_dia_back;
|
|
|
|
|
2010-03-08 16:36:53 +00:00
|
|
|
GPU_offscreen_free(oglrender->ofs);
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
oglrender->scene->customdata_mask_modal = 0;
|
2011-03-13 02:44:25 +00:00
|
|
|
|
2012-01-13 15:35:36 +00:00
|
|
|
CTX_wm_area_set(C, oglrender->prevsa);
|
|
|
|
CTX_wm_region_set(C, oglrender->prevar);
|
|
|
|
|
2010-03-08 16:36:53 +00:00
|
|
|
MEM_freeN(oglrender);
|
|
|
|
}
|
|
|
|
|
2013-10-30 23:08:53 +00:00
|
|
|
static void screen_opengl_render_cancel(bContext *C, wmOperator *op)
|
2010-03-08 16:36:53 +00:00
|
|
|
{
|
|
|
|
screen_opengl_render_end(C, op->customdata);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* share between invoke and exec */
|
|
|
|
static int screen_opengl_render_anim_initialize(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
/* initialize animation */
|
|
|
|
OGLRender *oglrender;
|
|
|
|
Scene *scene;
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
oglrender = op->customdata;
|
|
|
|
scene = oglrender->scene;
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
oglrender->reports = op->reports;
|
2012-05-07 09:30:15 +00:00
|
|
|
oglrender->mh = BKE_movie_handle_get(scene->r.im_format.imtype);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (BKE_imtype_is_movie(scene->r.im_format.imtype)) {
|
|
|
|
if (!oglrender->mh->start_movie(scene, &scene->r, oglrender->sizex, oglrender->sizey, oglrender->reports)) {
|
2010-03-08 16:36:53 +00:00
|
|
|
screen_opengl_render_end(C, oglrender);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
oglrender->cfrao = scene->r.cfra;
|
|
|
|
oglrender->nfra = PSFRA;
|
|
|
|
scene->r.cfra = PSFRA;
|
2010-03-08 16:36:53 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2013-09-30 08:21:12 +00:00
|
|
|
static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op)
|
2010-03-08 16:36:53 +00:00
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
OGLRender *oglrender = op->customdata;
|
|
|
|
Scene *scene = oglrender->scene;
|
2012-12-04 09:07:44 +00:00
|
|
|
ImBuf *ibuf, *ibuf_save = NULL;
|
2010-03-08 16:36:53 +00:00
|
|
|
void *lock;
|
2011-11-26 04:07:38 +00:00
|
|
|
char name[FILE_MAX];
|
2012-03-29 22:42:32 +00:00
|
|
|
int ok = 0;
|
|
|
|
const short view_context = (oglrender->v3d != NULL);
|
|
|
|
Object *camera = NULL;
|
2012-07-27 08:58:34 +00:00
|
|
|
int is_movie;
|
2010-03-08 16:36:53 +00:00
|
|
|
|
|
|
|
/* go to next frame */
|
2012-07-07 22:51:57 +00:00
|
|
|
if (CFRA < oglrender->nfra)
|
|
|
|
CFRA++;
|
2012-03-29 22:42:32 +00:00
|
|
|
while (CFRA < oglrender->nfra) {
|
|
|
|
unsigned int lay = screen_opengl_layers(oglrender);
|
2010-05-20 15:18:55 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lay & 0xFF000000)
|
2010-05-20 15:18:55 +00:00
|
|
|
lay &= 0xFF000000;
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2013-12-26 17:24:42 +06:00
|
|
|
BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene, lay);
|
2010-03-08 16:36:53 +00:00
|
|
|
CFRA++;
|
|
|
|
}
|
|
|
|
|
2012-07-27 08:58:34 +00:00
|
|
|
is_movie = BKE_imtype_is_movie(scene->r.im_format.imtype);
|
|
|
|
|
|
|
|
if (!is_movie) {
|
2012-12-23 13:57:09 +00:00
|
|
|
BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, &scene->r.im_format, scene->r.scemode & R_EXTENSION, TRUE);
|
2012-07-27 08:58:34 +00:00
|
|
|
|
|
|
|
if ((scene->r.mode & R_NO_OVERWRITE) && BLI_exists(name)) {
|
2013-09-30 08:21:12 +00:00
|
|
|
BKE_reportf(op->reports, RPT_INFO, "Skipping existing frame \"%s\"", name);
|
|
|
|
ok = true;
|
|
|
|
goto finally;
|
2012-07-27 08:58:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-31 09:18:40 +00:00
|
|
|
WM_cursor_time(oglrender->win, scene->r.cfra);
|
2013-07-17 09:57:02 +00:00
|
|
|
|
2013-12-26 17:24:42 +06:00
|
|
|
BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene, screen_opengl_layers(oglrender));
|
2010-05-23 10:47:19 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (view_context) {
|
2012-03-29 22:42:32 +00:00
|
|
|
if (oglrender->rv3d->persp == RV3D_CAMOB && oglrender->v3d->camera && oglrender->v3d->scenelock) {
|
2012-05-05 14:33:36 +00:00
|
|
|
/* since BKE_scene_update_for_newframe() is used rather
|
2010-05-23 10:47:19 +00:00
|
|
|
* then ED_update_for_newframe() the camera needs to be set */
|
2012-05-05 14:33:36 +00:00
|
|
|
if (BKE_scene_camera_switch_update(scene)) {
|
2012-03-29 22:42:32 +00:00
|
|
|
oglrender->v3d->camera = scene->camera;
|
2011-04-30 05:26:09 +00:00
|
|
|
}
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
camera = oglrender->v3d->camera;
|
2010-05-23 10:47:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-05-05 14:33:36 +00:00
|
|
|
BKE_scene_camera_switch_update(scene);
|
2011-04-30 05:26:09 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
camera = scene->camera;
|
2010-03-08 16:36:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* render into offscreen buffer */
|
|
|
|
screen_opengl_render_apply(oglrender);
|
|
|
|
|
|
|
|
/* save to disk */
|
2012-03-29 22:42:32 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock);
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ibuf) {
|
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
|
|
|
int needs_free = FALSE;
|
|
|
|
|
2012-12-04 09:07:44 +00:00
|
|
|
ibuf_save = ibuf;
|
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
|
|
|
|
2012-12-04 09:07:44 +00:00
|
|
|
if (is_movie || !BKE_imtype_requires_linear_float(scene->r.im_format.imtype)) {
|
2013-09-05 17:13:43 +00:00
|
|
|
ibuf_save = IMB_colormanagement_imbuf_for_write(ibuf, true, true, &scene->view_settings,
|
2012-12-04 09:07:44 +00:00
|
|
|
&scene->display_settings, &scene->r.im_format);
|
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
|
|
|
|
|
|
|
needs_free = TRUE;
|
|
|
|
}
|
|
|
|
|
2012-07-03 19:09:07 +00:00
|
|
|
/* color -> grayscale */
|
2011-06-24 03:49:56 +00:00
|
|
|
/* editing directly would alter the render view */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scene->r.im_format.planes == R_IMF_PLANES_BW) {
|
2012-12-04 09:07:44 +00:00
|
|
|
ImBuf *ibuf_bw = IMB_dupImBuf(ibuf_save);
|
2011-06-24 03:49:56 +00:00
|
|
|
IMB_color_to_bw(ibuf_bw);
|
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 (needs_free)
|
2012-12-04 09:07:44 +00:00
|
|
|
IMB_freeImBuf(ibuf_save);
|
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
|
|
|
|
2012-12-04 09:07:44 +00:00
|
|
|
ibuf_save = ibuf_bw;
|
2011-07-05 07:46:25 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* this is lightweight & doesnt re-alloc the buffers, only do this
|
|
|
|
* to save the correct bit depth since the image is always RGBA */
|
2012-12-04 09:07:44 +00:00
|
|
|
ImBuf *ibuf_cpy = IMB_allocImBuf(ibuf_save->x, ibuf_save->y, scene->r.im_format.planes, 0);
|
|
|
|
|
|
|
|
ibuf_cpy->rect = ibuf_save->rect;
|
|
|
|
ibuf_cpy->rect_float = ibuf_save->rect_float;
|
|
|
|
ibuf_cpy->zbuf_float = ibuf_save->zbuf_float;
|
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 (needs_free) {
|
2012-12-04 09:07:44 +00:00
|
|
|
ibuf_cpy->mall = ibuf_save->mall;
|
|
|
|
ibuf_save->mall = 0;
|
|
|
|
IMB_freeImBuf(ibuf_save);
|
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
|
|
|
}
|
|
|
|
|
2012-12-04 09:07:44 +00:00
|
|
|
ibuf_save = ibuf_cpy;
|
2011-06-24 03:49:56 +00:00
|
|
|
}
|
|
|
|
|
2012-07-27 08:58:34 +00:00
|
|
|
if (is_movie) {
|
2013-05-31 10:31:44 +00:00
|
|
|
ok = oglrender->mh->append_movie(&scene->r, PSFRA, CFRA, (int *)ibuf_save->rect,
|
2012-03-29 22:42:32 +00:00
|
|
|
oglrender->sizex, oglrender->sizey, oglrender->reports);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ok) {
|
2010-03-08 16:36:53 +00:00
|
|
|
printf("Append frame %d", scene->r.cfra);
|
|
|
|
BKE_reportf(op->reports, RPT_INFO, "Appended frame: %d", scene->r.cfra);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-12-04 09:07:44 +00:00
|
|
|
ok = BKE_imbuf_write_stamp(scene, camera, ibuf_save, name, &scene->r.im_format);
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (ok == 0) {
|
2010-03-08 16:36:53 +00:00
|
|
|
printf("Write error: cannot save %s\n", name);
|
|
|
|
BKE_reportf(op->reports, RPT_ERROR, "Write error: cannot save %s", name);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("Saved: %s", name);
|
|
|
|
BKE_reportf(op->reports, RPT_INFO, "Saved file: %s", name);
|
|
|
|
}
|
|
|
|
}
|
2011-06-24 03:49:56 +00:00
|
|
|
|
2012-12-04 09:07:44 +00:00
|
|
|
if (needs_free)
|
|
|
|
IMB_freeImBuf(ibuf_save);
|
2010-03-08 16:36:53 +00:00
|
|
|
}
|
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_image_release_ibuf(oglrender->ima, ibuf, lock);
|
2010-03-08 16:36:53 +00:00
|
|
|
|
|
|
|
/* movie stats prints have no line break */
|
|
|
|
printf("\n");
|
|
|
|
|
2013-09-30 08:21:12 +00:00
|
|
|
|
|
|
|
finally: /* Step the frame and bail early if needed */
|
|
|
|
|
2010-03-08 16:36:53 +00:00
|
|
|
/* go to next frame */
|
|
|
|
oglrender->nfra += scene->r.frame_step;
|
|
|
|
|
|
|
|
/* stop at the end or on error */
|
2012-07-07 22:51:57 +00:00
|
|
|
if (CFRA >= PEFRA || !ok) {
|
2010-03-08 16:36:53 +00:00
|
|
|
screen_opengl_render_end(C, op->customdata);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int screen_opengl_render_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
2010-03-08 16:36:53 +00:00
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
OGLRender *oglrender = op->customdata;
|
|
|
|
int anim = RNA_boolean_get(op->ptr, "animation");
|
2013-09-30 08:21:12 +00:00
|
|
|
bool ret;
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
switch (event->type) {
|
2010-03-08 16:36:53 +00:00
|
|
|
case ESCKEY:
|
|
|
|
/* cancel */
|
|
|
|
screen_opengl_render_end(C, op->customdata);
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
case TIMER:
|
|
|
|
/* render frame? */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (oglrender->timer == event->customdata)
|
2010-03-08 16:36:53 +00:00
|
|
|
break;
|
2013-08-06 02:47:47 +00:00
|
|
|
/* fall-through */
|
2010-03-08 16:36:53 +00:00
|
|
|
default:
|
|
|
|
/* nothing to do */
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
2010-07-01 11:58:48 +00:00
|
|
|
/* run first because screen_opengl_render_anim_step can free oglrender */
|
2012-03-29 22:42:32 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, oglrender->scene);
|
2010-07-01 11:58:48 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (anim == 0) {
|
2010-12-27 18:00:35 +00:00
|
|
|
screen_opengl_render_apply(op->customdata);
|
|
|
|
screen_opengl_render_end(C, op->customdata);
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
2013-09-30 08:21:12 +00:00
|
|
|
else {
|
2012-03-29 22:42:32 +00:00
|
|
|
ret = screen_opengl_render_anim_step(C, op);
|
2013-09-30 08:21:12 +00:00
|
|
|
}
|
2010-03-08 16:36:53 +00:00
|
|
|
|
|
|
|
/* stop at the end or on error */
|
2013-09-30 08:21:12 +00:00
|
|
|
if (ret == false) {
|
2010-03-08 16:36:53 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int screen_opengl_render_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2010-03-08 16:36:53 +00:00
|
|
|
{
|
2010-12-27 18:00:35 +00:00
|
|
|
OGLRender *oglrender;
|
2012-03-29 22:42:32 +00:00
|
|
|
int anim = RNA_boolean_get(op->ptr, "animation");
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!screen_opengl_render_init(C, op))
|
2010-03-08 16:36:53 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (anim) {
|
|
|
|
if (!screen_opengl_render_anim_initialize(C, op))
|
2010-03-08 16:36:53 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2010-12-27 18:00:35 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
oglrender = op->customdata;
|
2011-05-19 11:34:11 +00:00
|
|
|
render_view_open(C, event->x, event->y);
|
2010-12-27 18:00:35 +00:00
|
|
|
|
2013-07-22 23:44:46 +00:00
|
|
|
/* view may be changed above (R_OUTPUT_WINDOW) */
|
|
|
|
oglrender->win = CTX_wm_window(C);
|
|
|
|
|
2010-12-27 18:00:35 +00:00
|
|
|
WM_event_add_modal_handler(C, op);
|
2013-07-17 09:57:02 +00:00
|
|
|
oglrender->timer = WM_event_add_timer(oglrender->wm, oglrender->win, TIMER, 0.01f);
|
2010-12-27 18:00:35 +00:00
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
2010-03-08 16:36:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* executes blocking render */
|
|
|
|
static int screen_opengl_render_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
const short is_animation = RNA_boolean_get(op->ptr, "animation");
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!screen_opengl_render_init(C, op))
|
2010-03-08 16:36:53 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!is_animation) { /* same as invoke */
|
2010-03-08 16:36:53 +00:00
|
|
|
/* render image */
|
|
|
|
screen_opengl_render_apply(op->customdata);
|
|
|
|
screen_opengl_render_end(C, op->customdata);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
else {
|
2013-09-30 08:21:12 +00:00
|
|
|
bool ret = true;
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!screen_opengl_render_anim_initialize(C, op))
|
2010-03-08 16:36:53 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
while (ret) {
|
2012-03-29 22:42:32 +00:00
|
|
|
ret = screen_opengl_render_anim_step(C, op);
|
2010-03-08 16:36:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-20 20:20:02 +00:00
|
|
|
/* no redraw needed, we leave state as we entered it */
|
2010-03-08 16:36:53 +00:00
|
|
|
// ED_update_for_newframe(C, 1);
|
2012-03-29 22:42:32 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, CTX_data_scene(C));
|
2010-03-08 16:36:53 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RENDER_OT_opengl(wmOperatorType *ot)
|
|
|
|
{
|
2012-03-29 23:33:50 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2010-03-08 16:36:53 +00:00
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "OpenGL Render";
|
|
|
|
ot->description = "OpenGL render active viewport";
|
|
|
|
ot->idname = "RENDER_OT_opengl";
|
2010-03-08 16:36:53 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = screen_opengl_render_invoke;
|
|
|
|
ot->exec = screen_opengl_render_exec; /* blocking */
|
|
|
|
ot->modal = screen_opengl_render_modal;
|
|
|
|
ot->cancel = screen_opengl_render_cancel;
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_screenactive;
|
2010-03-08 16:36:53 +00:00
|
|
|
|
2012-03-29 23:33:50 +00:00
|
|
|
prop = RNA_def_boolean(ot->srna, "animation", 0, "Animation", "Render files from the animation range of this scene");
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2012-04-02 06:56:16 +00:00
|
|
|
prop = RNA_def_boolean(ot->srna, "sequencer", 0, "Sequencer", "Render using the sequencer's OpenGL display");
|
2012-03-29 23:33:50 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
|
|
|
prop = RNA_def_boolean(ot->srna, "write_still", 0, "Write Image", "Save rendered the image to the output path (used only when animation is disabled)");
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
|
|
|
prop = RNA_def_boolean(ot->srna, "view_context", 1, "View Context", "Use the current 3D view for rendering, else use scene settings");
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
|
|
|
|
2010-03-08 16:36:53 +00:00
|
|
|
}
|
2010-03-08 20:08:04 +00:00
|
|
|
|
|
|
|
/* function for getting an opengl buffer from a View3D, used by sequencer */
|
|
|
|
// extern void *sequencer_view3d_cb;
|