diff options
author | Thomas Dinges <blender@dingto.org> | 2012-09-04 15:41:48 +0400 |
---|---|---|
committer | Thomas Dinges <blender@dingto.org> | 2012-09-04 15:41:48 +0400 |
commit | bf8d6952340cc3518ed155e42bc7b0668b86e316 (patch) | |
tree | bc07cd1e5d351f998369cc0fae50e8a2bf8d5e4f | |
parent | d4be0ec9fbd122e259662f8da0261798a0056430 (diff) |
OSL:
* Gradient texture renders now.
-rw-r--r-- | intern/cycles/kernel/osl/nodes/node_gradient_texture.osl | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/intern/cycles/kernel/osl/nodes/node_gradient_texture.osl b/intern/cycles/kernel/osl/nodes/node_gradient_texture.osl index e6fa014324c..a8dd65ae23b 100644 --- a/intern/cycles/kernel/osl/nodes/node_gradient_texture.osl +++ b/intern/cycles/kernel/osl/nodes/node_gradient_texture.osl @@ -21,46 +21,40 @@ /* Gradient */ -float gradient(point p, string progression, string axis) +float gradient(point p, string type) { float x, y; - - if(axis == "Vertical") { - x= p[1]; - y= p[0]; - } - else { - x= p[0]; - y= p[1]; - } + + x = p[0]; + y = p[1]; float result = 0.0; - if(progression == "Linear") { + if(type == "Linear") { result = (1.0 + x)/2.0; } - else if(progression == "Quadratic") { + else if(type == "Quadratic") { float r = max((1.0 + x)/2.0, 0.0); result = r*r; } - else if(progression == "Easing") { + else if(type == "Easing") { float r = min(max((1.0 + x)/2.0, 0.0), 1.0); float t = r*r; result = (3.0*t - 2.0*t*r); } - else if(progression == "Diagonal") { + else if(type == "Diagonal") { result = (2.0 + x + y)/4.0; } - else if(progression == "Radial") { + else if(type == "Radial") { result = atan2(y, x)/(2*M_PI) + 0.5; } else { float r = max(1.0 - sqrt(x*x + y*y + p[2]*p[2]), 0.0); - if(progression == "Quadratic Sphere") + if(type == "Quadratic Sphere") result = r*r; - else if(progression == "Spherical") + else if(type == "Spherical") result = r; } @@ -68,11 +62,12 @@ float gradient(point p, string progression, string axis) } shader node_gradient_texture( - string Progression = "Linear", - string Axis = "Horizontal", + string Type = "Linear", point Vector = P, - output float Fac = 0.0) + output float Fac = 0.0, + output color Color = color(0.0, 0.0, 0.0)) { - Fac = gradient(Vector, Progression, Axis); + Fac = gradient(Vector, Type); + Color = color(Fac, Fac, Fac); } |