From 247c7078bc1ae60a21748f16f331390d4f46d212 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 1 Jan 2013 19:02:08 +0000 Subject: Bug fixes, own collection. While examining icons, I noticed material icons were too dark. It appeared a lot of bad hacks were added for colormanagement in preview render. Removed them all, and things look smooth (yes, color management is OK!). However! It is now very clear that Procedural Textures miss getting inverse color managed in render - a reason why they show so bright washed out, already since introduction of Color Management in Blender. Try render a plane with linear black-white blend, shadeless! http://www.blender.org/bf/Untitled.png Todo: add colormanaged procedurals (optional). --- source/blender/editors/render/render_preview.c | 57 ++++++-------------------- 1 file changed, 12 insertions(+), 45 deletions(-) (limited to 'source/blender/editors/render') diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 6ca8478b489..8d748d3ea20 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -280,11 +280,6 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre sce->r.tiley = sce->r.ysch / 4; } - /* exception: don't apply render part of display transform for texture previews or icons */ - if ((id && sp->pr_method == PR_ICON_RENDER) || id_type == ID_TE) { - BKE_scene_disable_color_management(sce); - } - if ((id && sp->pr_method == PR_ICON_RENDER) && id_type != ID_WO) sce->r.alphamode = R_ALPHAPREMUL; else @@ -488,24 +483,15 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre /* new UI convention: draw is in pixel space already. */ /* uses ROUNDBOX button in block to get the rect */ -static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int first, rcti *rect, rcti *newrect) +static int ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect, rcti *newrect) { Render *re; RenderResult rres; char name[32]; - int do_gamma_correct = FALSE, do_predivide = FALSE; int offx = 0; int newx = BLI_rcti_size_x(rect); int newy = BLI_rcti_size_y(rect); - if (id && GS(id->name) != ID_TE) { - /* exception: don't color manage texture previews - show the raw values */ - if (sce) { - do_gamma_correct = TRUE; - do_predivide = TRUE; - } - } - if (!split || first) sprintf(name, "Preview %p", (void *)sa); else sprintf(name, "SecondPreview %p", (void *)sa); @@ -520,8 +506,10 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int } } + /* test if something rendered ok */ re = RE_GetRender(name); RE_AcquireResultImage(re, &rres); + RE_ReleaseResultImage(re); if (rres.rectf) { @@ -531,40 +519,20 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int newrect->ymax = max_ii(newrect->ymax, rect->ymin + rres.recty); if (rres.rectx && rres.recty) { - /* temporary conversion to byte for drawing */ + unsigned char *rect_byte = MEM_mallocN(rres.rectx * rres.recty * sizeof(int), "ed_preview_draw_rect"); float fx = rect->xmin + offx; float fy = rect->ymin; - int dither = 0; - unsigned char *rect_byte; - - rect_byte = MEM_mallocN(rres.rectx * rres.recty * sizeof(int), "ed_preview_draw_rect"); - - if (do_gamma_correct) { - IMB_display_buffer_transform_apply(rect_byte, rres.rectf, rres.rectx, rres.recty, 4, - &sce->view_settings, &sce->display_settings, do_predivide); - - } - else { - /* OCIO_TODO: currently seems an exception for textures (came fro mlegacish time), - * but is it indeed expected behavior, or textures should be - * color managed as well? - */ - IMB_buffer_byte_from_float(rect_byte, rres.rectf, - 4, dither, IB_PROFILE_SRGB, IB_PROFILE_SRGB, do_predivide, - rres.rectx, rres.recty, rres.rectx, rres.rectx); - } - + + RE_ResultGet32(re, (unsigned int *)rect_byte); glaDrawPixelsSafe(fx, fy, rres.rectx, rres.recty, rres.rectx, GL_RGBA, GL_UNSIGNED_BYTE, rect_byte); - + MEM_freeN(rect_byte); + + return 1; } - - RE_ReleaseResultImage(re); - return 1; } } - RE_ReleaseResultImage(re); return 0; } @@ -572,7 +540,6 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r { if (idp) { ScrArea *sa = CTX_wm_area(C); - Scene *sce = CTX_data_scene(C); ID *id = (ID *)idp; ID *parent = (ID *)parentp; MTex *slot = (MTex *)slotp; @@ -588,11 +555,11 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r newrect.ymax = rect->ymin; if (parent) { - ok = ed_preview_draw_rect(sa, sce, id, 1, 1, rect, &newrect); - ok &= ed_preview_draw_rect(sa, sce, parent, 1, 0, rect, &newrect); + ok = ed_preview_draw_rect(sa, 1, 1, rect, &newrect); + ok &= ed_preview_draw_rect(sa, 1, 0, rect, &newrect); } else - ok = ed_preview_draw_rect(sa, sce, id, 0, 0, rect, &newrect); + ok = ed_preview_draw_rect(sa, 0, 0, rect, &newrect); if (ok) *rect = newrect; -- cgit v1.2.3