[Bf-blender-cvs] [541e81ac96e] greasepencil-object: Fix color distorsion while drawing
Antonio Vazquez
noreply at git.blender.org
Wed Jul 12 14:12:26 CEST 2017
Commit: 541e81ac96eb7fbd5265db53043908cc7b7425e3
Author: Antonio Vazquez
Date: Wed Jul 12 14:12:14 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB541e81ac96eb7fbd5265db53043908cc7b7425e3
Fix color distorsion while drawing
Need to use the mix_pass in order to get the same color while drawing. If the pass is not mixed with the same pass than strokes, there is a change in the color between drawing stroke and final stroke due the process to mix.
This is slower, but needed and while drawing the time delay is negligible
===================================================================
M source/blender/draw/engines/gpencil/gpencil_engine.c
===================================================================
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 9a0eace5a30..95d2c259959 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -299,6 +299,11 @@ static void GPENCIL_draw_scene(void *vedata)
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
float clearcol[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
int init_grp, end_grp;
+ bool is_drawing_session = false;
+
+ /* attach temp textures */
+ DRW_framebuffer_texture_attach(fbl->temp_color_fb, e_data.temp_fbcolor_depth_tx, 0, 0);
+ DRW_framebuffer_texture_attach(fbl->temp_color_fb, e_data.temp_fbcolor_color_tx, 0, 0);
/* Draw all pending objects */
if (stl->g_data->gp_cache_used > 0) {
@@ -307,12 +312,11 @@ static void GPENCIL_draw_scene(void *vedata)
qsort(stl->g_data->gp_object_cache, stl->g_data->gp_cache_used,
sizeof(tGPencilObjectCache), gpencil_object_cache_compare_zdepth);
- /* attach temp textures */
- DRW_framebuffer_texture_attach(fbl->temp_color_fb, e_data.temp_fbcolor_depth_tx, 0, 0);
- DRW_framebuffer_texture_attach(fbl->temp_color_fb, e_data.temp_fbcolor_color_tx, 0, 0);
for (int i = 0; i < stl->g_data->gp_cache_used; ++i) {
Object *ob = stl->g_data->gp_object_cache[i].ob;
+ is_drawing_session = (bool) (ob->gpd->sbuffer_size > 0);
+
init_grp = stl->g_data->gp_object_cache[i].init_grp;
end_grp = stl->g_data->gp_object_cache[i].end_grp;
if (end_grp >= init_grp) {
@@ -341,18 +345,31 @@ static void GPENCIL_draw_scene(void *vedata)
/* edit points */
DRW_draw_pass(psl->edit_pass);
- /* detach temp textures */
- DRW_framebuffer_texture_detach(e_data.temp_fbcolor_depth_tx);
- DRW_framebuffer_texture_detach(e_data.temp_fbcolor_color_tx);
-
- /* attach again default framebuffer */
- DRW_framebuffer_bind(dfbl->default_fb);
}
/* free memory */
MEM_SAFE_FREE(stl->g_data->gp_object_cache);
- /* current drawing buffer */
- DRW_draw_pass(psl->drawing_pass);
+ /* current drawing buffer
+ * Need to use the mix_pass in order to get the same color while drawing. If the pass is not mixed with the
+ * same pass than strokes, there is a change in the color between drawing stroke and final stroke due the process
+ * to mix. This is slower, but needed and while drawing the time delay is negligible
+ */
+ if (is_drawing_session) {
+ DRW_framebuffer_bind(fbl->temp_color_fb);
+ DRW_framebuffer_clear(true, true, false, clearcol, 1.0f);
+
+ DRW_draw_pass(psl->drawing_pass);
+
+ DRW_framebuffer_bind(dfbl->default_fb);
+ DRW_draw_pass(psl->mix_pass);
+ }
+
+ /* detach temp textures */
+ DRW_framebuffer_texture_detach(e_data.temp_fbcolor_depth_tx);
+ DRW_framebuffer_texture_detach(e_data.temp_fbcolor_color_tx);
+
+ /* attach again default framebuffer */
+ DRW_framebuffer_bind(dfbl->default_fb);
}
static const DrawEngineDataSize GPENCIL_data_size = DRW_VIEWPORT_DATA_SIZE(GPENCIL_Data);
More information about the Bf-blender-cvs
mailing list