Cycles / OSL:
authorThomas Dinges <blender@dingto.org>
Wed, 1 May 2013 13:21:15 +0000 (13:21 +0000)
committerThomas Dinges <blender@dingto.org>
Wed, 1 May 2013 13:21:15 +0000 (13:21 +0000)
* Add a few more OSL templates to the Text Editor, so people can use some of the OSL only shaders and closures.

* Temperature (Kelvin) to RGB converter
* Wavelength to RGB converter
* Ramp closure (Phong and Diffuse)
* Toon closure (Diffuse and Specular)

release/scripts/templates_osl/ramp_closure.osl [new file with mode: 0644]
release/scripts/templates_osl/temperature_to_rgb.osl [new file with mode: 0644]
release/scripts/templates_osl/toon_closure.osl [new file with mode: 0644]
release/scripts/templates_osl/wavelength_to_rgb.osl [new file with mode: 0644]

diff --git a/release/scripts/templates_osl/ramp_closure.osl b/release/scripts/templates_osl/ramp_closure.osl
new file mode 100644 (file)
index 0000000..3f5cf24
--- /dev/null
@@ -0,0 +1,20 @@
+
+shader node_ramp_bsdf(
+       float Exponent = 10.0,
+       color Color1 = color(0.8, 0.0, 0.0),
+       color Color2 = color(0.0, 0.8, 0.0),
+       color Color3 = color(0.0, 0.0, 0.8),
+       color Color4 = 0.1,
+       color Color5 = 0.2,
+       color Color6 = 0.3,
+       color Color7 = 0.4,
+       color Color8 = 0.5,
+       normal Normal = N,
+       output closure color Phong = 0,
+       output closure color Diffuse = 0)
+{
+       color Color[8] = {Color1, Color2, Color3, Color4, Color5, Color6, Color7, Color8};
+
+       Phong = phong_ramp(Normal, Exponent, Color);
+       Diffuse = diffuse_ramp(Normal, Color);
+}
\ No newline at end of file
diff --git a/release/scripts/templates_osl/temperature_to_rgb.osl b/release/scripts/templates_osl/temperature_to_rgb.osl
new file mode 100644 (file)
index 0000000..6b91416
--- /dev/null
@@ -0,0 +1,9 @@
+
+shader temperature_to_rgb(
+       float Kelvin = 1200.0,
+       output color Color = 0.8)
+{   
+       /* Kelvin to RGB */
+       Color = blackbody(Kelvin);
+}
+
diff --git a/release/scripts/templates_osl/toon_closure.osl b/release/scripts/templates_osl/toon_closure.osl
new file mode 100644 (file)
index 0000000..ccc3812
--- /dev/null
@@ -0,0 +1,12 @@
+
+shader node_toon_bsdf(
+       color Color = 0.8,
+       float Size = 0.5,
+       float Smooth = 0.0,
+       normal Normal = N,
+       output closure color Diffuse = 0,
+       output closure color Specular = 0)
+{
+       Diffuse = Color * diffuse_toon(Normal, Size, Smooth);
+       Specular = Color * specular_toon(Normal, Size, Smooth);
+}
\ No newline at end of file
diff --git a/release/scripts/templates_osl/wavelength_to_rgb.osl b/release/scripts/templates_osl/wavelength_to_rgb.osl
new file mode 100644 (file)
index 0000000..2a605be
--- /dev/null
@@ -0,0 +1,9 @@
+
+shader wavelength_to_rgb(
+       float Wavelength = 500.0,
+       output color Color = 0.8)
+{   
+       /* Wavelength to RGB */
+       Color = wavelength_color(Wavelength);
+}
+