[Bf-blender-cvs] [0b758fd9948] soc-2018-npr: Software normal control thickness for non-chain situation
Nick Wu
noreply at git.blender.org
Tue Aug 28 12:11:40 CEST 2018
Commit: 0b758fd9948fe6c456fccc1596fcd587c9e1184e
Author: Nick Wu
Date: Tue Aug 28 14:13:57 2018 +0800
Branches: soc-2018-npr
https://developer.blender.org/rB0b758fd9948fe6c456fccc1596fcd587c9e1184e
Software normal control thickness for non-chain situation
===================================================================
M release/scripts/startup/bl_ui/properties_scene.py
M source/blender/draw/engines/lanpr/lanpr_ops.c
M source/blender/draw/engines/lanpr/shaders/lanpr_software_line_chain_geom.glsl
M source/blender/draw/engines/lanpr/shaders/lanpr_software_passthrough_vert.glsl
M source/blender/makesdna/DNA_lanpr_types.h
M source/blender/makesrna/intern/rna_lanpr.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py
index 8fbf1631c1d..e90e8f4b890 100644
--- a/release/scripts/startup/bl_ui/properties_scene.py
+++ b/release/scripts/startup/bl_ui/properties_scene.py
@@ -617,7 +617,7 @@ class LANPR_linesets(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
lineset = item
if self.layout_type in {'DEFAULT', 'COMPACT'}:
- split = layout.split(percentage=0.6)
+ split = layout.split(factor=0.6)
split.label(text="Layer")
row = split.row(align=True)
row.prop(lineset, "color", text="", icon_value=icon)
@@ -655,7 +655,7 @@ class SCENE_PT_lanpr(SceneButtonsPanel, Panel):
layout.label(text="RUN:")
layout.operator("scene.lanpr_calculate", icon='RENDER_STILL')
- split = layout.split(percentage=0.7)
+ split = layout.split(factor=0.7)
col = split.column()
col.label(text="Layer Composition:")
col = split.column()
@@ -702,7 +702,7 @@ class SCENE_PT_lanpr_line_types(SceneButtonsPanel, Panel):
layout.operator("scene.lanpr_enable_all_line_types")
- split = layout.split(percentage=0.3)
+ split = layout.split(factor=0.3)
col = split.column()
col.prop(active_layer, "enable_contour", text="Contour", toggle=True)
col.prop(active_layer, "enable_crease", text="Crease", toggle=True)
@@ -734,6 +734,9 @@ class SCENE_PT_lanpr_line_types(SceneButtonsPanel, Panel):
else:
row.label(text= "Intersection Calculation Disabled")
+ layout.label(text= "Normal:")
+ layout.prop(active_layer,"normal_mode", expand = True)
+
if lanpr.master_mode == "DPIX" and active_layer.enable_intersection:
row = col.row(align = True)
row.prop(lanpr,"enable_intersections", toggle = True, text = "Enable")
@@ -767,9 +770,9 @@ class SCENE_PT_lanpr_line_components(SceneButtonsPanel, Panel):
i=0
for c in active_layer.components:
- split = layout.split(percentage=0.85)
+ split = layout.split(factor=0.85)
col = split.column()
- sp2 = col.split(percentage=0.4)
+ sp2 = col.split(factor=0.4)
cl = sp2.column()
cl.prop(c,"component_mode", text = "")
cl = sp2.column()
diff --git a/source/blender/draw/engines/lanpr/lanpr_ops.c b/source/blender/draw/engines/lanpr/lanpr_ops.c
index 9cd29b6feb2..49d67b1f51e 100644
--- a/source/blender/draw/engines/lanpr/lanpr_ops.c
+++ b/source/blender/draw/engines/lanpr/lanpr_ops.c
@@ -2418,6 +2418,8 @@ LANPR_RenderLine *lanpr_triangle_generate_intersection_line_only(LANPR_RenderBuf
Result = mem_static_aquire(&rb->RenderDataPool, sizeof(LANPR_RenderLine));
Result->L = L;
Result->R = R;
+ Result->TL = rt;
+ Result->TR = Testing;
LANPR_RenderLineSegment *rls = mem_static_aquire(&rb->RenderDataPool, sizeof(LANPR_RenderLineSegment));
BLI_addtail(&Result->Segments, rls);
BLI_addtail(&rb->AllRenderLines, Result);
@@ -2816,7 +2818,7 @@ int lanpr_count_this_line(LANPR_RenderLine *rl, LANPR_LineLayer *ll) {
}
} elif(llc->component_mode == LANPR_COMPONENT_MODE_MATERIAL && llc->material_select)
{
- if ((rl->TL && rl->TL->MaterialID == llc->material_select->index) || (rl->TR && rl->TR->MaterialID == llc->material_select->index) || (!rl->TL && !rl->TR)) { OrResult = 1; }
+ if ((rl->TL && rl->TL->MaterialID == llc->material_select->index) || (rl->TR && rl->TR->MaterialID == llc->material_select->index) || (!(rl->Flags & LANPR_EDGE_FLAG_INTERSECTION))) { OrResult = 1; }
else {
AndResult = 0;
}
@@ -2858,7 +2860,7 @@ long lanpr_count_intersection_segment_count(LANPR_RenderBuffer *rb) {
}
return Count;
}
-void *lanpr_make_leveled_edge_vertex_array(LANPR_RenderBuffer *rb, ListBase *LineList, float *VertexArray, LANPR_LineLayer *ll, float componet_id) {
+void *lanpr_make_leveled_edge_vertex_array(LANPR_RenderBuffer *rb, ListBase *LineList, float *VertexArray, float* NormalArray, float** NextNormal, LANPR_LineLayer *ll, float componet_id) {
nListItemPointer *lip;
LANPR_RenderLine *rl;
LANPR_RenderLineSegment *rls, *irls;
@@ -2866,12 +2868,30 @@ void *lanpr_make_leveled_edge_vertex_array(LANPR_RenderBuffer *rb, ListBase *Lin
real W = rb->W / 2, H = rb->H / 2;
long i = 0;
float *V = VertexArray;
+ float *N = NormalArray;
for (lip = LineList->first; lip; lip = lip->pNext) {
rl = lip->p;
if (!lanpr_count_this_line(rl, ll)) continue;
for (rls = rl->Segments.first; rls; rls = rls->Item.pNext) {
if (rls->OcclusionLevel >= ll->qi_begin && rls->OcclusionLevel <= ll->qi_end) {
+
+ if (rl->TL) {
+ N[0] += rl->TL->GN[0];
+ N[1] += rl->TL->GN[1];
+ N[2] += rl->TL->GN[2];
+ }
+ if (rl->TR) {
+ N[0] += rl->TR->GN[0];
+ N[1] += rl->TR->GN[1];
+ N[2] += rl->TR->GN[2];
+ }
+ if (rl->TL || rl->TR) {
+ normalize_v3(N);
+ copy_v3_v3(&N[3], N);
+ }
+ N += 6;
+
*V = tnsLinearItp(rl->L->FrameBufferCoord[0], rl->R->FrameBufferCoord[0], rls->at);
V++;
*V = tnsLinearItp(rl->L->FrameBufferCoord[1], rl->R->FrameBufferCoord[1], rls->at);
@@ -2887,6 +2907,7 @@ void *lanpr_make_leveled_edge_vertex_array(LANPR_RenderBuffer *rb, ListBase *Lin
}
}
}
+ *NextNormal = N;
return V;
}
@@ -2897,15 +2918,16 @@ void lanpr_chain_generate_draw_command(LANPR_RenderBuffer *rb);
void lanpr_rebuild_render_draw_command(LANPR_RenderBuffer *rb, LANPR_LineLayer *ll) {
int Count = 0;
int level;
- float *V, *tv, *N;;
+ float *V, *tv, *N, *tn;
int i;
int VertCount;
if (ll->type == TNS_COMMAND_LINE) {
static GPUVertFormat format = { 0 };
- static struct { uint pos, uvs; } attr_id;
+ static struct { uint pos, normal; } attr_id;
if (format.attr_len == 0) {
attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.normal = GPU_vertformat_attr_add(&format, "normal", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
@@ -2923,19 +2945,22 @@ void lanpr_rebuild_render_draw_command(LANPR_RenderBuffer *rb, LANPR_LineLayer *
GPU_vertbuf_data_alloc(vbo, VertCount);
tv = V = CreateNewBuffer(float, 6 * Count);
+ tn = N = CreateNewBuffer(float, 6 * Count);
- if (ll->enable_contour) tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->Contours, tv, ll, 1.0f);
- if (ll->enable_crease) tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->CreaseLines, tv, ll, 2.0f);
- if (ll->enable_material_seperate) tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->MaterialLines, tv, ll, 3.0f);
- if (ll->enable_edge_mark) tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->EdgeMarks, tv, ll, 4.0f);
- if (ll->enable_intersection) tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->IntersectionLines, tv, ll, 5.0f);
+ if (ll->enable_contour) tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->Contours, tv, tn, &tn, ll, 1.0f);
+ if (ll->enable_crease) tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->CreaseLines, tv, tn, &tn, ll, 2.0f);
+ if (ll->enable_material_seperate) tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->MaterialLines, tv, tn, &tn, ll, 3.0f);
+ if (ll->enable_edge_mark) tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->EdgeMarks, tv, tn, &tn, ll, 4.0f);
+ if (ll->enable_intersection) tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->IntersectionLines, tv, tn, &tn, ll, 5.0f);
for (i = 0; i < VertCount; i++) {
- GPU_vertbuf_attr_set(vbo, attr_id.pos, i, &V[i * 3]);
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i, &V[i * 3]);
+ GPU_vertbuf_attr_set(vbo, attr_id.normal, i, &N[i * 3]);
}
FreeMem(V);
+ FreeMem(N);
ll->batch = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, 0, GPU_USAGE_DYNAMIC | GPU_BATCH_OWNS_VBO);
@@ -3105,6 +3130,7 @@ void lanpr_software_draw_scene(void *vedata, GPUFrameBuffer *dfb, int is_render)
psl->software_pass = DRW_pass_create("Software Render Preview", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL);
ll->shgrp = DRW_shgroup_create(lanpr_share.software_shader, psl->software_pass);
DRW_shgroup_uniform_vec4(ll->shgrp, "color", ll->color, 1);
+ DRW_shgroup_uniform_int(ll->shgrp, "normal_mode", &ll->normal_mode, 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);
diff --git a/source/blender/draw/engines/lanpr/shaders/lanpr_software_line_chain_geom.glsl b/source/blender/draw/engines/lanpr/shaders/lanpr_software_line_chain_geom.glsl
index 96c480de7ee..db50a37ecf3 100644
--- a/source/blender/draw/engines/lanpr/shaders/lanpr_software_line_chain_geom.glsl
+++ b/source/blender/draw/engines/lanpr/shaders/lanpr_software_line_chain_geom.glsl
@@ -1,6 +1,9 @@
layout(lines) in;
layout(triangle_strip, max_vertices = 6) out;
+in vec3 gNormal[];
+uniform int normal_mode;
+uniform vec3 normal_direction;
uniform float thickness;
uniform float thickness_crease;
@@ -52,11 +55,20 @@ void draw_line(vec4 p1, vec4 p2){
}
void decide_color_and_thickness(float component_id){
- if (component_id < 1.5) { out_color = color; use_thickness = thickness; return; }
- if (component_id < 2.5) { out_color = crease_color; use_thickness = thickness * thickness_crease; return; }
- if (component_id < 3.5) { out_color = material_color; use_thickness = thickness * thickness_material; return; }
- if (component_id < 4.5) { out_color = edge_mark_color; use_thickness = thickness * thickness_edge_mark; return; }
- if (component_id < 5.5) { out_color = intersection_color; use_thickness = thickness * thickness_intersection; return; }
+ float fac=1.0f;
+ if(normal_mode == 0){
+ fac*=1.0f;
+ }else if(normal_mode == 1){
+ float factor = dot(gNormal[0],vec3(0,0,1));
+ fac *= factor;
+ if (fac
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list