diff options
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_proj.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawmesh.c | 5 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 18 | ||||
-rw-r--r-- | source/blender/imbuf/intern/divers.c | 1 |
4 files changed, 13 insertions, 21 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index e10c97ea9f0..516666e8c2c 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -4852,7 +4852,7 @@ bool proj_paint_add_slot(bContext *C, Material *ma, wmOperator *op) mtex->mapto = type; if (mtex->tex) { - float color[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + float color[4] = {0.0f, 0.0f, 0.0f, 0.0f}; char imagename[MAX_ID_NAME - 2] = "Material Diffuse Color"; int width = 1024; int height = 1024; @@ -4870,12 +4870,6 @@ bool proj_paint_add_slot(bContext *C, Material *ma, wmOperator *op) RNA_string_get(op->ptr, "name", imagename); } - if (!use_float) { - /* crappy workaround because we only upload straight color to OpenGL and that makes - * painting result on viewport too opaque */ - color[3] = 1.0; - } - ima = mtex->tex->ima = BKE_image_add_generated(bmain, width, height, imagename, alpha ? 32 : 24, use_float, gen_type, color); @@ -4926,7 +4920,7 @@ static int texture_paint_add_texture_paint_slot_invoke(bContext *C, wmOperator * void PAINT_OT_add_texture_paint_slot(wmOperatorType *ot) { PropertyRNA *prop; - static float default_color[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + static float default_color[4] = {0.0f, 0.0f, 0.0f, 0.0f}; /* identifiers */ ot->name = "Add Texture Paint Slot"; diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 89babf977e1..e571584a10f 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -303,11 +303,13 @@ static bool set_draw_settings_cached(int clearcache, MTFace *texface, Material * c_badtex = false; if (GPU_verify_image(ima, NULL, 0, 1, 0, false)) { glEnable(GL_TEXTURE_2D); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); } else { c_badtex = true; GPU_clear_tpage(true); glDisable(GL_TEXTURE_2D); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBindTexture(GL_TEXTURE_2D, 0); } } @@ -437,7 +439,8 @@ static void draw_textured_end(void) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL_TEXTURE0); - } + } + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); /* manual reset, since we don't use tpage */ glBindTexture(GL_TEXTURE_2D, 0); /* force switch off textures */ diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 8abe7d5534a..7295f0259c5 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -1039,21 +1039,14 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h) * which is much quicker for painting */ GLint row_length, skip_pixels, skip_rows; - glGetIntegerv(GL_UNPACK_ROW_LENGTH, &row_length); - glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skip_pixels); - glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skip_rows); - /* if color correction is needed, we must update the part that needs updating. */ if (ibuf->rect_float) { - float *buffer = MEM_mallocN(w*h*sizeof(float)*4, "temp_texpaint_float_buf"); + float *buffer = MEM_mallocN(w * h * sizeof(float) * 4, "temp_texpaint_float_buf"); bool is_data = (ima->tpageflag & IMA_GLBIND_IS_DATA) != 0; IMB_partial_rect_from_float(ibuf, buffer, x, y, w, h, is_data); - + if (GPU_check_scaled_image(ibuf, ima, buffer, x, y, w, h)) { MEM_freeN(buffer); - glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels); - glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows); BKE_image_release_ibuf(ima, ibuf, NULL); return; } @@ -1078,15 +1071,16 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h) } if (GPU_check_scaled_image(ibuf, ima, NULL, x, y, w, h)) { - glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels); - glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows); BKE_image_release_ibuf(ima, ibuf, NULL); return; } glBindTexture(GL_TEXTURE_2D, ima->bindcode); + glGetIntegerv(GL_UNPACK_ROW_LENGTH, &row_length); + glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skip_pixels); + glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skip_rows); + glPixelStorei(GL_UNPACK_ROW_LENGTH, ibuf->x); glPixelStorei(GL_UNPACK_SKIP_PIXELS, x); glPixelStorei(GL_UNPACK_SKIP_ROWS, y); diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c index 9975c58bdd2..03cd5ecd646 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.c @@ -720,6 +720,7 @@ void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w ibuf->channels, IB_PROFILE_SRGB, profile_from, true, w, h, w, ibuf->x); + IMB_buffer_float_unpremultiply(buffer, w, h); /* XXX: need to convert to image buffer's rect space */ IMB_buffer_byte_from_float(rect_byte, buffer, 4, ibuf->dither, IB_PROFILE_SRGB, IB_PROFILE_SRGB, 0, |