[opengtl-commits] [596] add kernels from the collection

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


Revision: 596
Author:   cyrille
Date:     2009-03-12 17:47:20 +0100 (Thu, 12 Mar 2009)

Log Message:
-----------
add kernels from the collection

Added Paths:
-----------
    trunk/shiva-collections/CMakeLists.txt
    trunk/shiva-collections/filters/
    trunk/shiva-collections/filters/AntiBullify.shiva
    trunk/shiva-collections/filters/Bullify.shiva
    trunk/shiva-collections/filters/Ripples.shiva
    trunk/shiva-collections/filters/Something.shiva
    trunk/shiva-collections/generators/
    trunk/shiva-collections/generators/RadialGradient.shiva
    trunk/shiva-collections/generators/SunRay.shiva
    trunk/shiva-collections/generators/SuperNova.shiva

Property Changed:
----------------
    trunk/shiva-collections/


Property changes on: trunk/shiva-collections
___________________________________________________________________
Name: svn:ignore
   + 
..kdev4

shiva-collections.kdev4


Added: trunk/shiva-collections/CMakeLists.txt
===================================================================
--- trunk/shiva-collections/CMakeLists.txt	                        (rev 0)
+++ trunk/shiva-collections/CMakeLists.txt	2009-03-12 16:47:20 UTC (rev 596)
@@ -0,0 +1,7 @@
+project(shiva-collections)
+cmake_minimum_required(VERSION 2.6)
+
+set(SHARE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/OpenGTL/)
+
+add_subdirectory(generators)
+add_subdirectory(filters)

Copied: trunk/shiva-collections/filters/AntiBullify.shiva (from rev 560, trunk/OpenGTL/OpenShiva/examples/AntiBullify.shiva)
===================================================================
--- trunk/shiva-collections/filters/AntiBullify.shiva	                        (rev 0)
+++ trunk/shiva-collections/filters/AntiBullify.shiva	2009-03-12 16:47:20 UTC (rev 596)
@@ -0,0 +1,42 @@
+<
+  parameters: <
+    xcenter: <
+      label: "Center x";
+      type: float;
+    >;
+    ycenter: <
+      label: "Center y";
+      type: float;
+    >;
+    lightLengthP:  <
+      label: "Zoom";
+      type: float;
+      minValue: 0.01;
+    >;
+  >;
+>;  
+kernel AntiBullify
+{
+  const float width = 1000;
+  const float height = 800;
+  const float2 center = { xcenter * width, ycenter * height };
+  const float lightLength = lightLengthP * 0.5 * (width + height );
+  
+  float length( float2 v)
+  {
+    v *= v;
+    return sqrt( v[0] + v[1] );
+  }
+  
+  void evaluatePixel(image4 img, out pixel4 result)
+  {
+    float2 vec = result.coord - center;
+    float factor = length( vec ) / lightLength;
+    factor = 1.0 / (factor * factor);
+    result = img.sampleNearest( vec * factor + center );
+  }
+  region changed(region changed_input_region, int input_index, region input_DOD[])
+  {
+    return changed_input_region;
+  }
+}


Property changes on: trunk/shiva-collections/filters/AntiBullify.shiva
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: trunk/shiva-collections/filters/Bullify.shiva (from rev 560, trunk/OpenGTL/OpenShiva/examples/Bullify.shiva)
===================================================================
--- trunk/shiva-collections/filters/Bullify.shiva	                        (rev 0)
+++ trunk/shiva-collections/filters/Bullify.shiva	2009-03-12 16:47:20 UTC (rev 596)
@@ -0,0 +1,41 @@
+<
+  parameters: <
+    xcenter: <
+      label: "Center x";
+      type: float;
+    >;
+    ycenter: <
+      label: "Center y";
+      type: float;
+    >;
+    lightLengthP:  <
+      label: "Zoom";
+      type: float;
+      minValue: 0.01;
+    >;
+  >;
+>;  
+kernel Bullify
+{
+  const float width = 1000;
+  const float height = 800;
+  const float2 center = { xcenter * width, ycenter * height };
+  const float lightLength = lightLengthP * 0.5 * (width + height );
+  float length( float2 v)
+  {
+    v *= v;
+    return sqrt( v[0] + v[1] );
+  }
+  
+  void evaluatePixel(image4 img, out pixel4 result)
+  {
+    float2 vec = result.coord - center;
+    float factor = length( vec ) / lightLength;
+    factor *= factor;
+    result = img.sampleNearest( vec * factor + center );
+  }
+  region changed(region changed_input_region, int input_index, region input_DOD[])
+  {
+    return changed_input_region;
+  }
+}


