Commit: e406c67842479a78b8904671a8e9729fc8a505c7 Author: Nick Wu Date: Mon Jul 23 22:33:59 2018 +0800 Branches: soc-2018-npr https://developer.blender.org/rBe406c67842479a78b8904671a8e9729fc8a505c7
Provide a switch to enable chaining or not. =================================================================== M release/scripts/startup/bl_ui/properties_scene.py M source/blender/draw/CMakeLists.txt M source/blender/draw/engines/lanpr/lanpr_all.h M source/blender/draw/engines/lanpr/lanpr_engine.c M source/blender/draw/engines/lanpr/lanpr_ops.c A source/blender/draw/engines/lanpr/shaders/lanpr_software_chain.geometry M source/blender/draw/engines/lanpr/shaders/lanpr_software_line_width.geometry M source/blender/makesdna/DNA_lanpr_types.h M source/blender/makesdna/DNA_scene_types.h M source/blender/makesrna/intern/rna_scene.c =================================================================== diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index d8cc00d7afd..a95ed107725 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -618,10 +618,11 @@ class SCENE_PT_lanpr(SceneButtonsPanel, Panel): if lanpr.master_mode == "DPIX": layout.prop(lanpr, "reloaded") - rows = 4 if lanpr.master_mode == "SOFTWARE": layout.label(text="Enable On Demand:") - layout.prop(lanpr,"calculate_intersections", toggle = True, text = "Enable Intersection Lines") + row = layout.row() + row.prop(lanpr,"calculate_intersections", text = "Intersection Lines") + row.prop(lanpr,"enable_chaining", text = "Chaining (SLOW!)") layout.label(text="RUN:") layout.operator("scene.lanpr_calculate", icon='RENDER_STILL') layout.label(text="Layer Composition:") diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index a8c099dcdae..1ed2b724f7a 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -252,6 +252,8 @@ data_to_c_simple(engines/lanpr/shaders/lanpr_snake_edge.fragment SRC) data_to_c_simple(engines/lanpr/shaders/lanpr_snake_multichannel.fragment SRC) data_to_c_simple(engines/lanpr/shaders/lanpr_software_line_width.geometry SRC) data_to_c_simple(engines/lanpr/shaders/lanpr_software_scale_compensate.vertex SRC) +data_to_c_simple(engines/lanpr/shaders/lanpr_software_chain.geometry SRC) + data_to_c_simple(modes/shaders/common_globals_lib.glsl SRC) data_to_c_simple(modes/shaders/common_hair_lib.glsl SRC) diff --git a/source/blender/draw/engines/lanpr/lanpr_all.h b/source/blender/draw/engines/lanpr/lanpr_all.h index 1b070a54002..b9e5c9d3e30 100644 --- a/source/blender/draw/engines/lanpr/lanpr_all.h +++ b/source/blender/draw/engines/lanpr/lanpr_all.h @@ -64,6 +64,7 @@ typedef struct LANPROneTimeInit { /* Software */ GPUShader *software_shader; + GPUShader *software_chaining_shader; void *ved; diff --git a/source/blender/draw/engines/lanpr/lanpr_engine.c b/source/blender/draw/engines/lanpr/lanpr_engine.c index c7248182520..3c48ec0fae8 100644 --- a/source/blender/draw/engines/lanpr/lanpr_engine.c +++ b/source/blender/draw/engines/lanpr/lanpr_engine.c @@ -36,6 +36,7 @@ extern char datatoc_lanpr_line_connection_vertex[]; extern char datatoc_lanpr_line_connection_fragment[]; extern char datatoc_lanpr_line_connection_geometry[]; extern char datatoc_lanpr_software_line_width_geometry[]; +extern char datatoc_lanpr_software_chain_geometry[]; extern char datatoc_lanpr_atlas_project_passthrough_vertex[]; extern char datatoc_lanpr_atlas_preview_fragment[]; extern char datatoc_lanpr_software_scale_compensate_vertex[]; @@ -177,6 +178,15 @@ static void lanpr_engine_init(void *ved){ NULL, NULL); } + if (!OneTime.software_chaining_shader) { + OneTime.software_chaining_shader = + GPU_shader_create( + datatoc_lanpr_software_scale_compensate_vertex, + datatoc_lanpr_atlas_preview_fragment, + datatoc_lanpr_software_chain_geometry, + NULL, NULL); + } + GPU_framebuffer_ensure_config(&fbl->software_ms, { GPU_ATTACHMENT_TEXTURE(txl->ms_resolve_depth), GPU_ATTACHMENT_TEXTURE(txl->ms_resolve_color), @@ -349,23 +359,6 @@ static void lanpr_cache_init(void *vedata){ } elif(lanpr->master_mode == LANPR_MASTER_MODE_SOFTWARE) { ; - /*LANPR_LineLayer *ll; - for (ll = lanpr->line_layers.first; ll; ll = ll->next) { - ll->shgrp = DRW_shgroup_create(OneTime.software_shader, psl->software_pass); - DRW_shgroup_uniform_vec4(ll->shgrp, "color", ll->color, 1); - DRW_shgroup_uniform_vec4(ll->shgrp, "crease_color", ll->crease_color, 1); - DRW_shgroup_uniform_vec4(ll->shgrp, "material_color", ll->material_color, 1); - DRW_shgroup_uniform_vec4(ll->shgrp, "edge_mark_color", ll->edge_mark_color, 1); - DRW_shgroup_uniform_vec4(ll->shgrp, "intersection_color", ll->intersection_color, 1); - DRW_shgroup_uniform_float(ll->shgrp, "thickness", &ll->thickness, 1); - DRW_shgroup_uniform_float(ll->shgrp, "thickness_crease", &ll->thickness_crease, 1); - DRW_shgroup_uniform_float(ll->shgrp, "thickness_material", &ll->thickness_material, 1); - DRW_shgroup_uniform_float(ll->shgrp, "thickness_edge_mark", &ll->thickness_edge_mark, 1); - DRW_shgroup_uniform_float(ll->shgrp, "thickness_intersection", &ll->thickness_intersection, 1); - DRW_shgroup_uniform_vec4(ll->shgrp, "preview_viewport", stl->g_data->dpix_viewport, 1); - DRW_shgroup_uniform_vec4(ll->shgrp, "output_viewport", stl->g_data->output_viewport, 1); - if (ll->batch) DRW_shgroup_call_add(ll->shgrp, ll->batch, NULL); - }*/ } @@ -482,51 +475,76 @@ static void lanpr_draw_scene_exec(void *vedata, GPUFrameBuffer *dfb) { } elif(lanpr->master_mode == LANPR_MASTER_MODE_SOFTWARE) { + // should isolate these into a seperate function. + LANPR_LineLayer* ll; + GPU_framebuffer_bind(fbl->software_ms); GPU_framebuffer_clear(fbl->software_ms, clear_bits, lanpr->background_color, clear_depth, clear_stencil); - if (lanpr->render_buffer && lanpr->render_buffer->ChainDrawBatch) { - LANPR_LineLayer* ll; - for (ll = lanpr->line_layers.first; ll; ll = ll->next) { - LANPR_RenderBuffer* rb; - psl->software_pass = DRW_pass_create("Software Render Preview", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL); - rb = lanpr->render_buffer; - rb->ChainShgrp = DRW_shgroup_create(OneTime.software_shader, psl->software_pass); - DRW_shgroup_uniform_vec4(rb->ChainShgrp, "color", ll->color, 1); - DRW_shgroup_uniform_vec4(rb->ChainShgrp, "crease_color", ll->crease_color, 1); - DRW_shgroup_uniform_vec4(rb->ChainShgrp, "material_color", ll->material_color, 1); - DRW_shgroup_uniform_vec4(rb->ChainShgrp, "edge_mark_color", ll->edge_mark_color, 1); - DRW_shgroup_uniform_vec4(rb->ChainShgrp, "intersection_color", ll->intersection_color, 1); - DRW_shgroup_uniform_float(rb->ChainShgrp, "thickness", &ll->thickness, 1); - DRW_shgroup_uniform_float(rb->ChainShgrp, "thickness_crease", &ll->thickness_crease, 1); - DRW_shgroup_uniform_float(rb->ChainShgrp, "thickness_material", &ll->thickness_material, 1); - DRW_shgroup_uniform_float(rb->ChainShgrp, "thickness_edge_mark", &ll->thickness_edge_mark, 1); - DRW_shgroup_uniform_float(rb->ChainShgrp, "thickness_intersection", &ll->thickness_intersection, 1); - - DRW_shgroup_uniform_int(rb->ChainShgrp, "occlusion_level_begin", &ll->qi_begin, 1); - DRW_shgroup_uniform_int(rb->ChainShgrp, "occlusion_level_end", &ll->qi_end, 1); - - int texw = GPU_texture_width(txl->ms_resolve_color), texh = GPU_texture_height(txl->ms_resolve_color);; - pd->output_viewport[2] = scene->r.xsch; - pd->output_viewport[3] = scene->r.ysch; - pd->dpix_viewport[2] = texw; - pd->dpix_viewport[3] = texh; - DRW_shgroup_uniform_vec4(rb->ChainShgrp, "preview_viewport", stl->g_data->dpix_viewport, 1); - DRW_shgroup_uniform_vec4(rb->ChainShgrp, "output_viewport", stl->g_data->output_viewport, 1); - - float *tld = &lanpr->taper_left_distance, *tls = &lanpr->taper_left_strength, - *trd = &lanpr->taper_right_distance, *trs = &lanpr->taper_right_strength; - - DRW_shgroup_uniform_float(rb->ChainShgrp, "TaperLDist", tld, 1); - DRW_shgroup_uniform_float(rb->ChainShgrp, "TaperLStrength", tls, 1); - DRW_shgroup_uniform_float(rb->ChainShgrp, "TaperRDist", lanpr->use_same_taper ? tld : trd, 1); - DRW_shgroup_uniform_float(rb->ChainShgrp, "TaperRStrength", lanpr->use_same_taper ? tls : trs, 1); - - //need to add component enable/disable option. - DRW_shgroup_call_add(rb->ChainShgrp, lanpr->render_buffer->ChainDrawBatch, NULL); - // debug purpose - //DRW_draw_pass(psl->color_pass); - //DRW_draw_pass(psl->color_pass); + if (lanpr->render_buffer) { + + int texw = GPU_texture_width(txl->ms_resolve_color), texh = GPU_texture_height(txl->ms_resolve_color);; + pd->output_viewport[2] = scene->r.xsch; + pd->output_viewport[3] = scene->r.ysch; + pd->dpix_viewport[2] = texw; + pd->dpix_viewport[3] = texh; + + if (lanpr->enable_chaining && lanpr->render_buffer->ChainDrawBatch) { + for (ll = lanpr->line_layers.first; ll; ll = ll->next) { + LANPR_RenderBuffer* rb; + psl->software_pass = DRW_pass_create("Software Render Preview", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL); + rb = lanpr->render_buffer; + rb->ChainShgrp = DRW_shgroup_create(OneTime.software_chaining_shader, psl->software_pass); + DRW_shgroup_uniform_vec4(rb->ChainShgrp, "color", ll->color, 1); + DRW_shgroup_uniform_vec4(rb->ChainShgrp, "crease_color", ll->crease_color, 1); + DRW_shgroup_uniform_vec4(rb->ChainShgrp, "material_color", ll->material_color, 1); + DRW_shgroup_uniform_vec4(rb->ChainShgrp, "edge_mark_color", ll->edge_mark_color, 1); + DRW_shgroup_uniform_vec4(rb->ChainShgrp, "intersection_color", ll->intersection_color, 1); + DRW_shgroup_uniform_float(rb->ChainShgrp, "thickness", &ll->thickness, 1); + DRW_shgroup_uniform_float(rb->ChainShgrp, "thickness_crease", &ll->thickness_crease, 1); + DRW_shgroup_uniform_float(rb->ChainShgrp, "thickness_material", &ll->thickness_material, 1); + DRW_shgroup_uniform_float(rb->ChainShgrp, "thickness_edge_mark", &ll->thickness_edge_mark, 1); + DRW_shgroup_uniform_float(rb->ChainShgrp, "thickness_intersection", &ll->thickness_intersection, 1); + + DRW_shgroup_uniform_int(rb->ChainShgrp, "occlusion_level_begin", &ll->qi_begin, 1); + DRW_shgroup_uniform_int(rb->ChainShgrp, "occlusion_level_end", &ll->qi_end, 1); + + DRW_shgroup_uniform_vec4(rb->ChainShgrp, "preview_viewport", stl->g_data->dpix_viewport, 1); + DRW_shgroup_uniform_vec4(rb->ChainShgrp, "output_viewport", stl->g_data->output_viewport, 1); + + float *tld = &lanpr->taper_left_distance, *tls = &lanpr->taper_left_strength, + *trd = &lanpr->taper_right_distance, *trs = &lanpr->taper_right_strength; + + DRW_shgroup_uniform_float(rb->Cha @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs