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
This commit is contained in:
@@ -1422,15 +1422,33 @@ NODE_DEFINE(WaveTextureNode)
|
||||
type_enum.insert("rings", NODE_WAVE_RINGS);
|
||||
SOCKET_ENUM(type, "Type", type_enum, NODE_WAVE_BANDS);
|
||||
|
||||
static NodeEnum bands_direction_enum;
|
||||
bands_direction_enum.insert("x", NODE_WAVE_BANDS_DIRECTION_X);
|
||||
bands_direction_enum.insert("y", NODE_WAVE_BANDS_DIRECTION_Y);
|
||||
bands_direction_enum.insert("z", NODE_WAVE_BANDS_DIRECTION_Z);
|
||||
bands_direction_enum.insert("diagonal", NODE_WAVE_BANDS_DIRECTION_DIAGONAL);
|
||||
SOCKET_ENUM(
|
||||
bands_direction, "Bands Direction", bands_direction_enum, NODE_WAVE_BANDS_DIRECTION_X);
|
||||
|
||||
static NodeEnum rings_direction_enum;
|
||||
rings_direction_enum.insert("x", NODE_WAVE_RINGS_DIRECTION_X);
|
||||
rings_direction_enum.insert("y", NODE_WAVE_RINGS_DIRECTION_Y);
|
||||
rings_direction_enum.insert("z", NODE_WAVE_RINGS_DIRECTION_Z);
|
||||
rings_direction_enum.insert("spherical", NODE_WAVE_RINGS_DIRECTION_SPHERICAL);
|
||||
SOCKET_ENUM(
|
||||
rings_direction, "Rings Direction", rings_direction_enum, NODE_WAVE_BANDS_DIRECTION_X);
|
||||
|
||||
static NodeEnum profile_enum;
|
||||
profile_enum.insert("sine", NODE_WAVE_PROFILE_SIN);
|
||||
profile_enum.insert("saw", NODE_WAVE_PROFILE_SAW);
|
||||
profile_enum.insert("tri", NODE_WAVE_PROFILE_TRI);
|
||||
SOCKET_ENUM(profile, "Profile", profile_enum, NODE_WAVE_PROFILE_SIN);
|
||||
|
||||
SOCKET_IN_FLOAT(scale, "Scale", 1.0f);
|
||||
SOCKET_IN_FLOAT(distortion, "Distortion", 0.0f);
|
||||
SOCKET_IN_FLOAT(detail, "Detail", 2.0f);
|
||||
SOCKET_IN_FLOAT(detail_scale, "Detail Scale", 0.0f);
|
||||
SOCKET_IN_FLOAT(phase, "Phase Offset", 0.0f);
|
||||
SOCKET_IN_POINT(
|
||||
vector, "Vector", make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_GENERATED);
|
||||
|
||||
@@ -1446,32 +1464,36 @@ WaveTextureNode::WaveTextureNode() : TextureNode(node_type)
|
||||
|
||||
void WaveTextureNode::compile(SVMCompiler &compiler)
|
||||
{
|
||||
ShaderInput *vector_in = input("Vector");
|
||||
ShaderInput *scale_in = input("Scale");
|
||||
ShaderInput *distortion_in = input("Distortion");
|
||||
ShaderInput *dscale_in = input("Detail Scale");
|
||||
ShaderInput *detail_in = input("Detail");
|
||||
ShaderInput *vector_in = input("Vector");
|
||||
ShaderOutput *fac_out = output("Fac");
|
||||
ShaderInput *dscale_in = input("Detail Scale");
|
||||
ShaderInput *phase_in = input("Phase Offset");
|
||||
ShaderOutput *color_out = output("Color");
|
||||
ShaderOutput *fac_out = output("Fac");
|
||||
|
||||
int vector_offset = tex_mapping.compile_begin(compiler, vector_in);
|
||||
|
||||
compiler.add_node(NODE_TEX_WAVE,
|
||||
compiler.encode_uchar4(type,
|
||||
compiler.stack_assign_if_linked(color_out),
|
||||
compiler.stack_assign_if_linked(fac_out),
|
||||
compiler.stack_assign_if_linked(dscale_in)),
|
||||
compiler.encode_uchar4(type, bands_direction, rings_direction, profile),
|
||||
compiler.encode_uchar4(vector_offset,
|
||||
compiler.stack_assign_if_linked(scale_in),
|
||||
compiler.stack_assign_if_linked(detail_in),
|
||||
compiler.stack_assign_if_linked(distortion_in)),
|
||||
profile);
|
||||
compiler.stack_assign_if_linked(distortion_in),
|
||||
compiler.stack_assign_if_linked(detail_in)),
|
||||
compiler.encode_uchar4(compiler.stack_assign_if_linked(dscale_in),
|
||||
compiler.stack_assign_if_linked(phase_in),
|
||||
compiler.stack_assign_if_linked(color_out),
|
||||
compiler.stack_assign_if_linked(fac_out)));
|
||||
|
||||
compiler.add_node(__float_as_int(scale),
|
||||
__float_as_int(detail),
|
||||
__float_as_int(distortion),
|
||||
__float_as_int(detail_scale));
|
||||
|
||||
compiler.add_node(
|
||||
__float_as_int(phase), SVM_STACK_INVALID, SVM_STACK_INVALID, SVM_STACK_INVALID);
|
||||
|
||||
tex_mapping.compile_end(compiler, vector_in, vector_offset);
|
||||
}
|
||||
|
||||
@@ -1480,6 +1502,8 @@ void WaveTextureNode::compile(OSLCompiler &compiler)
|
||||
tex_mapping.compile(compiler);
|
||||
|
||||
compiler.parameter(this, "type");
|
||||
compiler.parameter(this, "bands_direction");
|
||||
compiler.parameter(this, "rings_direction");
|
||||
compiler.parameter(this, "profile");
|
||||
|
||||
compiler.add(this, "node_wave_texture");
|
||||
|
||||
Reference in New Issue
Block a user