Property changes on: trunk/shiva-collections/filters/Bullify.shiva
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: trunk/shiva-collections/filters/Ripples.shiva (from rev 560, trunk/OpenGTL/OpenShiva/examples/Ripples.shiva)
===================================================================
--- trunk/shiva-collections/filters/Ripples.shiva	                        (rev 0)
+++ trunk/shiva-collections/filters/Ripples.shiva	2009-03-12 16:47:20 UTC (rev 596)
@@ -0,0 +1,42 @@
+<
+  parameters: <
+    xcenter: <
+      label: "Center x";
+      type: float;
+    >;
+    ycenter: <
+      label: "Center y";
+      type: float;
+    >;
+    ripplesLength: <
+      label: "Ripples length";
+      type: float;
+      minValue: 0.01;
+      maxValue: 1000.0;
+    >;
+  >;
+>;  
+kernel Ripples
+{
+  const float width = 500.0;
+  const float height = 500.0;
+  const float2 center = { width * xcenter, height * ycenter };
+  const float waveslengthInv = 1.0 / 50.0;
+  float length( float2 v)
+  {
+    v *= v;
+    return sqrt( v[0] + v[1] );
+  }
+  
+  void evaluatePixel(image4 img, out pixel4 result)
+  {
+    float2 vec = result.coord - center;
+    float vec_length = length( vec );
+    float displacement = cos( vec_length * waveslengthInv ) * ripplesLength / vec_length;
+    result = img.sampleNearest( vec * ( 1.0 + displacement  ) + center );
+  }
+  region changed(region changed_input_region, int input_index, region input_DOD[])
+  {
+    return changed_input_region;
+  }
+}


Property changes on: trunk/shiva-collections/filters/Ripples.shiva
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: trunk/shiva-collections/filters/Something.shiva (from rev 560, trunk/OpenGTL/OpenShiva/examples/Something.shiva)
===================================================================
--- trunk/shiva-collections/filters/Something.shiva	                        (rev 0)
+++ trunk/shiva-collections/filters/Something.shiva	2009-03-12 16:47:20 UTC (rev 596)
@@ -0,0 +1,84 @@
+<
+  parameters: <
+    colors: <
+      colorrgb: <
+        label: "Object";
+        type: rgb;
+        defaultValue: { 0.2, 0.01, 0.08 };
+      >;
+      colorcenterrgb: <
+        label: "Background";
+        type: rgb;
+        defaultValue: { 1.0, 1.0, 1.0 };
+      >;
+    >;
+    xcenter: <
+      label: "Center x";
+      type: float;
+    >;
+    ycenter: <
+      label: "Center y";
+      type: float;
+    >;
+    phase: <
+      label: "Phase";
+      type: float;
+      defaultValue: 6.0;
+      maxValue: 32.0;
+    >;
+    radiusp: <
+      label: "Radius";
+      type: float;
+      defaultValue: 0.8;
+    >;
+  >;
+>;
+kernel Something
+{
+  const float width = 500.0;
+  const float height = 500.0;
+  const float2 center = { width * xcenter, height * ycenter };
+  const float PI = 3.14159265;
+  const float4 color1 = { colorrgb[0], colorrgb[1], colorrgb[2], 1.0 };
+  const float4 colorCenter = { colorcenterrgb[0], colorcenterrgb[1], colorcenterrgb[2], 1.0 };
+  const float radius = 0.2 * (width + height) * radiusp;
+  float length( float2 v)
+  {
+    v *= v;
+    return sqrt( v[0] + v[1] );
+  }
+  
+  void evaluatePixel(out pixel4 result)
+  {
+    float2 vec = result.coord - center;
+    float vec_length = length( vec );
+    float angle = atan2( vec.x, vec.y);
+    float coef = (cos( angle * phase) + cos( angle * 0.5 * phase ) + cos( angle * 0.1 * phase ) + cos( angle * 0.01 * phase )) * 0.25;
+//      float coef = (cos( angle * phase) * cos( angle * 0.5 * phase ) * cos( angle * 0.1 * phase ) * cos( angle * 0.01 * phase ));
+   if( coef < 0.0 ) coef = - coef;
+    coef = 1.0 - coef;
+    float adjRadius = radius  * ( 0.5 + 1.0 * coef );
+    if( vec_length < adjRadius )
+    {
+      if( vec_length < adjRadius )
+      {
+	coef = pow((radius - vec_length) / adjRadius , 1.0 ) * ( 1.0 - coef) + coef;
+      }
+      result = ( 1 - coef ) * color1 + coef * colorCenter;
+      
+      for( int i = 0; i < 3; ++i)
+      {
+	if(result[i] < 0) result[i] = 0.0;
+	else if(result[i] > 1) result[i] = 1.0;
+      }
+      result[3] = 1.0;
+    } else {
+      result = colorCenter;
+    }
+  }
+  region generated()
+  {
+    region reg = { 0, 0, width, height};
+    return reg;
+  }
+}


