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_texture.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_texture.h')
-rw-r--r-- | intern/cycles/kernel/svm/svm_texture.h | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/intern/cycles/kernel/svm/svm_texture.h b/intern/cycles/kernel/svm/svm_texture.h index e273a92c988..82797018d74 100644 --- a/intern/cycles/kernel/svm/svm_texture.h +++ b/intern/cycles/kernel/svm/svm_texture.h @@ -213,14 +213,17 @@ __device float noise_wave(NodeWaveType wave, float a) /* Turbulence */ -__device_noinline float noise_turbulence(float3 p, NodeNoiseBasis basis, int octaves, int hard) +__device_noinline float noise_turbulence(float3 p, NodeNoiseBasis basis, float octaves, int hard) { float fscale = 1.0f; float amp = 1.0f; float sum = 0.0f; - int i; + int i, n; - for(i = 0; i <= octaves; i++) { + octaves = clamp(octaves, 0.0f, 16.0f); + n= (int)octaves; + + for(i = 0; i <= n; i++) { float t = noise_basis(fscale*p, basis); if(hard) @@ -231,9 +234,25 @@ __device_noinline float noise_turbulence(float3 p, NodeNoiseBasis basis, int oct fscale *= 2.0f; } - sum *= ((float)(1 << octaves)/(float)((1 << (octaves+1)) - 1)); + float rmd = octaves - floor(octaves); + + if(rmd != 0.0f) { + float t = noise_basis(fscale*p, basis); + + if(hard) + t = fabsf(2.0f*t - 1.0f); + + float sum2 = sum + t*amp; + + sum *= ((float)(1 << n)/(float)((1 << (n+1)) - 1)); + sum2 *= ((float)(1 << (n+1))/(float)((1 << (n+2)) - 1)); - return sum; + return (1.0f - rmd)*sum + rmd*sum2; + } + else { + sum *= ((float)(1 << n)/(float)((1 << (n+1)) - 1)); + return sum; + } } CCL_NAMESPACE_END |