Cycles: Add Saw option to the wave texture

This commit adds "Bands Saw" and "Rings Saw" to the options for the Wave texture node in Cycles, behaving similar to the Saw option in BI textures.
Requested by @cekuhnen on BA.

Reviewers: dingto, sergey

Subscribers: cekuhnen

Differential Revision: https://developer.blender.org/D1699
This commit is contained in:
Lukas Stockner
2015-12-29 14:42:49 +01:00
parent 1991ee1738
commit 5c682a901b
9 changed files with 66 additions and 10 deletions

View File

@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Wave */
ccl_device_noinline float svm_wave(NodeWaveType type, float3 p, float detail, float distortion, float dscale)
ccl_device_noinline float svm_wave(NodeWaveType type, NodeWaveProfile profile, float3 p, float detail, float distortion, float dscale)
{
float n;
@@ -26,11 +26,18 @@ ccl_device_noinline float svm_wave(NodeWaveType type, float3 p, float detail, fl
n = (p.x + p.y + p.z) * 10.0f;
else /* NODE_WAVE_RINGS */
n = len(p) * 20.0f;
if(distortion != 0.0f)
n += distortion * noise_turbulence(p*dscale, detail, 0);
return 0.5f + 0.5f * sinf(n);
if(profile == NODE_WAVE_PROFILE_SIN) {
return 0.5f + 0.5f * sinf(n);
}
else { /* NODE_WAVE_PROFILE_SAW */
n /= M_2PI_F;
n -= (int) n;
return (n < 0.0f)? n + 1.0f: n;
}
}
ccl_device void svm_node_tex_wave(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
@@ -49,7 +56,7 @@ ccl_device void svm_node_tex_wave(KernelGlobals *kg, ShaderData *sd, float *stac
float distortion = stack_load_float_default(stack, distortion_offset, node2.z);
float dscale = stack_load_float_default(stack, dscale_offset, node2.w);
float f = svm_wave((NodeWaveType)type, co*scale, detail, distortion, dscale);
float f = svm_wave((NodeWaveType)type, (NodeWaveProfile)node.w, co*scale, detail, distortion, dscale);
if(stack_valid(fac_offset)) stack_store_float(stack, fac_offset, f);
if(stack_valid(color_offset)) stack_store_float3(stack, color_offset, make_float3(f, f, f));