diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-07-18 23:36:09 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-07-18 23:49:10 +0300 |
commit | 9b406162490d9ee93e9786350432cdc1563b7bf6 (patch) | |
tree | cf573ef92132c45c7daac221296bfc76bf327628 /source/blender/nodes | |
parent | 7d10798af22f683a8f55a8c361ad5676bd4160d2 (diff) |
Cycles: Point density texture support
This commit implements point density texture for Cycles shading nodes.
It's done via creating voxel texture at shader compilation time, Not
totally memory efficient, but avoids adding sampling code to kernel
(which keeps render time as low as possible), In the future this will
be compensated by using OpenVDB for more efficient storage of sparse
volume data.
Sampling of the voxel texture is happening at blender side and the
same code is used as for Blender Internal's renderer.
This texture is controlled by only object, particle system and radius.
Linear falloff is used and there's no turbulence. This is because
falloff is expected to happen using Curve Mapping node. Turbulence
will be done as a distortion on the input coordinate. It's already
possible to fake it using nose textures and in the future we can add
more proper turbulence distortion node, which then could also be used
for 2D texture mapping.
Particle color support is done by Lukas, thanks!
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/nodes/NOD_shader.h | 1 | ||||
-rw-r--r-- | source/blender/nodes/NOD_static_types.h | 1 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c | 76 |
4 files changed, 79 insertions, 0 deletions
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index c95daffe557..3fd1241f3fa 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -200,6 +200,7 @@ set(SRC shader/nodes/node_shader_tex_magic.c shader/nodes/node_shader_tex_musgrave.c shader/nodes/node_shader_tex_noise.c + shader/nodes/node_shader_tex_pointdensity.c shader/nodes/node_shader_tex_sky.c shader/nodes/node_shader_tex_voronoi.c shader/nodes/node_shader_tex_wave.c diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h index 595a3b12bc6..4c0047f1d58 100644 --- a/source/blender/nodes/NOD_shader.h +++ b/source/blender/nodes/NOD_shader.h @@ -75,6 +75,7 @@ void register_node_type_sh_sepxyz(void); void register_node_type_sh_combxyz(void); void register_node_type_sh_hue_sat(void); void register_node_type_sh_tex_brick(void); +void register_node_type_sh_tex_pointdensity(void); void register_node_type_sh_attribute(void); void register_node_type_sh_geometry(void); diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h index b33bec51c2c..9e1a0c926fa 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -116,6 +116,7 @@ DefNode( ShaderNode, SH_NODE_TEX_MUSGRAVE, def_sh_tex_musgrave, "TE DefNode( ShaderNode, SH_NODE_TEX_VORONOI, def_sh_tex_voronoi, "TEX_VORONOI", TexVoronoi, "Voronoi Texture", "" ) DefNode( ShaderNode, SH_NODE_TEX_CHECKER, def_sh_tex_checker, "TEX_CHECKER", TexChecker, "Checker Texture", "" ) DefNode( ShaderNode, SH_NODE_TEX_BRICK, def_sh_tex_brick, "TEX_BRICK", TexBrick, "Brick Texture", "" ) +DefNode( ShaderNode, SH_NODE_TEX_POINTDENSITY, def_sh_tex_pointdensity,"TEX_POINTDENSITY", TexPointDensity, "Point Density", "" ) DefNode( ShaderNode, SH_NODE_TEX_COORD, def_sh_tex_coord, "TEX_COORD", TexCoord, "Texture Coordinate","" ) DefNode( ShaderNode, SH_NODE_VECT_TRANSFORM, def_sh_vect_transform, "VECT_TRANSFORM", VectorTransform, "Vector Transform", "" ) DefNode( ShaderNode, SH_NODE_SEPHSV, 0, "SEPHSV", SeparateHSV, "Separate HSV", "" ) diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c new file mode 100644 index 00000000000..6205b0fa11f --- /dev/null +++ b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c @@ -0,0 +1,76 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2015 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Sergey Sharybin. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "../node_shader_util.h" + +/* **************** OUTPUT ******************** */ + +static bNodeSocketTemplate sh_node_tex_pointdensity_in[] = { + {SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, + {-1, 0, ""} +}; + +static bNodeSocketTemplate sh_node_tex_pointdensity_out[] = { + {SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, + {SOCK_FLOAT, 0, N_("Density"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f}, + {-1, 0, ""} +}; + +static void node_shader_init_tex_pointdensity(bNodeTree *UNUSED(ntree), + bNode *node) +{ + NodeShaderTexPointDensity *point_density = + MEM_callocN(sizeof(NodeShaderTexPointDensity), "new pd node"); + point_density->resolution = 100; + point_density->radius = 0.3f; + point_density->space = SHD_POINTDENSITY_SPACE_OBJECT; + point_density->color_source = SHD_POINTDENSITY_COLOR_PARTAGE; + node->storage = point_density; +} + +/* node type definition */ +void register_node_type_sh_tex_pointdensity(void) +{ + static bNodeType ntype; + + sh_node_type_base(&ntype, + SH_NODE_TEX_POINTDENSITY, + "Point Density", + NODE_CLASS_TEXTURE, + 0); + node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_socket_templates(&ntype, + sh_node_tex_pointdensity_in, + sh_node_tex_pointdensity_out); + node_type_init(&ntype, node_shader_init_tex_pointdensity); + node_type_storage(&ntype, + "NodeShaderTexPointDensity", + node_free_standard_storage, + node_copy_standard_storage); + + nodeRegisterType(&ntype); +} |