Property changes on: trunk/shiva-collections/filters/Something.shiva
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: trunk/shiva-collections/generators/RadialGradient.shiva (from rev 560, trunk/OpenGTL/OpenShiva/examples/RadialGradient.shiva)
===================================================================
--- trunk/shiva-collections/generators/RadialGradient.shiva	                        (rev 0)
+++ trunk/shiva-collections/generators/RadialGradient.shiva	2009-03-12 16:47:20 UTC (rev 596)
@@ -0,0 +1,32 @@
+<
+  parameters: <
+    xcenter: <
+      label: "Center x";
+      type: float;
+    >;
+    ycenter: <
+      label: "Center y";
+      type: float;
+    >;
+  >;
+>;  
+kernel RadialGradient
+{
+  const float width = 500.0;
+  const float height = 500.0;
+  const float2 center = { width * xcenter, height * ycenter };
+  const float PI = 3.14159265;
+  void evaluatePixel(out pixel4 result)
+  {
+    float2 vec = result.coord - center;
+    float angle = atan2( vec.x, vec.y);
+    float coef = angle / PI;
+    if( coef < 0.0 ) coef = - coef;
+    result = float4(coef, coef, coef, 1.0);
+  }
+  region generated()
+  {
+    region reg = { 0, 0, width, height};
+    return reg;
+  }
+}


Property changes on: trunk/shiva-collections/generators/RadialGradient.shiva
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: trunk/shiva-collections/generators/SunRay.shiva (from rev 560, trunk/OpenGTL/OpenShiva/examples/SunRay.shiva)
===================================================================
--- trunk/shiva-collections/generators/SunRay.shiva	                        (rev 0)
+++ trunk/shiva-collections/generators/SunRay.shiva	2009-03-12 16:47:20 UTC (rev 596)
@@ -0,0 +1,63 @@
+<
+  parameters: <
+    xcenter: <
+      label: "Center x";
+      type: float;
+    >;
+    ycenter: <
+      label: "Center y";
+      type: float;
+    >;
+    fluctuation: <
+      label: "Fluctuation";
+      type: float;
+    >;
+    phase: <
+      label: "Phase";
+      type:float;
+      minValue: 0.1;
+      maxValue: 100.0;
+      defaultValue: 30.0;
+    >;
+    colorrgb: <
+      label: "Color";
+      type: rgb;
+      defaultValue: { 0.3, 0.05, 0.01 };
+    >;
+  >;
+>;
+
+kernel SunRay
+{
+  const float width = 500.0;
+  const float height = 500.0;
+  const float2 center = { width * xcenter, height * ycenter };
+  const float PI = 3.14159265;
+  const float4 color = { colorrgb[0], colorrgb[1], colorrgb[2], 1.0 };
+  float length( float2 v)
+  {
+    v *= v;
+    return sqrt( v[0] + v[1] );
+  }
+  
+  void evaluatePixel(out pixel4 result)
+  {
+    float2 vec = result.coord - center;
+    float angle = atan2( vec.x, vec.y);
+    float coef = cos(angle * phase);
+    if( coef < 0.0 ) coef = - coef;
+    result = color + fluctuation * coef;
+    
+    for( int i = 0; i < 3; ++i)
+    {
+      if(result[i] < 0) result[i] = 0.0;
+      else if(result[i] > 1) result[i] = 1.0;
+    }
+    result[3] = 1.0;
+  }
+  region generated()
+  {
+    region reg = { 0, 0, width, height};
+    return reg;
+  }
+}


