Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2011-11-07 01:05:58 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-11-07 01:05:58 +0400
commitfb56dbc2afc7c8b6ffc24406ed82cbcbff090da3 (patch)
tree5832366c7147ad6ebc858312ac106b5d1571b5e5 /intern/cycles/kernel/svm/svm_gradient.h
parent3bf96250cde08ab9ad717819114b48ccb11c2d5d (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_gradient.h')
-rw-r--r--intern/cycles/kernel/svm/svm_gradient.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/intern/cycles/kernel/svm/svm_gradient.h b/intern/cycles/kernel/svm/svm_gradient.h
new file mode 100644
index 00000000000..79298f5f581
--- /dev/null
+++ b/intern/cycles/kernel/svm/svm_gradient.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+CCL_NAMESPACE_BEGIN
+
+/* Gradient */
+
+__device float svm_gradient(float3 p, NodeBlendType type)
+{
+ float x, y, z;
+
+ x= p.x;
+ y= p.y;
+ z= p.z;
+
+ if(type == NODE_BLEND_LINEAR) {
+ return x;
+ }
+ else if(type == NODE_BLEND_QUADRATIC) {
+ float r = fmaxf(x, 0.0f);
+ return r*r;
+ }
+ else if(type == NODE_BLEND_EASING) {
+ float r = fminf(fmaxf(x, 0.0f), 1.0f);
+ float t = r*r;
+
+ return (3.0f*t - 2.0f*t*r);
+ }
+ else if(type == NODE_BLEND_DIAGONAL) {
+ return (x + y)/2.0f;
+ }
+ else if(type == NODE_BLEND_RADIAL) {
+ return atan2(y, x)/(2.0f*M_PI_F) + 0.5f;
+ }
+ else {
+ float r = fmaxf(1.0f - sqrtf(x*x + y*y + p.z*p.z), 0.0f);
+
+ if(type == NODE_BLEND_QUADRATIC_SPHERE)
+ return r*r;
+ else if(type == NODE_BLEND_SPHERICAL)
+ return r;
+ }
+
+ return 0.0f;
+}
+
+__device void svm_node_tex_gradient(ShaderData *sd, float *stack, uint4 node)
+{
+ uint type, co_offset, color_offset, fac_offset;
+
+ decode_node_uchar4(node.y, &type, &co_offset, &fac_offset, &color_offset);
+
+ float3 co = stack_load_float3(stack, co_offset);
+
+ float f = svm_gradient(co, (NodeBlendType)type);
+ f = clamp(f, 0.0f, 1.0f);
+
+ 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));
+}
+
+CCL_NAMESPACE_END
+