From 67d12bb5192d04a596e216f63cff2875fdd8cfbf Mon Sep 17 00:00:00 2001 From: Bartosz Moniewski Date: Mon, 17 Feb 2020 12:31:38 +0100 Subject: Shading: add direction modes and phase offset to wave texture node * Direction mode X, Y and Z to align with axes rather than diagonal or spherical as previously. X is the new default, existing files will use diagonal or spherical for compatibility. * Phase offset to offset the wave along its direction, for purposes like animation and distortion. https://developer.blender.org/D6382 --- .../blender/nodes/shader/nodes/node_shader_tex_wave.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'source/blender/nodes') diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c index b525f4897a9..457e85519b2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c @@ -27,6 +27,7 @@ static bNodeSocketTemplate sh_node_tex_wave_in[] = { {SOCK_FLOAT, 1, N_("Distortion"), 0.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, {SOCK_FLOAT, 1, N_("Detail"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 16.0f}, {SOCK_FLOAT, 1, N_("Detail Scale"), 1.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, + {SOCK_FLOAT, 1, N_("Phase Offset"), 0.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, {-1, 0, ""}, }; @@ -62,7 +63,9 @@ static void node_shader_init_tex_wave(bNodeTree *UNUSED(ntree), bNode *node) BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); BKE_texture_colormapping_default(&tex->base.color_mapping); tex->wave_type = SHD_WAVE_BANDS; - + tex->bands_direction = SHD_WAVE_BANDS_DIRECTION_X; + tex->rings_direction = SHD_WAVE_RINGS_DIRECTION_X; + tex->wave_profile = SHD_WAVE_PROFILE_SIN; node->storage = tex; } @@ -77,10 +80,19 @@ static int node_shader_gpu_tex_wave(GPUMaterial *mat, NodeTexWave *tex = (NodeTexWave *)node->storage; float wave_type = tex->wave_type; + float bands_direction = tex->bands_direction; + float rings_direction = tex->rings_direction; float wave_profile = tex->wave_profile; - return GPU_stack_link( - mat, node, "node_tex_wave", in, out, GPU_constant(&wave_type), GPU_constant(&wave_profile)); + return GPU_stack_link(mat, + node, + "node_tex_wave", + in, + out, + GPU_constant(&wave_type), + GPU_constant(&bands_direction), + GPU_constant(&rings_direction), + GPU_constant(&wave_profile)); } /* node type definition */ -- cgit v1.2.3