OSL Templates:
authorThomas Dinges <blender@dingto.org>
Sun, 30 Dec 2012 03:11:52 +0000 (03:11 +0000)
committerThomas Dinges <blender@dingto.org>
Sun, 30 Dec 2012 03:11:52 +0000 (03:11 +0000)
* Add 3 simple templates:
** empty_shader.osl: A basic shader declaration to start with
** wireframe.osl: Simple wireframe shader
** noise.osl: Simple noise shader, with 3 noise types.

release/scripts/templates_osl/empty_shader.osl [new file with mode: 0644]
release/scripts/templates_osl/noise.osl [new file with mode: 0644]
release/scripts/templates_osl/wireframe.osl [new file with mode: 0644]
source/blender/editors/space_text/text_format_osl.c

diff --git a/release/scripts/templates_osl/empty_shader.osl b/release/scripts/templates_osl/empty_shader.osl
new file mode 100644 (file)
index 0000000..8526e0f
--- /dev/null
@@ -0,0 +1,6 @@
+#include "stdosl.h"
+
+shader name()
+{
+
+}
\ No newline at end of file
diff --git a/release/scripts/templates_osl/noise.osl b/release/scripts/templates_osl/noise.osl
new file mode 100644 (file)
index 0000000..e152824
--- /dev/null
@@ -0,0 +1,18 @@
+#include <stdosl.h>
+
+shader noise(
+       float Time = 1.0,
+       point Point = P,
+       output float Cell = 0.0,
+       output color Perlin = 0.8,
+       output color UPerlin = 0.8)
+{   
+       /* Cell Noise */
+       Cell = noise("cell", Point);
+       
+    /* Perlin 4D Noise*/
+    Perlin = noise("perlin", Point, Time);
+   
+    /* UPerlin 4D Noise*/
+    UPerlin = noise("uperlin", Point, Time);
+}
\ No newline at end of file
diff --git a/release/scripts/templates_osl/wireframe.osl b/release/scripts/templates_osl/wireframe.osl
new file mode 100644 (file)
index 0000000..193dc7e
--- /dev/null
@@ -0,0 +1,10 @@
+#include "stdosl.h"
+#include "oslutil.h"
+
+shader wireframe(
+    float Line_Width = 2.0,
+    int Raster = 1,
+    output float Wire = 0.0)
+{
+    Wire = wireframe("triangles", Line_Width, Raster);
+}
\ No newline at end of file
index a815fb2c34d1127bad0be59e22dd899ee470bc88..f313e9a5f2af0af0817ad9615ab1fd1f5b8cd06f 100644 (file)
@@ -144,7 +144,7 @@ static int txtfmt_osl_find_specialvar(const char *string)
        if      (STR_LITERAL_STARTSWITH(string, "shader",               len)) i = len;
        else if (STR_LITERAL_STARTSWITH(string, "surface",              len)) i = len;
        else if (STR_LITERAL_STARTSWITH(string, "volume",               len)) i = len;
-       else if (STR_LITERAL_STARTSWITH(string, "displacement", len)) i = len;
+       else if (STR_LITERAL_STARTSWITH(string, "displacement", len)) i = len;
        else                                                    i = 0;
 
        /* If next source char is an identifier (eg. 'i' in "definate") no match */