Permalink
Browse files

Add ElColourSquares by elbrujodelatribu

  • Loading branch information...
1 parent 16916a4 commit 777baad08bb8122ef2befbd69faf6315c16c6046 sambler committed Apr 21, 2013
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,65 @@
+/*
+ * ElColourSquares.osl by elbrujodelatribu (c)2012
+ * from https://github.com/sambler/osl-shaders
+ *
+ * original script from - http://blenderartists.org/forum/showthread.php?270332-OSL-Goodness/page17
+ *
+ */
+
+/*
+* Migrated from "http://glsl.heroku.com/e#5335.0"
+* Author: elbrujodelatribu
+*/
+
+#include "stdosl.h"
+
+// Devuelve la parte fraccional
+float fract(float x)
+{
+ return (x - floor(x));
+}
+
+// Devuelve la parte fractional, coordenada por coordenada
+point fract(point x)
+{
+ return point(fract(x[0]),fract(x[1]),fract(x[2]));
+}
+
+point tri(point p, float r)
+{
+ point pos = p;
+
+ pos *= r;
+ point x = fract(pos);
+ point i = pos - x;
+ point c = point(sin(i[0]*2.0), sin(i[1]*2.0), 0.0)*0.2+0.2;
+
+ return (((x[0] < x[1]) == (x[0] < 1.0 - x[1])) ? 1.0 : 0.0) * c;
+}
+
+shader ElColourSquares(
+ float Scale = 1.0,
+ vector Vector = P,
+ output color ColorOut = 0.8)
+{
+ vector pos = Vector*Scale;
+
+ float r = 20.0;
+ point x = fract(pos*r);
+ point i = pos*r - x;
+
+ float w = 50.0;
+ float l = clamp(0.0, 1.0, (0.5 - abs(x[0]-0.5))*w);
+ l *= clamp(0.0, 1.0, (0.5 - abs(x[1]-0.5))*w);
+ l *= clamp(0.0, 1.0, abs(x[0] - x[1])*w);
+ l *= clamp(0.0, 1.0, abs(1.0 - x[0] - x[1])*w);
+
+ point tc = tri(pos, r);
+ tc += tri(pos, r*0.5);
+ tc += tri(pos, r*0.25);
+ tc += tri(pos, r*0.125);
+
+ //Fac = tc*l;
+ ColorOut = color(tc*l);
+}
+
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<material view_color="rgb(0.80000, 0.80000, 0.80000)" sample_lamp="True">
+ <nodes>
+ <node type="TEX_COORD" dupli="False" width="150" loc="-445, 296" />
+ <node type="SCRIPT" mode="INTERNAL" script="0" scale="1.0" vector="Vector(0.0, 0.0, 0.0)" width="140" loc="-234, 302" />
+ <node type="BSDF_DIFFUSE" color="rgba(0.80000, 0.80000, 0.80000, 1.0)" roughness="0.0" width="150" loc="-51, 313" />
+ <node type="OUTPUT_MATERIAL" width="120" loc="139, 303" />
+ </nodes>
+ <links>
+ <link to="3" input="0" from="2" output="0" />
+ <link to="2" input="0" from="1" output="0" />
+ <link to="1" input="1" from="0" output="2" />
+ </links>
+ <scripts>
+ <script name="ElColourSquares.osl" id="0">
+/*<br /> * ElColourSquares.osl by elbrujodelatribu (c)2012<br /> * from https://github.com/sambler/osl-shaders<br /> *<br /> * original script from - http://blenderartists.org/forum/showthread.php?270332-OSL-Goodness/page17<br /> *<br /> */<br /><br />/*<br />* Migrated from &quot;http://glsl.heroku.com/e#5335.0&quot;<br />* Author: elbrujodelatribu<br />*/<br /><br />#include &quot;stdosl.h&quot;<br /><br />// Devuelve la parte fraccional<br />float fract(float x)<br />{<br /> return (x - floor(x));<br />}<br /><br />// Devuelve la parte fractional, coordenada por coordenada<br />point fract(point x)<br />{<br /> return point(fract(x[0]),fract(x[1]),fract(x[2]));<br />}<br /><br />point tri(point p, float r)<br />{<br /> point pos = p;<br /><br /> pos *= r;<br /> point x = fract(pos);<br /> point i = pos - x;<br /> point c = point(sin(i[0]*2.0), sin(i[1]*2.0), 0.0)*0.2+0.2;<br /><br /> return (((x[0] &lt; x[1]) == (x[0] &lt; 1.0 - x[1])) ? 1.0 : 0.0) * c;<br />}<br /><br />shader ElColourSquares(<br /> float Scale = 1.0,<br /> vector Vector = P,<br /> output color ColorOut = 0.8)<br />{<br /> vector pos = Vector*Scale;<br /><br /> float r = 20.0;<br /> point x = fract(pos*r);<br /> point i = pos*r - x;<br /><br /> float w = 50.0;<br /> float l = clamp(0.0, 1.0, (0.5 - abs(x[0]-0.5))*w);<br /> l *= clamp(0.0, 1.0, (0.5 - abs(x[1]-0.5))*w);<br /> l *= clamp(0.0, 1.0, abs(x[0] - x[1])*w);<br /> l *= clamp(0.0, 1.0, abs(1.0 - x[0] - x[1])*w);<br /><br /> point tc = tri(pos, r);<br /> tc += tri(pos, r*0.5);<br /> tc += tri(pos, r*0.25);<br /> tc += tri(pos, r*0.125);<br /><br /> //Fac = tc*l;<br /> ColorOut = color(tc*l);<br />}<br /><br />
+ </script>
+ </scripts>
+</material>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 777baad

Please sign in to comment.