Property changes on: trunk/shiva-collections/generators/SunRay.shiva
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: trunk/shiva-collections/generators/SuperNova.shiva (from rev 560, trunk/OpenGTL/OpenShiva/examples/SuperNova.shiva)
===================================================================
--- trunk/shiva-collections/generators/SuperNova.shiva	                        (rev 0)
+++ trunk/shiva-collections/generators/SuperNova.shiva	2009-03-12 16:47:20 UTC (rev 596)
@@ -0,0 +1,97 @@
+
+<
+  parameters: <
+    colors: <
+      color1: <
+        type: rgba;
+        defaultValue: { 0.1, 0.1, 0.2, 1.0 };
+      >;
+      color2: <
+        type: rgba;
+        defaultValue: { 0.2, 0.2, 0.4, 1.0 };
+      >;
+      colorCenter: <
+        type: rgba;
+        defaultValue: { 0.9, 0.9, 1.0, 1.0 };
+      >;
+    >;
+    xcenter: <
+      label: "Center x";
+      type: float;
+    >;
+    ycenter: <
+      label: "Center y";
+      type: float;
+    >;
+    phase: <
+      label: "Phase";
+      type: float;
+      minValue: 0.1;
+      defaultValue: 30.0;
+      maxValue: 100.0;
+    >;
+    radiusp: <
+      label: "Inner Radius";
+      type: float;
+      defaultValue: 0.01;
+    >;
+    color2radiusp: <
+      label: "Outter Radius";
+      type: float;
+      defaultValue: 0.02;
+    >;
+  >;
+>;
+
+kernel SuperNova
+{
+  const float width = 1000.0;
+  const float height = 1000.0;
+  const float wh = 0.25 * (width + height);
+  const float2 center = { width * xcenter, height * ycenter };
+  const float PI = 3.14159265;
+  const float radius = radiusp * wh;
+  const float color2radius = color2radiusp * wh;
+  float length( float2 v)
+  {
+    v *= v;
+    return sqrt( v[0] + v[1] );
+  }
+  
+  void evaluatePixel(out pixel4 result)
+  {
+    float2 vec = result.coord - center;
+    float vec_length = length( vec );
+    float angle = atan2( vec.x, vec.y);
+    float coef = 0.9 * (cos( angle * phase) * cos( angle * 0.5 * phase ) * cos( angle * 0.1 * phase ) * cos( angle * 0.01 * phase )) + 0.1;
+    if( coef < 0.0 ) coef = - coef;
+    float adjRadius = radius  * ( 1.0 + 2.0 * coef ); //( 0.5 + 0.5 * cos(angle) );
+    if( vec_length > adjRadius )
+    {
+      if( vec_length < adjRadius )
+      {
+	coef = pow((radius - vec_length) / adjRadius , 1.0 ) * ( 1.0 - coef) + coef;
+      }
+      float coef2 = 1.0;
+      if( vec_length < color2radius * radius )
+      {
+	coef2 = (vec_length - radius) / ( (color2radius - 1.0) * radius );
+      }
+      result = ( 1 - coef ) * (  coef2 * color1 + (1 - coef2) *  color2) + coef * colorCenter;
+      
+      for( int i = 0; i < 3; ++i)
+      {
+	if(result[i] < 0) result[i] = 0.0;
+	else if(result[i] > 1) result[i] = 1.0;
+      }
+      result[3] = 1.0;
+    } else {
+      result = colorCenter;
+    }
+  }
+  region generated()
+  {
+    region reg = { 0, 0, width, height};
+    return reg;
+  }
+}


Property changes on: trunk/shiva-collections/generators/SuperNova.shiva
___________________________________________________________________
Name: svn:mergeinfo
   + 


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