diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-01-05 19:33:18 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-01-05 19:33:18 +0400 |
commit | fa0805e287e762df3638df1982297c794c4cf4b7 (patch) | |
tree | 1b2a7d612bde64569aad2afd72410a43a8147f27 /source/blender/imbuf | |
parent | e8b415bdb4ba282e3574cad1463bf2512fe5eb8f (diff) |
Changes for opengl render to reflect new alpha premul pipeline
without hurting quick texture painting
- ED_view3d_draw_offscreen will now output buffer with
transparent alpha, if sky needed it should be alpha-undered
later.
- ED_view3d_draw_offscreen_imbuf now accepts alpha mode as an
argument which could be either R_ADDSKY or R_PREMULALPHA
- OpenGL render and sequencer's opengl preview will now reflect
scene's Alpha Mode
- Quick Edit will use OpenGL with transparent alpha mode
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r-- | source/blender/imbuf/IMB_imbuf.h | 3 | ||||
-rw-r--r-- | source/blender/imbuf/intern/imageprocess.c | 50 |
2 files changed, 53 insertions, 0 deletions
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 850060ef4d5..8d60227377b 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -416,6 +416,9 @@ void nearest_interpolation_color(struct ImBuf *in, unsigned char col[4], float c void bilinear_interpolation_color(struct ImBuf *in, unsigned char col[4], float col_float[4], float u, float v); void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char col[4], float col_float[4], float u, float v); +void IMB_alpha_under_color_float(float *rect_float, int x, int y, float backcol[3]); +void IMB_alpha_under_color_byte(unsigned char *rect, int x, int y, float backcol[3]); + /** * * \attention defined in readimage.c diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c index 1eac6236829..59282c9d207 100644 --- a/source/blender/imbuf/intern/imageprocess.c +++ b/source/blender/imbuf/intern/imageprocess.c @@ -327,3 +327,53 @@ void IMB_processor_apply_threaded(int buffer_lines, int handle_size, void *init_ MEM_freeN(handles); } + +/* Alpha-under */ + +void IMB_alpha_under_color_float(float *rect_float, int x, int y, float backcol[3]) +{ + int a = x * y; + float *fp = rect_float; + + while (a--) { + if (fp[3] == 0.0f) { + copy_v3_v3(fp, backcol); + } + else { + float mul = 1.0f - fp[3]; + + fp[0] += mul * backcol[0]; + fp[1] += mul * backcol[1]; + fp[2] += mul * backcol[2]; + } + + fp[3] = 1.0f; + + fp += 4; + } +} + +void IMB_alpha_under_color_byte(unsigned char *rect, int x, int y, float backcol[3]) +{ + int a = x * y; + unsigned char *cp = rect; + + while (a--) { + if (cp[3] == 0) { + cp[0] = backcol[0] * 255; + cp[1] = backcol[1] * 255; + cp[2] = backcol[2] * 255; + } + else { + int mul = 255 - cp[3]; + + cp[0] += mul * backcol[0] / 255; + cp[1] += mul * backcol[1] / 255; + cp[2] += mul * backcol[2] / 255; + } + + cp[3] = 255; + + cp += 4; + } +} |