From 667add5fc5b743a324b508e3c5cedfde1df218c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 20 Sep 2018 17:41:07 +0200 Subject: Eevee: Implement Wireframe Node This implementation is a bit hacky but match cycles pretty close. If pixel size is not enabled, it will use the geom shader to compute distances between vertices. This will have a cost. Implementation is a bit hacky in gpu_codegen to make the geom shader works in an optional manner. --- source/blender/nodes/shader/nodes/node_shader_wireframe.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/blender/nodes/shader') diff --git a/source/blender/nodes/shader/nodes/node_shader_wireframe.c b/source/blender/nodes/shader/nodes/node_shader_wireframe.c index 11d889def31..3592f98d81d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_wireframe.c +++ b/source/blender/nodes/shader/nodes/node_shader_wireframe.c @@ -38,6 +38,17 @@ static bNodeSocketTemplate sh_node_wireframe_out[] = { { -1, 0, "" } }; +static int node_shader_gpu_wireframe(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) +{ + /* node->custom1 is use_pixel_size */ + if (node->custom1) { + return GPU_stack_link(mat, node, "node_wireframe_screenspace", in, out, GPU_builtin(GPU_BARYCENTRIC_TEXCO)); + } + else { + return GPU_stack_link(mat, node, "node_wireframe", in, out, GPU_builtin(GPU_BARYCENTRIC_TEXCO), GPU_builtin(GPU_BARYCENTRIC_DIST)); + } +} + /* node type definition */ void register_node_type_sh_wireframe(void) { @@ -47,6 +58,7 @@ void register_node_type_sh_wireframe(void) node_type_socket_templates(&ntype, sh_node_wireframe_in, sh_node_wireframe_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); + node_type_gpu(&ntype, node_shader_gpu_wireframe); nodeRegisterType(&ntype); } -- cgit v1.2.3