diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-11-07 01:05:58 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-11-07 01:05:58 +0400 |
commit | fb56dbc2afc7c8b6ffc24406ed82cbcbff090da3 (patch) | |
tree | 5832366c7147ad6ebc858312ac106b5d1571b5e5 /intern/cycles/kernel/svm/svm_noisetex.h | |
parent | 3bf96250cde08ab9ad717819114b48ccb11c2d5d (diff) |
Cycles: procedural texture nodes reorganization. This will break existing files
using them, but rather do it now that I have the chance still. Highlights:
* Wood and Marble merged into a single Wave texture
* Clouds + Distorted Noise merged into new Noise node
* Blend renamed to Gradient
* Stucci removed, was mostly useful for old bump
* Noise removed, will come back later, didn't actually work yet
* Depth setting is now Detail socket, which accepts float values
* Scale socket instead of Size socket
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/Textures
Diffstat (limited to 'intern/cycles/kernel/svm/svm_noisetex.h')
-rw-r--r-- | intern/cycles/kernel/svm/svm_noisetex.h | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/intern/cycles/kernel/svm/svm_noisetex.h b/intern/cycles/kernel/svm/svm_noisetex.h index 38b249a80fe..7421597040e 100644 --- a/intern/cycles/kernel/svm/svm_noisetex.h +++ b/intern/cycles/kernel/svm/svm_noisetex.h @@ -18,30 +18,55 @@ CCL_NAMESPACE_BEGIN -__device float svm_noise_texture_value(float3 p) -{ - return cellnoise(p*1e8f); -} +/* Clouds */ -__device float3 svm_noise_texture_color(float3 p) +__device_inline void svm_noise(float3 p, float scale, float detail, float distortion, float *fac, float3 *color) { - return cellnoise_color(p*1e8f); -} + NodeNoiseBasis basis = NODE_NOISE_PERLIN; + int hard = 0; -__device void svm_node_tex_noise_f(ShaderData *sd, float *stack, uint co_offset, uint out_offset) -{ - float3 co = stack_load_float3(stack, co_offset); - float f = svm_noise_texture_value(co); + p *= scale; + + if(distortion != 0.0f) { + float3 r, offset = make_float3(13.5f, 13.5f, 13.5f); + + r.x = noise_basis(p + offset, basis) * distortion; + r.y = noise_basis(p, basis) * distortion; + r.z = noise_basis(p - offset, basis) * distortion; - stack_store_float(stack, out_offset, f); + p += r; + } + + *fac = noise_turbulence(p, basis, detail, hard); + *color = make_float3(*fac, + noise_turbulence(make_float3(p.y, p.x, p.z), basis, detail, hard), + noise_turbulence(make_float3(p.y, p.z, p.x), basis, detail, hard)); } -__device void svm_node_tex_noise_v(ShaderData *sd, float *stack, uint co_offset, uint out_offset) +__device void svm_node_tex_noise(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) { + uint co_offset, scale_offset, detail_offset, distortion_offset, fac_offset, color_offset; + + decode_node_uchar4(node.y, &co_offset, &scale_offset, &detail_offset, &distortion_offset); + + uint4 node2 = read_node(kg, offset); + + float scale = stack_load_float_default(stack, scale_offset, node2.x); + float detail = stack_load_float_default(stack, detail_offset, node2.y); + float distortion = stack_load_float_default(stack, distortion_offset, node2.z); float3 co = stack_load_float3(stack, co_offset); - float3 f = svm_noise_texture_color(co); - stack_store_float3(stack, out_offset, f); + float3 color; + float f; + + svm_noise(co, scale, detail, distortion, &f, &color); + + decode_node_uchar4(node.z, &color_offset, &fac_offset, NULL, NULL); + + if(stack_valid(fac_offset)) + stack_store_float(stack, fac_offset, f); + if(stack_valid(color_offset)) + stack_store_float3(stack, color_offset, color); } CCL_NAMESPACE_END |