[opengtl-commits] [677] add a disco effect

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 677
Author:   cyrille
Date:     2009-03-25 10:04:52 +0100 (Wed, 25 Mar 2009)

Log Message:
-----------
add a disco effect

Added Paths:
-----------
    trunk/shiva-collections/generators/Disco.shiva


Added: trunk/shiva-collections/generators/Disco.shiva
===================================================================
--- trunk/shiva-collections/generators/Disco.shiva	                        (rev 0)
+++ trunk/shiva-collections/generators/Disco.shiva	2009-03-25 09:04:52 UTC (rev 677)
@@ -0,0 +1,70 @@
+<
+  parameters: <
+    t: <
+      label: "Time";
+      type: float;
+    >;
+    xcenter: <                                                          
+      label: "Center x";                                                
+      type: float;                                                      
+    >;                                                                  
+    ycenter: <                                                          
+      label: "Center y";                                                
+      type: float;                                                      
+    >;
+    zoom: <
+      label: "Zoom";
+      type: float;
+      minValue: 0.0;
+      maxValue: 10000.0;
+      defaultValue: 1000.0;
+    >;
+    Wavelength: <
+      rl: <
+        label: "Red";
+        type: int;
+        minValue: 1;
+        maxValue: 100;
+        defaultValue: 10;
+      >;
+      gl: <
+        label: "Green";
+        type: int;
+        minValue: 1;
+        maxValue: 100;
+        defaultValue: 14;
+      >;
+      bl: <
+        label: "Blue";
+        type: int;
+        minValue: 1;
+        maxValue: 100;
+        defaultValue: 20;
+      >;
+    >;
+  >;
+>;  
+kernel Disco
+{
+  const float width = 500.0;
+  const float height = 500.0;
+  const float2 center = { width * xcenter, height * ycenter };
+  const float PI2 = 2 * 3.14159265;
+  const float q = t * PI2;
+  void evaluatePixel(out pixel4 result)
+  {
+    float2 vec = result.coord - center;
+    float angle = atan2( vec.x, vec.y);
+    float r = length(vec);
+    float rz=r*zoom;
+    
+    result = float4( fabs( sin( rz / rl + q ) + sin( angle * rl + q ) ),
+                     fabs( sin( rz / gl + q ) + sin( angle * gl + q ) ),
+                     fabs( sin( rz / bl + q ) + sin( angle * bl + q ) ), 2 ) * 0.5;
+  }
+  region generated()
+  {
+    region reg = { 0, 0, width, height};
+    return reg;
+  }
+}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/