[Bf-blender-cvs] [30947f22084] soc-2018-npr: Now use one-time scene loading. Line/Polygon smooth added.
Nick Wu
noreply at git.blender.org
Thu Jun 7 13:50:02 CEST 2018
Commit: 30947f220847f1047bad9961ee70b11a96f31a14
Author: Nick Wu
Date: Thu Jun 7 18:56:17 2018 +0800
Branches: soc-2018-npr
https://developer.blender.org/rB30947f220847f1047bad9961ee70b11a96f31a14
Now use one-time scene loading. Line/Polygon smooth added.
===================================================================
M source/blender/draw/engines/lanpr/lanpr_all.h
M source/blender/draw/engines/lanpr/lanpr_dpix.c
M source/blender/draw/engines/lanpr/lanpr_engine.c
M source/blender/draw/engines/lanpr/lanpr_snake.c
===================================================================
diff --git a/source/blender/draw/engines/lanpr/lanpr_all.h b/source/blender/draw/engines/lanpr/lanpr_all.h
index 2a05dcfdac5..8e7acae20c6 100644
--- a/source/blender/draw/engines/lanpr/lanpr_all.h
+++ b/source/blender/draw/engines/lanpr/lanpr_all.h
@@ -145,6 +145,7 @@ typedef struct LANPR_PrivateData {
BLI_mempool* mp_sample;
BLI_mempool* mp_line_strip;
BLI_mempool* mp_line_strip_point;
+ BLI_mempool* mp_batch_list;
ListBase pending_samples;
ListBase erased_samples;
@@ -174,12 +175,21 @@ typedef struct LANPR_PrivateData {
Gwn_VertFormat snake_gwn_format;
Gwn_Batch* snake_batch;
+ ListBase dpix_batch_list;
+
} LANPR_PrivateData;
typedef struct LANPR_StorageList {
LANPR_PrivateData *g_data;
} LANPR_StorageList;
+typedef struct LANPR_BatchItem {
+ Link Item;
+ Gwn_Batch* dpix_transform_batch;
+ Gwn_Batch* dpix_preview_batch;
+ Object* ob;
+} LANPR_BatchItem;
+
typedef struct LANPR_Data {
void *engine_type;
LANPR_FramebufferList *fbl;
@@ -291,7 +301,7 @@ int lanpr_feed_atlas_data_obj(void* vedata,
float* AtlasPointsL, float* AtlasPointsR,
float* AtlasFaceNormalL, float* AtlasFaceNormalR,
Object* ob, int BeginIndex);
-void lanpr_feed_atlas_trigger_preview_obj(void* vedata, Object* ob, int BeginIndex);
+int lanpr_feed_atlas_trigger_preview_obj(void* vedata, Object* ob, int BeginIndex);
void lanpr_dpix_draw_scene(LANPR_TextureList* txl, LANPR_FramebufferList * fbl, LANPR_PassList *psl, LANPR_PrivateData *pd, SceneLANPR *lanpr);
diff --git a/source/blender/draw/engines/lanpr/lanpr_dpix.c b/source/blender/draw/engines/lanpr/lanpr_dpix.c
index 6fabd972249..2eae86b3242 100644
--- a/source/blender/draw/engines/lanpr/lanpr_dpix.c
+++ b/source/blender/draw/engines/lanpr/lanpr_dpix.c
@@ -45,7 +45,7 @@ void lanpr_init_atlas_inputs(void *ved){
Object *camera = (rv3d->persp == RV3D_CAMOB) ? v3d->camera : NULL;
SceneLANPR* lanpr=&draw_ctx->scene->lanpr;
- if(lanpr->reloaded){
+ if(lanpr->reloaded || !txl->dpix_in_pl){
DRW_texture_ensure_2D(&txl->dpix_in_pl, TNS_DPIX_TEXTURE_SIZE, TNS_DPIX_TEXTURE_SIZE, GPU_RGBA32F, 0);
DRW_texture_ensure_2D(&txl->dpix_in_pr, TNS_DPIX_TEXTURE_SIZE, TNS_DPIX_TEXTURE_SIZE, GPU_RGBA32F, 0);
DRW_texture_ensure_2D(&txl->dpix_in_nl, TNS_DPIX_TEXTURE_SIZE, TNS_DPIX_TEXTURE_SIZE, GPU_RGBA32F, 0);
@@ -192,6 +192,8 @@ int lanpr_feed_atlas_data_obj(void* vedata,
}
}
+
+ BM_mesh_free(bm);
return BeginIndex + edge_count;
}
@@ -205,11 +207,11 @@ void lanpr_dpix_index_to_coord_absolute(int index, float* x,float* y){
(*y) = (float)(index / TNS_DPIX_TEXTURE_SIZE)+0.5;
}
-void lanpr_feed_atlas_trigger_preview_obj(void* vedata, Object* ob, int BeginIndex) {
+int lanpr_feed_atlas_trigger_preview_obj(void* vedata, Object* ob, int BeginIndex) {
LANPR_StorageList *stl = ((LANPR_Data *)vedata)->stl;
LANPR_PrivateData* pd = stl->g_data;
Mesh* me = ob->data;
- if (ob->type != OB_MESH) return;
+ if (ob->type != OB_MESH) return BeginIndex;
int edge_count = me->totedge;
int i;
float co[2];
@@ -238,10 +240,16 @@ void lanpr_feed_atlas_trigger_preview_obj(void* vedata, Object* ob, int BeginInd
GWN_vertbuf_attr_set(vbo2, attr_id2.pos, i, co);
}
- Gwn_Batch* gb = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, 0, GWN_USAGE_STREAM);
- Gwn_Batch* gb2 = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo2, 0, GWN_USAGE_STREAM);
- DRW_shgroup_call_add(pd->dpix_transform_shgrp,gb,ob->obmat);
- DRW_shgroup_call_add(pd->dpix_preview_shgrp,gb2,0);
+ Gwn_Batch* gb = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, 0, GWN_USAGE_STATIC|GWN_BATCH_OWNS_VBO);
+ Gwn_Batch* gb2 = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo2, 0, GWN_USAGE_STATIC|GWN_BATCH_OWNS_VBO);
+
+ LANPR_BatchItem *bi = BLI_mempool_alloc(pd->mp_batch_list);
+ BLI_addtail(&pd->dpix_batch_list,bi);
+ bi->dpix_transform_batch = gb;
+ bi->dpix_preview_batch = gb2;
+ bi->ob = ob;
+
+ return BeginIndex + edge_count;
}
@@ -269,14 +277,22 @@ void lanpr_dpix_draw_scene(LANPR_TextureList* txl, LANPR_FramebufferList * fbl,
//GPU_disable_program_point_size();
DRW_draw_pass(psl->dpix_transform_pass);
- GPU_framebuffer_bind(fbl->edge_intermediate);
- DRW_draw_pass(psl->edge_intermediate);// use depth
+ //GPU_framebuffer_bind(fbl->edge_intermediate);
+ //DRW_draw_pass(psl->color_pass);// use depth
+
+ glEnable(GL_LINE_SMOOTH);
+ glHint(GL_LINE_SMOOTH, GL_NICEST);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GPU_framebuffer_bind(fbl->dpix_preview);
GPUFrameBufferBits clear_bits = GPU_COLOR_BIT;
GPU_framebuffer_clear(fbl->dpix_preview, clear_bits, lanpr->background_color, clear_depth, clear_stencil);
DRW_draw_pass(psl->dpix_preview_pass);
+ glDisable(GL_LINE_SMOOTH);
+ glDisable(GL_BLEND);
+
GPU_framebuffer_bind(dfbl->default_fb);
//DRW_transform_to_display(txl->dpix_out_pl);
DRW_transform_to_display(txl->color);
diff --git a/source/blender/draw/engines/lanpr/lanpr_engine.c b/source/blender/draw/engines/lanpr/lanpr_engine.c
index 7ef6276b230..5c5f934b7f6 100644
--- a/source/blender/draw/engines/lanpr/lanpr_engine.c
+++ b/source/blender/draw/engines/lanpr/lanpr_engine.c
@@ -54,7 +54,7 @@ static void lanpr_engine_init(void *ved){
Object *camera = (rv3d->persp == RV3D_CAMOB) ? v3d->camera : NULL;
SceneLANPR* lanpr = &draw_ctx->scene->lanpr;
- lanpr->reloaded = 1;
+ //lanpr->reloaded = 1;
if (!OneTime.InitComplete) {
lanpr->depth_clamp = 0.01;
@@ -177,10 +177,14 @@ static void lanpr_engine_free(void){
BLI_mempool_destroy(stl->g_data->mp_line_strip);
BLI_mempool_destroy(stl->g_data->mp_line_strip_point);
BLI_mempool_destroy(stl->g_data->mp_sample);
+ BLI_mempool_destroy(stl->g_data->mp_batch_list);
MEM_freeN(stl->g_data->line_result_8bit);
MEM_freeN(stl->g_data->line_result);
MEM_freeN(stl->g_data);
+
+ lanpr_destroy_atlas(vedata);
+
stl->g_data=0;
}
@@ -196,81 +200,84 @@ static void lanpr_cache_init(void *vedata){
stl->g_data->mp_sample = BLI_mempool_create(sizeof(LANPR_TextureSample), 0, 512, BLI_MEMPOOL_NOP);
stl->g_data->mp_line_strip = BLI_mempool_create(sizeof(LANPR_LineStrip), 0, 512, BLI_MEMPOOL_NOP);
stl->g_data->mp_line_strip_point = BLI_mempool_create(sizeof(LANPR_LineStripPoint), 0, 1024, BLI_MEMPOOL_NOP);
+ stl->g_data->mp_batch_list = BLI_mempool_create(sizeof(LANPR_BatchItem), 0, 128, BLI_MEMPOOL_NOP);
}
LANPR_PrivateData* pd = stl->g_data;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ View3D *v3d = draw_ctx->v3d;
+ SceneLANPR *lanpr = &draw_ctx->scene->lanpr;
+
psl->color_pass = DRW_pass_create("Color Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WRITE_DEPTH);
stl->g_data->multipass_shgrp = DRW_shgroup_create(OneTime.multichannel_shader, psl->color_pass);
- struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
-
-
- psl->edge_intermediate = DRW_pass_create("Edge Detection", DRW_STATE_WRITE_COLOR);
- stl->g_data->edge_detect_shgrp = DRW_shgroup_create(OneTime.edge_detect_shader, psl->edge_intermediate);
- DRW_shgroup_uniform_texture_ref(stl->g_data->edge_detect_shgrp, "TexSample0", &txl->depth);
- DRW_shgroup_uniform_texture_ref(stl->g_data->edge_detect_shgrp, "TexSample1", &txl->color);
- DRW_shgroup_uniform_texture_ref(stl->g_data->edge_detect_shgrp, "TexSample2", &txl->normal);
+ if(lanpr->master_mode == LANPR_MASTER_MODE_SNAKE){
+ struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
- DRW_shgroup_uniform_float(stl->g_data->edge_detect_shgrp, "zNear", &stl->g_data->znear, 1);
- DRW_shgroup_uniform_float(stl->g_data->edge_detect_shgrp, "zfFar", &stl->g_data->zfar, 1);
+ psl->edge_intermediate = DRW_pass_create("Edge Detection", DRW_STATE_WRITE_COLOR);
+ stl->g_data->edge_detect_shgrp = DRW_shgroup_create(OneTime.edge_detect_shader, psl->edge_intermediate);
+ DRW_shgroup_uniform_texture_ref(stl->g_data->edge_detect_shgrp, "TexSample0", &txl->depth);
+ DRW_shgroup_uniform_texture_ref(stl->g_data->edge_detect_shgrp, "TexSample1", &txl->color);
+ DRW_shgroup_uniform_texture_ref(stl->g_data->edge_detect_shgrp, "TexSample2", &txl->normal);
- DRW_shgroup_uniform_float(stl->g_data->edge_detect_shgrp, "uValue0", &stl->g_data->normal_clamp, 1);// normal clamp
- DRW_shgroup_uniform_float(stl->g_data->edge_detect_shgrp, "uValue1", &stl->g_data->normal_strength, 1);// normal strength
- DRW_shgroup_uniform_float(stl->g_data->edge_detect_shgrp, "uValue2", &stl->g_data->depth_clamp, 1);// depth clamp
- DRW_shgroup_uniform_float(stl->g_data->edge_detect_shgrp, "uValue3", &stl->g_data->depth_strength, 1);// depth strength
- DRW_shgroup_call_add(stl->g_data->edge_detect_shgrp, quad, NULL);
+ DRW_shgroup_uniform_float(stl->g_data->edge_detect_shgrp, "zNear", &stl->g_data->znear, 1);
+ DRW_shgroup_uniform_float(stl->g_data->edge_detect_shgrp, "zfFar", &stl->g_data->zfar, 1);
- psl->edge_thinning = DRW_pass_create("Edge Thinning Stage 1", DRW_STATE_WRITE_COLOR);
- stl->g_data->edge_thinning_shgrp = DRW_shgroup_create(OneTime.edge_thinning_shader, psl->edge_thinning);
- DRW_shgroup_uniform_texture_ref(stl->g_data->edge_thinning_shgrp, "TexSample0", &txl->edge_intermediate);
- DRW_shgroup_uniform_int(stl->g_data->edge_thinning_shgrp, "Stage", &stl->g_data->stage, 1);
- DRW_shgroup_call_add(stl->g_data->edge_thinning_shgrp, quad, NULL);
+ DRW_shgroup_uniform_float(stl->g_data->edge_detect_shgrp, "uValue0", &stl->g_data->normal_clamp, 1);// normal clamp
+ DRW_shgroup_uniform_float(stl->g_data->edge_detect_shgrp, "uValue1", &stl->g_data->normal_strength, 1);// normal strength
+ DRW_shgroup_uniform_float(stl->g_data->edge_detect_shgrp, "uValue2", &stl->g_data->depth_clamp, 1);// depth clamp
+ DRW_shgroup_uniform_float(stl->g_data->edge_detect_shgrp, "uValue3", &stl->g_data->depth_strength, 1);// depth strength
+ DRW_shgroup_call_add(stl->g_data->edge_detect_shgrp, quad, NULL);
- psl->edge_thinning_2 = DRW_pass_create("Edge Thinning Stage 2", DRW_STATE_WRITE_COLOR);
- stl->g_data->edge_thinning_shgrp_2 = DRW_shgroup_create(OneTime.edge_thinning_shader, psl->edge_thinning_2);
- DRW_shgroup_uniform_texture_ref(stl->g_data->edge_thinning_shgrp_2, "TexSample0", &txl->color);
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list