[opengtl-commits] [682] add a mirror impose effect

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


Revision: 682
Author:   cyrille
Date:     2009-03-25 14:06:09 +0100 (Wed, 25 Mar 2009)

Log Message:
-----------
add a mirror impose effect

Added Paths:
-----------
    trunk/shiva-collections/filters/MirrorImpose.shiva


Added: trunk/shiva-collections/filters/MirrorImpose.shiva
===================================================================
--- trunk/shiva-collections/filters/MirrorImpose.shiva	                        (rev 0)
+++ trunk/shiva-collections/filters/MirrorImpose.shiva	2009-03-25 13:06:09 UTC (rev 682)
@@ -0,0 +1,37 @@
+kernel MirrorImpose
+{  
+  const float width = 1000.0;
+  const float height = 753.0;
+  const float2 imsize = { width, height };
+  float4 mix(float4 a, float4 b, float c)
+  {
+    return a * c + b * (1 - c);
+  }
+  float max(float a, float b)
+  {
+    if( a < b) return b;
+    return a;
+  }
+  float clamp(float a, float min, float max)
+  {
+    if( a < min ) return min;
+    if( a > max ) return max;
+    return a;
+  }
+  void evaluatePixel(image img, out pixel result)
+  {
+    float ax = result.coord.x / width;
+    float ay = result.coord.y / height;
+    float x1 = max(0, ax - ay);
+    float y1 = max(0, ay - ax);
+    float x2 = min(1, ax + (1 - ay));
+    float y2 = min(1, ay + (1 - ax));
+    float weight = clamp(1 - (ax - x1) / (x2 - x1), 0, 1);
+    result = mix(img.sampleNearest( result.coord ), img.sampleNearest( imsize - result.coord ), weight);
+    result[3] = 1.0;
+  }
+  region changed(region changed_input_region, int input_index, region input_DOD[])
+  {
+    return changed_input_region;
+  }
+}


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