[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50378] trunk/blender/intern/cycles/kernel /osl/nodes/node_gradient_texture.osl: OSL:
Thomas Dinges
blender at dingto.org
Tue Sep 4 13:41:49 CEST 2012
Revision: 50378
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50378
Author: dingto
Date: 2012-09-04 11:41:48 +0000 (Tue, 04 Sep 2012)
Log Message:
-----------
OSL:
* Gradient texture renders now.
Modified Paths:
--------------
trunk/blender/intern/cycles/kernel/osl/nodes/node_gradient_texture.osl
Modified: trunk/blender/intern/cycles/kernel/osl/nodes/node_gradient_texture.osl
===================================================================
--- trunk/blender/intern/cycles/kernel/osl/nodes/node_gradient_texture.osl 2012-09-04 11:08:47 UTC (rev 50377)
+++ trunk/blender/intern/cycles/kernel/osl/nodes/node_gradient_texture.osl 2012-09-04 11:41:48 UTC (rev 50378)
@@ -21,46 +21,40 @@
/* Gradient */
-float gradient(point p, string progression, string axis)
+float gradient(point p, string type)
{
float x, y;
+
+ x = p[0];
+ y = p[1];
- if(axis == "Vertical") {
- x= p[1];
- y= p[0];
- }
- else {
- 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 @@
}
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);
}
More information about the Bf-blender-cvs
mailing list