2022-02-10 23:07:11 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
* Copyright 2001-2002 NaN Holding BV. All rights reserved. */
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup imbuf
|
2011-02-27 21:23:21 +01:00
|
|
|
*/
|
|
|
|
|
2012-08-13 00:50:21 +02:00
|
|
|
#include <stdlib.h>
|
2011-02-27 21:23:21 +01:00
|
|
|
|
2013-04-25 16:16:22 +02:00
|
|
|
#include "BLI_math_base.h"
|
2012-08-13 00:50:21 +02:00
|
|
|
#include "BLI_math_color.h"
|
2013-04-27 14:51:23 +02:00
|
|
|
#include "BLI_math_color_blend.h"
|
2012-08-13 00:50:21 +02:00
|
|
|
#include "BLI_math_vector.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_rect.h"
|
|
|
|
#include "BLI_utildefines.h"
|
2002-10-12 13:37:38 +02:00
|
|
|
|
|
|
|
#include "IMB_imbuf.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "IMB_imbuf_types.h"
|
2002-10-12 13:37:38 +02: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 12:05:07 +02:00
|
|
|
#include "IMB_colormanagement.h"
|
2011-01-07 20:18:31 +01:00
|
|
|
|
2019-07-04 13:15:18 +02:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2013-04-28 13:55:41 +02:00
|
|
|
void IMB_blend_color_byte(unsigned char dst[4],
|
2019-09-25 09:11:00 +02:00
|
|
|
const unsigned char src1[4],
|
|
|
|
const unsigned char src2[4],
|
2013-04-28 13:55:41 +02:00
|
|
|
IMB_BlendMode mode)
|
2006-07-31 17:53:03 +02:00
|
|
|
{
|
|
|
|
switch (mode) {
|
|
|
|
case IMB_BLEND_MIX:
|
2013-04-28 13:55:41 +02:00
|
|
|
blend_color_mix_byte(dst, src1, src2);
|
|
|
|
break;
|
2006-07-31 17:53:03 +02:00
|
|
|
case IMB_BLEND_ADD:
|
2013-04-28 13:55:41 +02:00
|
|
|
blend_color_add_byte(dst, src1, src2);
|
|
|
|
break;
|
2006-07-31 17:53:03 +02:00
|
|
|
case IMB_BLEND_SUB:
|
2013-04-28 13:55:41 +02:00
|
|
|
blend_color_sub_byte(dst, src1, src2);
|
|
|
|
break;
|
2006-07-31 17:53:03 +02:00
|
|
|
case IMB_BLEND_MUL:
|
2013-04-28 13:55:41 +02:00
|
|
|
blend_color_mul_byte(dst, src1, src2);
|
|
|
|
break;
|
2006-07-31 17:53:03 +02:00
|
|
|
case IMB_BLEND_LIGHTEN:
|
2013-04-28 13:55:41 +02:00
|
|
|
blend_color_lighten_byte(dst, src1, src2);
|
|
|
|
break;
|
2006-07-31 17:53:03 +02:00
|
|
|
case IMB_BLEND_DARKEN:
|
2013-04-28 13:55:41 +02:00
|
|
|
blend_color_darken_byte(dst, src1, src2);
|
|
|
|
break;
|
2013-04-26 16:43:38 +02:00
|
|
|
case IMB_BLEND_ERASE_ALPHA:
|
2013-04-28 13:55:41 +02:00
|
|
|
blend_color_erase_alpha_byte(dst, src1, src2);
|
|
|
|
break;
|
2013-04-26 16:43:38 +02:00
|
|
|
case IMB_BLEND_ADD_ALPHA:
|
2013-04-28 13:55:41 +02:00
|
|
|
blend_color_add_alpha_byte(dst, src1, src2);
|
|
|
|
break;
|
2014-07-21 12:02:05 +02:00
|
|
|
case IMB_BLEND_OVERLAY:
|
|
|
|
blend_color_overlay_byte(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_HARDLIGHT:
|
|
|
|
blend_color_hardlight_byte(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_COLORBURN:
|
|
|
|
blend_color_burn_byte(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_LINEARBURN:
|
|
|
|
blend_color_linearburn_byte(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_COLORDODGE:
|
|
|
|
blend_color_dodge_byte(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_SCREEN:
|
|
|
|
blend_color_screen_byte(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_SOFTLIGHT:
|
|
|
|
blend_color_softlight_byte(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_PINLIGHT:
|
|
|
|
blend_color_pinlight_byte(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_LINEARLIGHT:
|
|
|
|
blend_color_linearlight_byte(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_VIVIDLIGHT:
|
|
|
|
blend_color_vividlight_byte(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_DIFFERENCE:
|
|
|
|
blend_color_difference_byte(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_EXCLUSION:
|
|
|
|
blend_color_exclusion_byte(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_COLOR:
|
|
|
|
blend_color_color_byte(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_HUE:
|
|
|
|
blend_color_hue_byte(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_SATURATION:
|
|
|
|
blend_color_saturation_byte(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_LUMINOSITY:
|
|
|
|
blend_color_luminosity_byte(dst, src1, src2);
|
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
default:
|
2013-04-28 13:55:41 +02:00
|
|
|
dst[0] = src1[0];
|
|
|
|
dst[1] = src1[1];
|
|
|
|
dst[2] = src1[2];
|
|
|
|
dst[3] = src1[3];
|
2013-04-26 16:43:38 +02:00
|
|
|
break;
|
2006-11-07 01:10:37 +01:00
|
|
|
}
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
|
2019-09-25 09:11:00 +02:00
|
|
|
void IMB_blend_color_float(float dst[4],
|
|
|
|
const float src1[4],
|
|
|
|
const float src2[4],
|
|
|
|
IMB_BlendMode mode)
|
2006-07-31 17:53:03 +02:00
|
|
|
{
|
|
|
|
switch (mode) {
|
|
|
|
case IMB_BLEND_MIX:
|
2013-04-28 13:55:41 +02:00
|
|
|
blend_color_mix_float(dst, src1, src2);
|
|
|
|
break;
|
2006-07-31 17:53:03 +02:00
|
|
|
case IMB_BLEND_ADD:
|
2013-04-28 13:55:41 +02:00
|
|
|
blend_color_add_float(dst, src1, src2);
|
|
|
|
break;
|
2006-07-31 17:53:03 +02:00
|
|
|
case IMB_BLEND_SUB:
|
2013-04-28 13:55:41 +02:00
|
|
|
blend_color_sub_float(dst, src1, src2);
|
|
|
|
break;
|
2006-07-31 17:53:03 +02:00
|
|
|
case IMB_BLEND_MUL:
|
2013-04-28 13:55:41 +02:00
|
|
|
blend_color_mul_float(dst, src1, src2);
|
|
|
|
break;
|
2006-07-31 17:53:03 +02:00
|
|
|
case IMB_BLEND_LIGHTEN:
|
2013-04-28 13:55:41 +02:00
|
|
|
blend_color_lighten_float(dst, src1, src2);
|
|
|
|
break;
|
2006-07-31 17:53:03 +02:00
|
|
|
case IMB_BLEND_DARKEN:
|
2013-04-28 13:55:41 +02:00
|
|
|
blend_color_darken_float(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_ERASE_ALPHA:
|
|
|
|
blend_color_erase_alpha_float(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_ADD_ALPHA:
|
|
|
|
blend_color_add_alpha_float(dst, src1, src2);
|
|
|
|
break;
|
2014-07-21 12:02:05 +02:00
|
|
|
case IMB_BLEND_OVERLAY:
|
|
|
|
blend_color_overlay_float(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_HARDLIGHT:
|
|
|
|
blend_color_hardlight_float(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_COLORBURN:
|
|
|
|
blend_color_burn_float(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_LINEARBURN:
|
|
|
|
blend_color_linearburn_float(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_COLORDODGE:
|
|
|
|
blend_color_dodge_float(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_SCREEN:
|
|
|
|
blend_color_screen_float(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_SOFTLIGHT:
|
|
|
|
blend_color_softlight_float(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_PINLIGHT:
|
|
|
|
blend_color_pinlight_float(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_LINEARLIGHT:
|
|
|
|
blend_color_linearlight_float(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_VIVIDLIGHT:
|
|
|
|
blend_color_vividlight_float(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_DIFFERENCE:
|
|
|
|
blend_color_difference_float(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_EXCLUSION:
|
|
|
|
blend_color_exclusion_float(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_COLOR:
|
|
|
|
blend_color_color_float(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_HUE:
|
|
|
|
blend_color_hue_float(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_SATURATION:
|
|
|
|
blend_color_saturation_float(dst, src1, src2);
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_LUMINOSITY:
|
|
|
|
blend_color_luminosity_float(dst, src1, src2);
|
|
|
|
break;
|
2006-07-31 17:53:03 +02:00
|
|
|
default:
|
2012-05-08 13:48:19 +02:00
|
|
|
dst[0] = src1[0];
|
|
|
|
dst[1] = src1[1];
|
|
|
|
dst[2] = src1[2];
|
2013-04-28 13:55:41 +02:00
|
|
|
dst[3] = src1[3];
|
|
|
|
break;
|
2006-11-07 01:10:37 +01:00
|
|
|
}
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
|
2019-11-24 15:14:39 +01:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Crop
|
|
|
|
* \{ */
|
2019-07-04 13:15:18 +02:00
|
|
|
|
|
|
|
static void rect_crop_4bytes(void **buf_p, const int size_src[2], const rcti *crop)
|
|
|
|
{
|
|
|
|
if (*buf_p == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const int size_dst[2] = {
|
|
|
|
BLI_rcti_size_x(crop) + 1,
|
|
|
|
BLI_rcti_size_y(crop) + 1,
|
|
|
|
};
|
|
|
|
uint *src = *buf_p;
|
|
|
|
uint *dst = src + crop->ymin * size_src[0] + crop->xmin;
|
|
|
|
for (int y = 0; y < size_dst[1]; y++, src += size_dst[0], dst += size_src[0]) {
|
|
|
|
memmove(src, dst, sizeof(uint) * size_dst[0]);
|
|
|
|
}
|
|
|
|
*buf_p = MEM_reallocN(*buf_p, sizeof(uint) * size_dst[0] * size_dst[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rect_crop_16bytes(void **buf_p, const int size_src[2], const rcti *crop)
|
|
|
|
{
|
|
|
|
if (*buf_p == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const int size_dst[2] = {
|
|
|
|
BLI_rcti_size_x(crop) + 1,
|
|
|
|
BLI_rcti_size_y(crop) + 1,
|
|
|
|
};
|
|
|
|
uint(*src)[4] = *buf_p;
|
|
|
|
uint(*dst)[4] = src + crop->ymin * size_src[0] + crop->xmin;
|
|
|
|
for (int y = 0; y < size_dst[1]; y++, src += size_dst[0], dst += size_src[0]) {
|
|
|
|
memmove(src, dst, sizeof(uint[4]) * size_dst[0]);
|
|
|
|
}
|
|
|
|
*buf_p = (void *)MEM_reallocN(*buf_p, sizeof(uint[4]) * size_dst[0] * size_dst[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IMB_rect_crop(ImBuf *ibuf, const rcti *crop)
|
|
|
|
{
|
|
|
|
const int size_src[2] = {
|
|
|
|
ibuf->x,
|
|
|
|
ibuf->y,
|
|
|
|
};
|
|
|
|
const int size_dst[2] = {
|
|
|
|
BLI_rcti_size_x(crop) + 1,
|
|
|
|
BLI_rcti_size_y(crop) + 1,
|
|
|
|
};
|
2019-10-02 22:58:43 +02:00
|
|
|
BLI_assert(size_dst[0] > 0 && size_dst[1] > 0);
|
2019-07-04 13:15:18 +02:00
|
|
|
BLI_assert(crop->xmin >= 0 && crop->ymin >= 0);
|
|
|
|
BLI_assert(crop->xmax < ibuf->x && crop->ymax < ibuf->y);
|
|
|
|
|
|
|
|
if ((size_dst[0] == ibuf->x) && (size_dst[1] == ibuf->y)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rect_crop_4bytes((void **)&ibuf->rect, size_src, crop);
|
|
|
|
rect_crop_4bytes((void **)&ibuf->zbuf, size_src, crop);
|
|
|
|
rect_crop_4bytes((void **)&ibuf->zbuf_float, size_src, crop);
|
|
|
|
rect_crop_16bytes((void **)&ibuf->rect_float, size_src, crop);
|
|
|
|
|
|
|
|
ibuf->x = size_dst[0];
|
|
|
|
ibuf->y = size_dst[1];
|
|
|
|
}
|
|
|
|
|
2019-11-24 15:14:39 +01:00
|
|
|
/**
|
2019-12-11 00:56:14 +01:00
|
|
|
* Re-allocate buffers at a new size.
|
2019-11-24 15:14:39 +01:00
|
|
|
*/
|
2019-10-01 16:07:06 +02:00
|
|
|
static void rect_realloc_4bytes(void **buf_p, const uint size[2])
|
|
|
|
{
|
|
|
|
if (*buf_p == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
MEM_freeN(*buf_p);
|
|
|
|
*buf_p = MEM_mallocN(sizeof(uint) * size[0] * size[1], __func__);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rect_realloc_16bytes(void **buf_p, const uint size[2])
|
|
|
|
{
|
|
|
|
if (*buf_p == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
MEM_freeN(*buf_p);
|
|
|
|
*buf_p = MEM_mallocN(sizeof(uint[4]) * size[0] * size[1], __func__);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IMB_rect_size_set(ImBuf *ibuf, const uint size[2])
|
|
|
|
{
|
2019-10-02 22:58:43 +02:00
|
|
|
BLI_assert(size[0] > 0 && size[1] > 0);
|
2019-10-01 16:07:06 +02:00
|
|
|
if ((size[0] == ibuf->x) && (size[1] == ibuf->y)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rect_realloc_4bytes((void **)&ibuf->rect, size);
|
|
|
|
rect_realloc_4bytes((void **)&ibuf->zbuf, size);
|
|
|
|
rect_realloc_4bytes((void **)&ibuf->zbuf_float, size);
|
|
|
|
rect_realloc_16bytes((void **)&ibuf->rect_float, size);
|
|
|
|
|
|
|
|
ibuf->x = size[0];
|
|
|
|
ibuf->y = size[1];
|
|
|
|
}
|
|
|
|
|
2019-11-24 15:14:39 +01:00
|
|
|
/** \} */
|
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
/* clipping */
|
|
|
|
|
2018-06-17 17:04:54 +02:00
|
|
|
void IMB_rectclip(ImBuf *dbuf,
|
2019-09-25 09:11:00 +02:00
|
|
|
const ImBuf *sbuf,
|
2018-06-17 17:04:54 +02:00
|
|
|
int *destx,
|
2012-05-08 13:48:19 +02:00
|
|
|
int *desty,
|
|
|
|
int *srcx,
|
|
|
|
int *srcy,
|
|
|
|
int *width,
|
|
|
|
int *height)
|
2006-07-31 17:53:03 +02:00
|
|
|
{
|
|
|
|
int tmp;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-23 03:01:30 +02:00
|
|
|
if (dbuf == NULL) {
|
2006-07-31 17:53:03 +02:00
|
|
|
return;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
if (*destx < 0) {
|
2006-08-27 15:29:00 +02:00
|
|
|
*srcx -= *destx;
|
|
|
|
*width += *destx;
|
2006-07-31 17:53:03 +02:00
|
|
|
*destx = 0;
|
|
|
|
}
|
|
|
|
if (*srcx < 0) {
|
2006-08-27 15:29:00 +02:00
|
|
|
*destx -= *srcx;
|
2009-12-08 09:44:18 +01:00
|
|
|
*width += *srcx;
|
2006-07-31 17:53:03 +02:00
|
|
|
*srcx = 0;
|
|
|
|
}
|
|
|
|
if (*desty < 0) {
|
2006-08-27 15:29:00 +02:00
|
|
|
*srcy -= *desty;
|
|
|
|
*height += *desty;
|
2006-07-31 17:53:03 +02:00
|
|
|
*desty = 0;
|
|
|
|
}
|
|
|
|
if (*srcy < 0) {
|
2006-08-27 15:29:00 +02:00
|
|
|
*desty -= *srcy;
|
2009-12-08 09:44:18 +01:00
|
|
|
*height += *srcy;
|
2006-07-31 17:53:03 +02:00
|
|
|
*srcy = 0;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
tmp = dbuf->x - *destx;
|
2019-04-23 03:01:30 +02:00
|
|
|
if (*width > tmp) {
|
2006-07-31 17:53:03 +02:00
|
|
|
*width = tmp;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2006-07-31 17:53:03 +02:00
|
|
|
tmp = dbuf->y - *desty;
|
2019-04-23 03:01:30 +02:00
|
|
|
if (*height > tmp) {
|
2006-07-31 17:53:03 +02:00
|
|
|
*height = tmp;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
if (sbuf) {
|
|
|
|
tmp = sbuf->x - *srcx;
|
2019-04-23 03:01:30 +02:00
|
|
|
if (*width > tmp) {
|
2006-07-31 17:53:03 +02:00
|
|
|
*width = tmp;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2006-07-31 17:53:03 +02:00
|
|
|
tmp = sbuf->y - *srcy;
|
2019-04-23 03:01:30 +02:00
|
|
|
if (*height > tmp) {
|
2006-07-31 17:53:03 +02:00
|
|
|
*height = tmp;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2006-08-27 15:29:00 +02:00
|
|
|
if ((*height <= 0) || (*width <= 0)) {
|
|
|
|
*width = 0;
|
|
|
|
*height = 0;
|
|
|
|
}
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
|
2018-06-17 17:04:54 +02:00
|
|
|
static void imb_rectclip3(ImBuf *dbuf,
|
2019-09-25 09:11:00 +02:00
|
|
|
const ImBuf *obuf,
|
|
|
|
const ImBuf *sbuf,
|
2018-06-17 17:04:54 +02:00
|
|
|
int *destx,
|
2013-04-30 08:07:42 +02:00
|
|
|
int *desty,
|
|
|
|
int *origx,
|
|
|
|
int *origy,
|
|
|
|
int *srcx,
|
|
|
|
int *srcy,
|
|
|
|
int *width,
|
|
|
|
int *height)
|
|
|
|
{
|
|
|
|
int tmp;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-23 03:01:30 +02:00
|
|
|
if (dbuf == NULL) {
|
2013-04-30 08:07:42 +02:00
|
|
|
return;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-30 08:07:42 +02:00
|
|
|
if (*destx < 0) {
|
|
|
|
*srcx -= *destx;
|
|
|
|
*origx -= *destx;
|
|
|
|
*width += *destx;
|
|
|
|
*destx = 0;
|
|
|
|
}
|
|
|
|
if (*origx < 0) {
|
|
|
|
*destx -= *origx;
|
|
|
|
*srcx -= *origx;
|
|
|
|
*width += *origx;
|
|
|
|
*origx = 0;
|
|
|
|
}
|
|
|
|
if (*srcx < 0) {
|
|
|
|
*destx -= *srcx;
|
|
|
|
*origx -= *srcx;
|
|
|
|
*width += *srcx;
|
|
|
|
*srcx = 0;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-30 08:07:42 +02:00
|
|
|
if (*desty < 0) {
|
|
|
|
*srcy -= *desty;
|
|
|
|
*origy -= *desty;
|
|
|
|
*height += *desty;
|
|
|
|
*desty = 0;
|
|
|
|
}
|
|
|
|
if (*origy < 0) {
|
|
|
|
*desty -= *origy;
|
|
|
|
*srcy -= *origy;
|
|
|
|
*height += *origy;
|
|
|
|
*origy = 0;
|
|
|
|
}
|
|
|
|
if (*srcy < 0) {
|
|
|
|
*desty -= *srcy;
|
|
|
|
*origy -= *srcy;
|
|
|
|
*height += *srcy;
|
|
|
|
*srcy = 0;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-30 08:07:42 +02:00
|
|
|
tmp = dbuf->x - *destx;
|
2019-04-23 03:01:30 +02:00
|
|
|
if (*width > tmp) {
|
2013-04-30 08:07:42 +02:00
|
|
|
*width = tmp;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2013-04-30 08:07:42 +02:00
|
|
|
tmp = dbuf->y - *desty;
|
2019-04-23 03:01:30 +02:00
|
|
|
if (*height > tmp) {
|
2013-04-30 08:07:42 +02:00
|
|
|
*height = tmp;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-30 08:07:42 +02:00
|
|
|
if (obuf) {
|
|
|
|
tmp = obuf->x - *origx;
|
2019-04-23 03:01:30 +02:00
|
|
|
if (*width > tmp) {
|
2013-04-30 08:07:42 +02:00
|
|
|
*width = tmp;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2013-04-30 08:07:42 +02:00
|
|
|
tmp = obuf->y - *origy;
|
2019-04-23 03:01:30 +02:00
|
|
|
if (*height > tmp) {
|
2013-04-30 08:07:42 +02:00
|
|
|
*height = tmp;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2013-04-30 08:07:42 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-30 08:07:42 +02:00
|
|
|
if (sbuf) {
|
|
|
|
tmp = sbuf->x - *srcx;
|
2019-04-23 03:01:30 +02:00
|
|
|
if (*width > tmp) {
|
2013-04-30 08:07:42 +02:00
|
|
|
*width = tmp;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2013-04-30 08:07:42 +02:00
|
|
|
tmp = sbuf->y - *srcy;
|
2019-04-23 03:01:30 +02:00
|
|
|
if (*height > tmp) {
|
2013-04-30 08:07:42 +02:00
|
|
|
*height = tmp;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2013-04-30 08:07:42 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-30 08:07:42 +02:00
|
|
|
if ((*height <= 0) || (*width <= 0)) {
|
|
|
|
*width = 0;
|
|
|
|
*height = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
/* copy and blend */
|
|
|
|
|
2019-09-25 09:11:00 +02:00
|
|
|
void IMB_rectcpy(ImBuf *dbuf,
|
|
|
|
const ImBuf *sbuf,
|
|
|
|
int destx,
|
|
|
|
int desty,
|
|
|
|
int srcx,
|
|
|
|
int srcy,
|
|
|
|
int width,
|
|
|
|
int height)
|
2002-10-12 13:37:38 +02:00
|
|
|
{
|
2014-07-21 12:02:05 +02:00
|
|
|
IMB_rectblend(dbuf,
|
|
|
|
dbuf,
|
|
|
|
sbuf,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
destx,
|
|
|
|
desty,
|
|
|
|
destx,
|
|
|
|
desty,
|
|
|
|
srcx,
|
|
|
|
srcy,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
IMB_BLEND_COPY,
|
|
|
|
false);
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
|
2013-04-27 14:51:23 +02:00
|
|
|
typedef void (*IMB_blend_func)(unsigned char *dst,
|
|
|
|
const unsigned char *src1,
|
|
|
|
const unsigned char *src2);
|
|
|
|
typedef void (*IMB_blend_func_float)(float *dst, const float *src1, const float *src2);
|
2013-03-05 03:47:00 +01:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
void IMB_rectblend(ImBuf *dbuf,
|
2019-09-25 09:11:00 +02:00
|
|
|
const ImBuf *obuf,
|
|
|
|
const ImBuf *sbuf,
|
2014-07-21 12:02:05 +02:00
|
|
|
unsigned short *dmask,
|
2019-09-25 09:11:00 +02:00
|
|
|
const unsigned short *curvemask,
|
|
|
|
const unsigned short *texmask,
|
2014-07-21 12:02:05 +02:00
|
|
|
float mask_max,
|
2013-04-30 08:07:42 +02:00
|
|
|
int destx,
|
|
|
|
int desty,
|
|
|
|
int origx,
|
|
|
|
int origy,
|
|
|
|
int srcx,
|
|
|
|
int srcy,
|
|
|
|
int width,
|
|
|
|
int height,
|
2014-07-21 12:02:05 +02:00
|
|
|
IMB_BlendMode mode,
|
|
|
|
bool accumulate)
|
2006-07-31 17:53:03 +02:00
|
|
|
{
|
2017-07-20 23:51:15 +02:00
|
|
|
unsigned int *drect = NULL, *orect = NULL, *srect = NULL, *dr, * or, *sr;
|
|
|
|
float *drectf = NULL, *orectf = NULL, *srectf = NULL, *drf, *orf, *srf;
|
2019-09-25 09:11:00 +02:00
|
|
|
const unsigned short *cmaskrect = curvemask, *cmr;
|
2013-05-12 11:14:13 +02:00
|
|
|
unsigned short *dmaskrect = dmask, *dmr;
|
2019-09-25 09:11:00 +02:00
|
|
|
const unsigned short *texmaskrect = texmask, *tmr;
|
2022-04-26 06:25:58 +02:00
|
|
|
int srcskip, destskip, origskip, x;
|
2013-03-05 03:47:00 +01:00
|
|
|
IMB_blend_func func = NULL;
|
|
|
|
IMB_blend_func_float func_float = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-23 03:01:30 +02:00
|
|
|
if (dbuf == NULL || obuf == NULL) {
|
2013-04-30 08:07:42 +02:00
|
|
|
return;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-30 08:07:42 +02:00
|
|
|
imb_rectclip3(dbuf, obuf, sbuf, &destx, &desty, &origx, &origy, &srcx, &srcy, &width, &height);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-23 03:01:30 +02:00
|
|
|
if (width == 0 || height == 0) {
|
2012-05-08 13:48:19 +02:00
|
|
|
return;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
|
|
|
if (sbuf && sbuf->channels != 4) {
|
2012-05-08 13:48:19 +02:00
|
|
|
return;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
|
|
|
if (dbuf->channels != 4) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-04-26 06:25:58 +02:00
|
|
|
const bool do_char = (sbuf && sbuf->rect && dbuf->rect && obuf->rect);
|
|
|
|
const bool do_float = (sbuf && sbuf->rect_float && dbuf->rect_float && obuf->rect_float);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-30 08:07:42 +02:00
|
|
|
if (do_char) {
|
2015-04-30 12:10:58 +02:00
|
|
|
drect = dbuf->rect + ((size_t)desty) * dbuf->x + destx;
|
|
|
|
orect = obuf->rect + ((size_t)origy) * obuf->x + origx;
|
2013-04-30 08:07:42 +02:00
|
|
|
}
|
|
|
|
if (do_float) {
|
2015-04-30 12:10:58 +02:00
|
|
|
drectf = dbuf->rect_float + (((size_t)desty) * dbuf->x + destx) * 4;
|
|
|
|
orectf = obuf->rect_float + (((size_t)origy) * obuf->x + origx) * 4;
|
2013-04-30 08:07:42 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-23 03:01:30 +02:00
|
|
|
if (dmaskrect) {
|
2015-04-30 12:10:58 +02:00
|
|
|
dmaskrect += ((size_t)origy) * obuf->x + origx;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
destskip = dbuf->x;
|
2013-04-30 08:07:42 +02:00
|
|
|
origskip = obuf->x;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
if (sbuf) {
|
2019-04-23 03:01:30 +02:00
|
|
|
if (do_char) {
|
2015-04-30 12:10:58 +02:00
|
|
|
srect = sbuf->rect + ((size_t)srcy) * sbuf->x + srcx;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
|
|
|
if (do_float) {
|
2015-04-30 12:10:58 +02:00
|
|
|
srectf = sbuf->rect_float + (((size_t)srcy) * sbuf->x + srcx) * 4;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2006-07-31 17:53:03 +02:00
|
|
|
srcskip = sbuf->x;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-23 03:01:30 +02:00
|
|
|
if (cmaskrect) {
|
2015-04-30 12:10:58 +02:00
|
|
|
cmaskrect += ((size_t)srcy) * sbuf->x + srcx;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-23 03:01:30 +02:00
|
|
|
if (texmaskrect) {
|
2015-04-30 12:10:58 +02:00
|
|
|
texmaskrect += ((size_t)srcy) * sbuf->x + srcx;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2012-03-24 07:38:07 +01:00
|
|
|
}
|
|
|
|
else {
|
2002-10-12 13:37:38 +02:00
|
|
|
srect = drect;
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 01:40:35 +01:00
|
|
|
srectf = drectf;
|
2006-07-31 17:53:03 +02:00
|
|
|
srcskip = destskip;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
if (mode == IMB_BLEND_COPY) {
|
|
|
|
/* copy */
|
2012-05-08 13:48:19 +02:00
|
|
|
for (; height > 0; height--) {
|
2006-07-31 17:53:03 +02:00
|
|
|
if (do_char) {
|
2012-04-29 17:47:02 +02:00
|
|
|
memcpy(drect, srect, width * sizeof(int));
|
2006-07-31 17:53:03 +02:00
|
|
|
drect += destskip;
|
|
|
|
srect += srcskip;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
if (do_float) {
|
2020-08-08 05:29:21 +02:00
|
|
|
memcpy(drectf, srectf, sizeof(float[4]) * width);
|
2012-05-08 13:48:19 +02:00
|
|
|
drectf += destskip * 4;
|
|
|
|
srectf += srcskip * 4;
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
2006-07-31 17:53:03 +02:00
|
|
|
else if (mode == IMB_BLEND_COPY_RGB) {
|
|
|
|
/* copy rgb only */
|
2012-05-08 13:48:19 +02:00
|
|
|
for (; height > 0; height--) {
|
2006-07-31 17:53:03 +02:00
|
|
|
if (do_char) {
|
|
|
|
dr = drect;
|
|
|
|
sr = srect;
|
2012-05-08 13:48:19 +02:00
|
|
|
for (x = width; x > 0; x--, dr++, sr++) {
|
|
|
|
((char *)dr)[0] = ((char *)sr)[0];
|
|
|
|
((char *)dr)[1] = ((char *)sr)[1];
|
|
|
|
((char *)dr)[2] = ((char *)sr)[2];
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
drect += destskip;
|
|
|
|
srect += srcskip;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
if (do_float) {
|
|
|
|
drf = drectf;
|
|
|
|
srf = srectf;
|
2012-05-08 13:48:19 +02:00
|
|
|
for (x = width; x > 0; x--, drf += 4, srf += 4) {
|
2014-01-12 12:27:55 +01:00
|
|
|
float map_alpha = (srf[3] == 0.0f) ? drf[3] : drf[3] / srf[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-05-22 22:06:50 +02:00
|
|
|
drf[0] = srf[0] * map_alpha;
|
|
|
|
drf[1] = srf[1] * map_alpha;
|
|
|
|
drf[2] = srf[2] * map_alpha;
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
2012-05-08 13:48:19 +02:00
|
|
|
drectf += destskip * 4;
|
|
|
|
srectf += srcskip * 4;
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
2006-07-31 17:53:03 +02:00
|
|
|
else if (mode == IMB_BLEND_COPY_ALPHA) {
|
|
|
|
/* copy alpha only */
|
2012-05-08 13:48:19 +02:00
|
|
|
for (; height > 0; height--) {
|
2006-07-31 17:53:03 +02:00
|
|
|
if (do_char) {
|
|
|
|
dr = drect;
|
|
|
|
sr = srect;
|
2019-04-23 03:01:30 +02:00
|
|
|
for (x = width; x > 0; x--, dr++, sr++) {
|
2012-05-08 13:48:19 +02:00
|
|
|
((char *)dr)[3] = ((char *)sr)[3];
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2006-07-31 17:53:03 +02:00
|
|
|
drect += destskip;
|
|
|
|
srect += srcskip;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
if (do_float) {
|
|
|
|
drf = drectf;
|
|
|
|
srf = srectf;
|
2019-04-23 03:01:30 +02:00
|
|
|
for (x = width; x > 0; x--, drf += 4, srf += 4) {
|
2012-05-08 13:48:19 +02:00
|
|
|
drf[3] = srf[3];
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2012-05-08 13:48:19 +02:00
|
|
|
drectf += destskip * 4;
|
|
|
|
srectf += srcskip * 4;
|
2002-10-12 13:37:38 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
2006-07-31 17:53:03 +02:00
|
|
|
else {
|
2013-03-05 03:47:00 +01:00
|
|
|
switch (mode) {
|
|
|
|
case IMB_BLEND_MIX:
|
2017-07-21 00:16:59 +02:00
|
|
|
case IMB_BLEND_INTERPOLATE:
|
2013-04-27 14:51:23 +02:00
|
|
|
func = blend_color_mix_byte;
|
2013-03-05 03:47:00 +01:00
|
|
|
func_float = blend_color_mix_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_ADD:
|
2013-04-27 14:51:23 +02:00
|
|
|
func = blend_color_add_byte;
|
2013-03-05 03:47:00 +01:00
|
|
|
func_float = blend_color_add_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_SUB:
|
2013-04-27 14:51:23 +02:00
|
|
|
func = blend_color_sub_byte;
|
2013-03-05 03:47:00 +01:00
|
|
|
func_float = blend_color_sub_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_MUL:
|
2013-04-27 14:51:23 +02:00
|
|
|
func = blend_color_mul_byte;
|
2013-03-05 03:47:00 +01:00
|
|
|
func_float = blend_color_mul_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_LIGHTEN:
|
2013-04-27 14:51:23 +02:00
|
|
|
func = blend_color_lighten_byte;
|
2013-03-05 03:47:00 +01:00
|
|
|
func_float = blend_color_lighten_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_DARKEN:
|
2013-04-27 14:51:23 +02:00
|
|
|
func = blend_color_darken_byte;
|
2013-03-05 03:47:00 +01:00
|
|
|
func_float = blend_color_darken_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_ERASE_ALPHA:
|
2013-04-27 14:51:23 +02:00
|
|
|
func = blend_color_erase_alpha_byte;
|
2013-03-05 03:47:00 +01:00
|
|
|
func_float = blend_color_erase_alpha_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_ADD_ALPHA:
|
2013-04-27 14:51:23 +02:00
|
|
|
func = blend_color_add_alpha_byte;
|
2013-03-05 03:47:00 +01:00
|
|
|
func_float = blend_color_add_alpha_float;
|
|
|
|
break;
|
2014-07-21 12:02:05 +02:00
|
|
|
case IMB_BLEND_OVERLAY:
|
|
|
|
func = blend_color_overlay_byte;
|
|
|
|
func_float = blend_color_overlay_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_HARDLIGHT:
|
|
|
|
func = blend_color_hardlight_byte;
|
|
|
|
func_float = blend_color_hardlight_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_COLORBURN:
|
|
|
|
func = blend_color_burn_byte;
|
|
|
|
func_float = blend_color_burn_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_LINEARBURN:
|
|
|
|
func = blend_color_linearburn_byte;
|
|
|
|
func_float = blend_color_linearburn_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_COLORDODGE:
|
|
|
|
func = blend_color_dodge_byte;
|
|
|
|
func_float = blend_color_dodge_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_SCREEN:
|
|
|
|
func = blend_color_screen_byte;
|
|
|
|
func_float = blend_color_screen_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_SOFTLIGHT:
|
|
|
|
func = blend_color_softlight_byte;
|
|
|
|
func_float = blend_color_softlight_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_PINLIGHT:
|
|
|
|
func = blend_color_pinlight_byte;
|
|
|
|
func_float = blend_color_pinlight_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_LINEARLIGHT:
|
|
|
|
func = blend_color_linearlight_byte;
|
|
|
|
func_float = blend_color_linearlight_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_VIVIDLIGHT:
|
|
|
|
func = blend_color_vividlight_byte;
|
|
|
|
func_float = blend_color_vividlight_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_DIFFERENCE:
|
|
|
|
func = blend_color_difference_byte;
|
|
|
|
func_float = blend_color_difference_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_EXCLUSION:
|
|
|
|
func = blend_color_exclusion_byte;
|
|
|
|
func_float = blend_color_exclusion_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_COLOR:
|
|
|
|
func = blend_color_color_byte;
|
|
|
|
func_float = blend_color_color_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_HUE:
|
|
|
|
func = blend_color_hue_byte;
|
|
|
|
func_float = blend_color_hue_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_SATURATION:
|
|
|
|
func = blend_color_saturation_byte;
|
|
|
|
func_float = blend_color_saturation_float;
|
|
|
|
break;
|
|
|
|
case IMB_BLEND_LUMINOSITY:
|
|
|
|
func = blend_color_luminosity_byte;
|
|
|
|
func_float = blend_color_luminosity_float;
|
|
|
|
break;
|
2013-03-05 03:47:00 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
/* blend */
|
2012-05-08 13:48:19 +02:00
|
|
|
for (; height > 0; height--) {
|
2006-07-31 17:53:03 +02:00
|
|
|
if (do_char) {
|
|
|
|
dr = drect;
|
2013-04-30 08:07:42 +02:00
|
|
|
or = orect;
|
2006-07-31 17:53:03 +02:00
|
|
|
sr = srect;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
if (cmaskrect) {
|
2013-04-30 08:07:42 +02:00
|
|
|
/* mask accumulation for painting */
|
2014-07-21 12:02:05 +02:00
|
|
|
cmr = cmaskrect;
|
|
|
|
tmr = texmaskrect;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
/* destination mask present, do max alpha masking */
|
|
|
|
if (dmaskrect) {
|
|
|
|
dmr = dmaskrect;
|
|
|
|
for (x = width; x > 0; x--, dr++, or ++, sr++, dmr++, cmr++) {
|
|
|
|
unsigned char *src = (unsigned char *)sr;
|
|
|
|
float mask_lim = mask_max * (*cmr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-23 03:01:30 +02:00
|
|
|
if (texmaskrect) {
|
2014-07-21 12:02:05 +02:00
|
|
|
mask_lim *= ((*tmr++) / 65535.0f);
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
if (src[3] && mask_lim) {
|
|
|
|
float mask;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-23 03:01:30 +02:00
|
|
|
if (accumulate) {
|
2014-07-21 12:02:05 +02:00
|
|
|
mask = *dmr + mask_lim;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
|
|
|
else {
|
2014-07-21 12:02:05 +02:00
|
|
|
mask = *dmr + mask_lim - (*dmr * (*cmr / 65535.0f));
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
mask = min_ff(mask, 65535.0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
if (mask > *dmr) {
|
|
|
|
unsigned char mask_src[4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
*dmr = mask;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
mask_src[0] = src[0];
|
|
|
|
mask_src[1] = src[1];
|
|
|
|
mask_src[2] = src[2];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-07-21 00:16:59 +02:00
|
|
|
if (mode == IMB_BLEND_INTERPOLATE) {
|
|
|
|
mask_src[3] = src[3];
|
|
|
|
blend_color_interpolate_byte(
|
|
|
|
(unsigned char *)dr, (unsigned char *) or, mask_src, mask / 65535.0f);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mask_src[3] = divide_round_i(src[3] * mask, 65535);
|
|
|
|
func((unsigned char *)dr, (unsigned char *) or, mask_src);
|
2014-07-21 12:02:05 +02:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
2014-07-21 12:02:05 +02:00
|
|
|
dmaskrect += origskip;
|
|
|
|
}
|
|
|
|
/* no destination mask buffer, do regular blend with masktexture if present */
|
|
|
|
else {
|
|
|
|
for (x = width; x > 0; x--, dr++, or ++, sr++, cmr++) {
|
|
|
|
unsigned char *src = (unsigned char *)sr;
|
|
|
|
float mask = (float)mask_max * ((float)(*cmr));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-23 03:01:30 +02:00
|
|
|
if (texmaskrect) {
|
2014-07-21 12:02:05 +02:00
|
|
|
mask *= ((float)(*tmr++) / 65535.0f);
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
mask = min_ff(mask, 65535.0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
if (src[3] && (mask > 0.0f)) {
|
|
|
|
unsigned char mask_src[4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-30 08:07:42 +02:00
|
|
|
mask_src[0] = src[0];
|
|
|
|
mask_src[1] = src[1];
|
|
|
|
mask_src[2] = src[2];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-07-21 00:16:59 +02:00
|
|
|
if (mode == IMB_BLEND_INTERPOLATE) {
|
|
|
|
mask_src[3] = src[3];
|
|
|
|
blend_color_interpolate_byte(
|
|
|
|
(unsigned char *)dr, (unsigned char *) or, mask_src, mask / 65535.0f);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mask_src[3] = divide_round_i(src[3] * mask, 65535);
|
|
|
|
func((unsigned char *)dr, (unsigned char *) or, mask_src);
|
2013-04-30 08:07:42 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
cmaskrect += srcskip;
|
2019-04-23 03:01:30 +02:00
|
|
|
if (texmaskrect) {
|
2014-07-21 12:02:05 +02:00
|
|
|
texmaskrect += srcskip;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2013-04-30 08:07:42 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* regular blending */
|
|
|
|
for (x = width; x > 0; x--, dr++, or ++, sr++) {
|
2019-04-23 03:01:30 +02:00
|
|
|
if (((unsigned char *)sr)[3]) {
|
2013-04-30 08:07:42 +02:00
|
|
|
func((unsigned char *)dr, (unsigned char *) or, (unsigned char *)sr);
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2013-03-05 03:47:00 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
drect += destskip;
|
2013-04-30 08:07:42 +02:00
|
|
|
orect += origskip;
|
2006-07-31 17:53:03 +02:00
|
|
|
srect += srcskip;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
if (do_float) {
|
|
|
|
drf = drectf;
|
2013-04-30 08:07:42 +02:00
|
|
|
orf = orectf;
|
2006-07-31 17:53:03 +02:00
|
|
|
srf = srectf;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
if (cmaskrect) {
|
2013-04-30 08:07:42 +02:00
|
|
|
/* mask accumulation for painting */
|
2014-07-21 12:02:05 +02:00
|
|
|
cmr = cmaskrect;
|
|
|
|
tmr = texmaskrect;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
/* destination mask present, do max alpha masking */
|
|
|
|
if (dmaskrect) {
|
|
|
|
dmr = dmaskrect;
|
|
|
|
for (x = width; x > 0; x--, drf += 4, orf += 4, srf += 4, dmr++, cmr++) {
|
|
|
|
float mask_lim = mask_max * (*cmr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-23 03:01:30 +02:00
|
|
|
if (texmaskrect) {
|
2014-07-21 12:02:05 +02:00
|
|
|
mask_lim *= ((*tmr++) / 65535.0f);
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
if (srf[3] && mask_lim) {
|
|
|
|
float mask;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-23 03:01:30 +02:00
|
|
|
if (accumulate) {
|
2014-07-21 12:02:05 +02:00
|
|
|
mask = min_ff(*dmr + mask_lim, 65535.0);
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
|
|
|
else {
|
2014-07-21 12:02:05 +02:00
|
|
|
mask = *dmr + mask_lim - (*dmr * (*cmr / 65535.0f));
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
mask = min_ff(mask, 65535.0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
if (mask > *dmr) {
|
|
|
|
*dmr = mask;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-07-21 00:16:59 +02:00
|
|
|
if (mode == IMB_BLEND_INTERPOLATE) {
|
|
|
|
blend_color_interpolate_float(drf, orf, srf, mask / 65535.0f);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float mask_srf[4];
|
|
|
|
mul_v4_v4fl(mask_srf, srf, mask / 65535.0f);
|
|
|
|
func_float(drf, orf, mask_srf);
|
2014-07-21 12:02:05 +02:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
2014-07-21 12:02:05 +02:00
|
|
|
dmaskrect += origskip;
|
|
|
|
}
|
|
|
|
/* no destination mask buffer, do regular blend with masktexture if present */
|
|
|
|
else {
|
|
|
|
for (x = width; x > 0; x--, drf += 4, orf += 4, srf += 4, cmr++) {
|
|
|
|
float mask = (float)mask_max * ((float)(*cmr));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-23 03:01:30 +02:00
|
|
|
if (texmaskrect) {
|
2014-07-21 12:02:05 +02:00
|
|
|
mask *= ((float)(*tmr++) / 65535.0f);
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
mask = min_ff(mask, 65535.0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
if (srf[3] && (mask > 0.0f)) {
|
2017-07-21 00:16:59 +02:00
|
|
|
if (mode == IMB_BLEND_INTERPOLATE) {
|
|
|
|
blend_color_interpolate_float(drf, orf, srf, mask / 65535.0f);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float mask_srf[4];
|
|
|
|
mul_v4_v4fl(mask_srf, srf, mask / 65535.0f);
|
|
|
|
func_float(drf, orf, mask_srf);
|
|
|
|
}
|
2013-04-30 08:07:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
cmaskrect += srcskip;
|
2019-04-23 03:01:30 +02:00
|
|
|
if (texmaskrect) {
|
2014-07-21 12:02:05 +02:00
|
|
|
texmaskrect += srcskip;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2013-03-05 03:47:00 +01:00
|
|
|
}
|
2013-04-30 08:07:42 +02:00
|
|
|
else {
|
|
|
|
/* regular blending */
|
|
|
|
for (x = width; x > 0; x--, drf += 4, orf += 4, srf += 4) {
|
2019-04-23 03:01:30 +02:00
|
|
|
if (srf[3] != 0) {
|
2013-04-30 08:07:42 +02:00
|
|
|
func_float(drf, orf, srf);
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2013-04-30 08:07:42 +02:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-08 13:48:19 +02:00
|
|
|
drectf += destskip * 4;
|
2013-04-30 08:07:42 +02:00
|
|
|
orectf += origskip * 4;
|
2012-05-08 13:48:19 +02:00
|
|
|
srectf += srcskip * 4;
|
2012-10-21 07:46:41 +02:00
|
|
|
}
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
2002-10-12 13:37:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-06 11:48:07 +02:00
|
|
|
typedef struct RectBlendThreadData {
|
2019-09-25 09:11:00 +02:00
|
|
|
ImBuf *dbuf;
|
|
|
|
const ImBuf *obuf, *sbuf;
|
|
|
|
unsigned short *dmask;
|
|
|
|
const unsigned short *curvemask, *texmask;
|
2016-05-06 11:48:07 +02:00
|
|
|
float mask_max;
|
|
|
|
int destx, desty, origx, origy;
|
|
|
|
int srcx, srcy, width;
|
|
|
|
IMB_BlendMode mode;
|
|
|
|
bool accumulate;
|
|
|
|
} RectBlendThreadData;
|
|
|
|
|
2021-06-11 15:55:09 +02:00
|
|
|
static void rectblend_thread_do(void *data_v, int scanline)
|
2016-05-06 11:48:07 +02:00
|
|
|
{
|
2021-06-11 15:55:09 +02:00
|
|
|
const int num_scanlines = 1;
|
2016-05-06 11:48:07 +02:00
|
|
|
RectBlendThreadData *data = (RectBlendThreadData *)data_v;
|
|
|
|
IMB_rectblend(data->dbuf,
|
|
|
|
data->obuf,
|
|
|
|
data->sbuf,
|
|
|
|
data->dmask,
|
|
|
|
data->curvemask,
|
|
|
|
data->texmask,
|
|
|
|
data->mask_max,
|
|
|
|
data->destx,
|
2021-06-11 15:55:09 +02:00
|
|
|
data->desty + scanline,
|
2016-05-06 11:48:07 +02:00
|
|
|
data->origx,
|
2021-06-11 15:55:09 +02:00
|
|
|
data->origy + scanline,
|
2016-05-06 11:48:07 +02:00
|
|
|
data->srcx,
|
2021-06-11 15:55:09 +02:00
|
|
|
data->srcy + scanline,
|
2016-05-06 11:48:07 +02:00
|
|
|
data->width,
|
|
|
|
num_scanlines,
|
|
|
|
data->mode,
|
|
|
|
data->accumulate);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IMB_rectblend_threaded(ImBuf *dbuf,
|
2019-09-25 09:11:00 +02:00
|
|
|
const ImBuf *obuf,
|
|
|
|
const ImBuf *sbuf,
|
2016-05-06 11:48:07 +02:00
|
|
|
unsigned short *dmask,
|
2019-09-25 09:11:00 +02:00
|
|
|
const unsigned short *curvemask,
|
|
|
|
const unsigned short *texmask,
|
2016-05-06 11:48:07 +02:00
|
|
|
float mask_max,
|
|
|
|
int destx,
|
|
|
|
int desty,
|
|
|
|
int origx,
|
|
|
|
int origy,
|
|
|
|
int srcx,
|
|
|
|
int srcy,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
IMB_BlendMode mode,
|
|
|
|
bool accumulate)
|
|
|
|
{
|
|
|
|
if (((size_t)width) * height < 64 * 64) {
|
|
|
|
IMB_rectblend(dbuf,
|
|
|
|
obuf,
|
|
|
|
sbuf,
|
|
|
|
dmask,
|
|
|
|
curvemask,
|
|
|
|
texmask,
|
|
|
|
mask_max,
|
|
|
|
destx,
|
|
|
|
desty,
|
|
|
|
origx,
|
|
|
|
origy,
|
|
|
|
srcx,
|
|
|
|
srcy,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
mode,
|
|
|
|
accumulate);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
RectBlendThreadData data;
|
|
|
|
data.dbuf = dbuf;
|
|
|
|
data.obuf = obuf;
|
|
|
|
data.sbuf = sbuf;
|
|
|
|
data.dmask = dmask;
|
|
|
|
data.curvemask = curvemask;
|
|
|
|
data.texmask = texmask;
|
|
|
|
data.mask_max = mask_max;
|
|
|
|
data.destx = destx;
|
|
|
|
data.desty = desty;
|
|
|
|
data.origx = origx;
|
|
|
|
data.origy = origy;
|
|
|
|
data.srcx = srcx;
|
|
|
|
data.srcy = srcy;
|
|
|
|
data.width = width;
|
|
|
|
data.mode = mode;
|
|
|
|
data.accumulate = accumulate;
|
|
|
|
IMB_processor_apply_threaded_scanlines(height, rectblend_thread_do, &data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-30 08:07:42 +02:00
|
|
|
void IMB_rectfill(ImBuf *drect, const float col[4])
|
2002-10-12 13:37:38 +02:00
|
|
|
{
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 01:40:35 +01:00
|
|
|
int num;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (drect->rect) {
|
2007-02-15 11:46:10 +01:00
|
|
|
unsigned int *rrect = drect->rect;
|
|
|
|
char ccol[4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-08 13:48:19 +02:00
|
|
|
ccol[0] = (int)(col[0] * 255);
|
|
|
|
ccol[1] = (int)(col[1] * 255);
|
|
|
|
ccol[2] = (int)(col[2] * 255);
|
|
|
|
ccol[3] = (int)(col[3] * 255);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2007-02-15 11:46:10 +01:00
|
|
|
num = drect->x * drect->y;
|
2019-04-23 03:01:30 +02:00
|
|
|
for (; num > 0; num--) {
|
2012-05-08 13:48:19 +02:00
|
|
|
*rrect++ = *((unsigned int *)ccol);
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2007-02-15 11:46:10 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (drect->rect_float) {
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 01:40:35 +01:00
|
|
|
float *rrectf = drect->rect_float;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 01:40:35 +01:00
|
|
|
num = drect->x * drect->y;
|
2012-05-08 13:48:19 +02:00
|
|
|
for (; num > 0; num--) {
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 01:40:35 +01:00
|
|
|
*rrectf++ = col[0];
|
|
|
|
*rrectf++ = col[1];
|
|
|
|
*rrectf++ = col[2];
|
|
|
|
*rrectf++ = col[3];
|
|
|
|
}
|
2012-10-21 07:46:41 +02:00
|
|
|
}
|
2002-10-12 13:37:38 +02:00
|
|
|
}
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 01:40:35 +01:00
|
|
|
|
2020-11-02 22:15:52 +01:00
|
|
|
void IMB_rectfill_area_replace(
|
|
|
|
const ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2)
|
|
|
|
{
|
|
|
|
/* Sanity checks. */
|
|
|
|
BLI_assert(ibuf->channels == 4);
|
|
|
|
|
|
|
|
if (ibuf->channels != 4) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int width = ibuf->x;
|
|
|
|
int height = ibuf->y;
|
|
|
|
CLAMP(x1, 0, width);
|
|
|
|
CLAMP(x2, 0, width);
|
|
|
|
CLAMP(y1, 0, height);
|
|
|
|
CLAMP(y2, 0, height);
|
|
|
|
|
|
|
|
if (x1 > x2) {
|
|
|
|
SWAP(int, x1, x2);
|
|
|
|
}
|
|
|
|
if (y1 > y2) {
|
|
|
|
SWAP(int, y1, y2);
|
|
|
|
}
|
|
|
|
if (x1 == x2 || y1 == y2) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char col_char[4] = {col[0] * 255, col[1] * 255, col[2] * 255, col[3] * 255};
|
|
|
|
|
|
|
|
for (int y = y1; y < y2; y++) {
|
|
|
|
for (int x = x1; x < x2; x++) {
|
|
|
|
size_t offset = ((size_t)ibuf->x) * y * 4 + 4 * x;
|
|
|
|
|
|
|
|
if (ibuf->rect) {
|
|
|
|
unsigned char *rrect = (unsigned char *)ibuf->rect + offset;
|
|
|
|
memcpy(rrect, &col_char, sizeof(unsigned char) * 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ibuf->rect_float) {
|
|
|
|
float *rrectf = ibuf->rect_float + offset;
|
|
|
|
memcpy(rrectf, &col, sizeof(float) * 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-13 00:50:21 +02:00
|
|
|
void buf_rectfill_area(unsigned char *rect,
|
|
|
|
float *rectf,
|
|
|
|
int width,
|
|
|
|
int height,
|
2012-10-21 07:46:41 +02:00
|
|
|
const float col[4],
|
|
|
|
struct ColorManagedDisplay *display,
|
|
|
|
int x1,
|
|
|
|
int y1,
|
|
|
|
int x2,
|
|
|
|
int y2)
|
2007-10-20 18:17:27 +02:00
|
|
|
{
|
|
|
|
int i, j;
|
2008-02-22 00:19:06 +01:00
|
|
|
float a; /* alpha */
|
|
|
|
float ai; /* alpha inverted */
|
|
|
|
float aich; /* alpha, inverted, ai/255.0 - Convert char to float at the same time */
|
2019-04-23 03:01:30 +02:00
|
|
|
if ((!rect && !rectf) || (!col) || col[3] == 0.0f) {
|
2007-10-20 18:17:27 +02:00
|
|
|
return;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2007-10-20 18:17:27 +02:00
|
|
|
/* sanity checks for coords */
|
2007-10-28 23:27:07 +01:00
|
|
|
CLAMP(x1, 0, width);
|
|
|
|
CLAMP(x2, 0, width);
|
|
|
|
CLAMP(y1, 0, height);
|
|
|
|
CLAMP(y2, 0, height);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-23 03:01:30 +02:00
|
|
|
if (x1 > x2) {
|
2012-05-08 13:48:19 +02:00
|
|
|
SWAP(int, x1, x2);
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
|
|
|
if (y1 > y2) {
|
2012-05-08 13:48:19 +02:00
|
|
|
SWAP(int, y1, y2);
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
|
|
|
if (x1 == x2 || y1 == y2) {
|
2012-05-08 13:48:19 +02:00
|
|
|
return;
|
2019-04-23 03:01:30 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Patch by GSR #7628, I also added alpha for text background.
The list of changes (some are fixes):
- Properly horizontally centered tags in all fields (bug?).
- File area does not have trailing space and has leading "File " at
start instead (probably a bug).
- Small separation between to time related fields, space saving.
- Removed colons, for consistency and space saving again.
- Frame field is zero aligned for higher visual stability.
- Marker name shows a rarer name, "<none>" (using <> is typical for cases
in which there is nothing: <none>, <empty>, <blank>, etc).
- Top area for misc info that can be really long (file, note and render date).
- Bottom area for more constantly changing but short ones (marker, SMPTE,
frame, camera and scene).
- Only render date moves a line (when note field is not used), and frame one
moves if no SMPTE (still in same line, so no big jump), for extra visual
stability (marker is fixed, assuming most people would show frame and or
SMPTE).
- ISO 8601 date format for render date, localization independant.
Comparision images:
http://www.infernal-iceberg.com/blender/stamp-original.png
http://www.infernal-iceberg.com/blender/stamp-cleanup.png
2007-10-24 00:51:50 +02:00
|
|
|
a = col[3];
|
2012-05-08 13:48:19 +02:00
|
|
|
ai = 1 - a;
|
|
|
|
aich = ai / 255.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2007-10-28 23:27:07 +01:00
|
|
|
if (rect) {
|
2018-06-17 17:04:54 +02:00
|
|
|
unsigned char *pixel;
|
2012-05-08 13:48:19 +02:00
|
|
|
unsigned char chr = 0, chg = 0, chb = 0;
|
|
|
|
float fr = 0, fg = 0, fb = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-07 17:31:28 +02:00
|
|
|
const int alphaint = unit_float_to_uchar_clamp(a);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-03-27 19:12:59 +02:00
|
|
|
if (a == 1.0f) {
|
2018-05-07 17:31:28 +02:00
|
|
|
chr = unit_float_to_uchar_clamp(col[0]);
|
|
|
|
chg = unit_float_to_uchar_clamp(col[1]);
|
|
|
|
chb = unit_float_to_uchar_clamp(col[2]);
|
2012-03-24 07:38:07 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-05-08 13:48:19 +02:00
|
|
|
fr = col[0] * a;
|
|
|
|
fg = col[1] * a;
|
|
|
|
fb = col[2] * a;
|
2007-10-28 23:27:07 +01:00
|
|
|
}
|
2012-05-08 13:48:19 +02:00
|
|
|
for (j = 0; j < y2 - y1; j++) {
|
|
|
|
for (i = 0; i < x2 - x1; i++) {
|
2007-10-28 23:27:07 +01:00
|
|
|
pixel = rect + 4 * (((y1 + j) * width) + (x1 + i));
|
2012-05-08 13:48:19 +02:00
|
|
|
if (pixel >= rect && pixel < rect + (4 * (width * height))) {
|
2011-03-27 19:12:59 +02:00
|
|
|
if (a == 1.0f) {
|
2007-10-28 23:27:07 +01:00
|
|
|
pixel[0] = chr;
|
|
|
|
pixel[1] = chg;
|
|
|
|
pixel[2] = chb;
|
2011-08-31 03:05:40 +02:00
|
|
|
pixel[3] = 255;
|
2012-03-24 07:38:07 +01:00
|
|
|
}
|
|
|
|
else {
|
2011-08-31 03:05:40 +02:00
|
|
|
int alphatest;
|
2012-05-08 13:48:19 +02:00
|
|
|
pixel[0] = (char)((fr + ((float)pixel[0] * aich)) * 255.0f);
|
|
|
|
pixel[1] = (char)((fg + ((float)pixel[1] * aich)) * 255.0f);
|
|
|
|
pixel[2] = (char)((fb + ((float)pixel[2] * aich)) * 255.0f);
|
|
|
|
pixel[3] = (char)((alphatest = ((int)pixel[3] + alphaint)) < 255 ? alphatest : 255);
|
Patch by GSR #7628, I also added alpha for text background.
The list of changes (some are fixes):
- Properly horizontally centered tags in all fields (bug?).
- File area does not have trailing space and has leading "File " at
start instead (probably a bug).
- Small separation between to time related fields, space saving.
- Removed colons, for consistency and space saving again.
- Frame field is zero aligned for higher visual stability.
- Marker name shows a rarer name, "<none>" (using <> is typical for cases
in which there is nothing: <none>, <empty>, <blank>, etc).
- Top area for misc info that can be really long (file, note and render date).
- Bottom area for more constantly changing but short ones (marker, SMPTE,
frame, camera and scene).
- Only render date moves a line (when note field is not used), and frame one
moves if no SMPTE (still in same line, so no big jump), for extra visual
stability (marker is fixed, assuming most people would show frame and or
SMPTE).
- ISO 8601 date format for render date, localization independant.
Comparision images:
http://www.infernal-iceberg.com/blender/stamp-original.png
http://www.infernal-iceberg.com/blender/stamp-cleanup.png
2007-10-24 00:51:50 +02:00
|
|
|
}
|
2007-10-20 18:17:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2007-10-28 23:27:07 +01:00
|
|
|
if (rectf) {
|
2012-08-13 00:50:21 +02:00
|
|
|
float col_conv[4];
|
2007-10-28 23:27:07 +01:00
|
|
|
float *pixel;
|
2019-04-17 06:17:24 +02: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 12:05:07 +02:00
|
|
|
if (display) {
|
|
|
|
copy_v4_v4(col_conv, col);
|
|
|
|
IMB_colormanagement_display_to_scene_linear_v3(col_conv, display);
|
2012-08-13 00:50:21 +02:00
|
|
|
}
|
|
|
|
else {
|
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 12:05:07 +02:00
|
|
|
srgb_to_linearrgb_v4(col_conv, col);
|
2012-08-13 00:50:21 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-08 13:48:19 +02:00
|
|
|
for (j = 0; j < y2 - y1; j++) {
|
|
|
|
for (i = 0; i < x2 - x1; i++) {
|
2007-10-28 23:27:07 +01:00
|
|
|
pixel = rectf + 4 * (((y1 + j) * width) + (x1 + i));
|
2011-03-27 19:12:59 +02:00
|
|
|
if (a == 1.0f) {
|
2012-08-13 00:50:21 +02:00
|
|
|
pixel[0] = col_conv[0];
|
|
|
|
pixel[1] = col_conv[1];
|
|
|
|
pixel[2] = col_conv[2];
|
2011-08-31 03:05:40 +02:00
|
|
|
pixel[3] = 1.0f;
|
2012-03-24 07:38:07 +01:00
|
|
|
}
|
|
|
|
else {
|
2011-08-31 03:05:40 +02:00
|
|
|
float alphatest;
|
2012-08-13 00:50:21 +02:00
|
|
|
pixel[0] = (col_conv[0] * a) + (pixel[0] * ai);
|
|
|
|
pixel[1] = (col_conv[1] * a) + (pixel[1] * ai);
|
|
|
|
pixel[2] = (col_conv[2] * a) + (pixel[2] * ai);
|
2012-05-08 13:48:19 +02:00
|
|
|
pixel[3] = (alphatest = (pixel[3] + a)) < 1.0f ? alphatest : 1.0f;
|
Patch by GSR #7628, I also added alpha for text background.
The list of changes (some are fixes):
- Properly horizontally centered tags in all fields (bug?).
- File area does not have trailing space and has leading "File " at
start instead (probably a bug).
- Small separation between to time related fields, space saving.
- Removed colons, for consistency and space saving again.
- Frame field is zero aligned for higher visual stability.
- Marker name shows a rarer name, "<none>" (using <> is typical for cases
in which there is nothing: <none>, <empty>, <blank>, etc).
- Top area for misc info that can be really long (file, note and render date).
- Bottom area for more constantly changing but short ones (marker, SMPTE,
frame, camera and scene).
- Only render date moves a line (when note field is not used), and frame one
moves if no SMPTE (still in same line, so no big jump), for extra visual
stability (marker is fixed, assuming most people would show frame and or
SMPTE).
- ISO 8601 date format for render date, localization independant.
Comparision images:
http://www.infernal-iceberg.com/blender/stamp-original.png
http://www.infernal-iceberg.com/blender/stamp-cleanup.png
2007-10-24 00:51:50 +02:00
|
|
|
}
|
2007-10-20 18:17:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-28 23:27:07 +01:00
|
|
|
|
2013-04-30 08:07:42 +02:00
|
|
|
void IMB_rectfill_area(ImBuf *ibuf,
|
|
|
|
const float col[4],
|
|
|
|
int x1,
|
|
|
|
int y1,
|
|
|
|
int x2,
|
|
|
|
int y2,
|
|
|
|
struct ColorManagedDisplay *display)
|
2007-10-28 23:27:07 +01:00
|
|
|
{
|
2019-04-23 03:01:30 +02:00
|
|
|
if (!ibuf) {
|
2007-10-28 23:27:07 +01:00
|
|
|
return;
|
2019-04-23 03:01:30 +02: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 12:05:07 +02:00
|
|
|
buf_rectfill_area((unsigned char *)ibuf->rect,
|
|
|
|
ibuf->rect_float,
|
|
|
|
ibuf->x,
|
|
|
|
ibuf->y,
|
|
|
|
col,
|
|
|
|
display,
|
2012-11-09 10:33:28 +01:00
|
|
|
x1,
|
|
|
|
y1,
|
|
|
|
x2,
|
|
|
|
y2);
|
2007-10-28 23:27:07 +01:00
|
|
|
}
|
2011-06-15 03:56:49 +02:00
|
|
|
|
|
|
|
void IMB_rectfill_alpha(ImBuf *ibuf, const float value)
|
|
|
|
{
|
|
|
|
int i;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-02-12 16:58:06 +01:00
|
|
|
if (ibuf->rect_float && (ibuf->channels == 4)) {
|
|
|
|
float *fbuf = ibuf->rect_float + 3;
|
2012-05-08 13:48:19 +02:00
|
|
|
for (i = ibuf->x * ibuf->y; i > 0; i--, fbuf += 4) {
|
|
|
|
*fbuf = value;
|
|
|
|
}
|
2011-06-15 03:56:49 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-02-12 15:58:58 +01:00
|
|
|
if (ibuf->rect) {
|
2012-05-08 13:48:19 +02:00
|
|
|
const unsigned char cvalue = value * 255;
|
|
|
|
unsigned char *cbuf = ((unsigned char *)ibuf->rect) + 3;
|
|
|
|
for (i = ibuf->x * ibuf->y; i > 0; i--, cbuf += 4) {
|
|
|
|
*cbuf = cvalue;
|
|
|
|
}
|
2011-06-15 03:56:49 +02:00
|
|
|
}
|
|
|
|
}
|