[opengtl-commits] [454] add a few more examples |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 454
Author: cyrille
Date: 2008-10-17 00:14:07 +0200 (Fri, 17 Oct 2008)
Log Message:
-----------
add a few more examples
Modified Paths:
--------------
trunk/OpenGTL/OpenGTL/GTLCore/Optimiser_p.cpp
trunk/OpenGTL/OpenShiva/examples/Bullify.shiva
Added Paths:
-----------
trunk/OpenGTL/OpenShiva/examples/RadialGradient.shiva
trunk/OpenGTL/OpenShiva/examples/Ripples.shiva
trunk/OpenGTL/OpenShiva/examples/Something.shiva
trunk/OpenGTL/OpenShiva/examples/SunRay.shiva
trunk/OpenGTL/OpenShiva/examples/SuperNova.shiva
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Optimiser_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Optimiser_p.cpp 2008-10-13 20:34:05 UTC (rev 453)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Optimiser_p.cpp 2008-10-16 22:14:07 UTC (rev 454)
@@ -75,7 +75,7 @@
Optimiser::Private::Private() : m_passManager(0)
{
- setLevel( 4 );
+ setLevel( 2 );
}
Optimiser::Private::~Private()
Modified: trunk/OpenGTL/OpenShiva/examples/Bullify.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/examples/Bullify.shiva 2008-10-13 20:34:05 UTC (rev 453)
+++ trunk/OpenGTL/OpenShiva/examples/Bullify.shiva 2008-10-16 22:14:07 UTC (rev 454)
@@ -1,7 +1,7 @@
kernel Bullify
{
- const float2 center = { 400.0, 400.0 };
- const float lightLength = 400.0;
+ const float2 center = { 3900.0/2.0, 2613/2.0 };
+ const float lightLength = 2613/2.0;
float length( float2 v)
{
Added: trunk/OpenGTL/OpenShiva/examples/RadialGradient.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/examples/RadialGradient.shiva (rev 0)
+++ trunk/OpenGTL/OpenShiva/examples/RadialGradient.shiva 2008-10-16 22:14:07 UTC (rev 454)
@@ -0,0 +1,20 @@
+kernel ColorsRay
+{
+ const float width = 500.0;
+ const float height = 500.0;
+ const float2 center = { width/2.0, height/2.0 };
+ 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;
+ }
+}
Added: trunk/OpenGTL/OpenShiva/examples/Ripples.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/examples/Ripples.shiva (rev 0)
+++ trunk/OpenGTL/OpenShiva/examples/Ripples.shiva 2008-10-16 22:14:07 UTC (rev 454)
@@ -0,0 +1,23 @@
+kernel Ripples
+{
+ const float2 center = { 3900.0/2.0, 2613/2.0 };
+ const float ripplesLength = 100.0;
+ const float waveslength = 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 * waveslength ) * 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;
+ }
+}
Added: trunk/OpenGTL/OpenShiva/examples/Something.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/examples/Something.shiva (rev 0)
+++ trunk/OpenGTL/OpenShiva/examples/Something.shiva 2008-10-16 22:14:07 UTC (rev 454)
@@ -0,0 +1,50 @@
+kernel Something
+{
+ const float width = 600.0;
+ const float height = 600.0;
+ const float2 center = { width/2.0, height/2.0 };
+ const float PI = 3.14159265;
+ const float4 color1 = { 0.2, 0.01, 0.08, 1.0 };
+ const float4 colorCenter = { 1.0, 1.0, 1.0, 1.0 };
+ const float phase = 6.0;
+ const float radius = 200.0;
+ 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;
+ }
+}
Added: trunk/OpenGTL/OpenShiva/examples/SunRay.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/examples/SunRay.shiva (rev 0)
+++ trunk/OpenGTL/OpenShiva/examples/SunRay.shiva 2008-10-16 22:14:07 UTC (rev 454)
@@ -0,0 +1,36 @@
+kernel SunRay
+{
+ const float width = 500.0;
+ const float height = 500.0;
+ const float2 center = { width/2.0, height/2.0 };
+ const float PI = 3.14159265;
+ const float4 color = { 0.3, 0.05, 0.01, 1.0 };
+ const float fluctuation = 0.5;
+ const float phase = 30.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;
+ }
+}
Added: trunk/OpenGTL/OpenShiva/examples/SuperNova.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/examples/SuperNova.shiva (rev 0)
+++ trunk/OpenGTL/OpenShiva/examples/SuperNova.shiva 2008-10-16 22:14:07 UTC (rev 454)
@@ -0,0 +1,55 @@
+kernel SuperNova
+{
+ const float width = 1000.0;
+ const float height = 1000.0;
+ const float2 center = { width/2.0, height/2.0 };
+ const float PI = 3.14159265;
+ const float4 color1 = { 0.1, 0.1, 0.2, 1.0 };
+ const float4 color2 = { 0.2, 0.2, 0.4, 1.0 };
+ const float4 colorCenter = { 0.9, 0.9, 1.0, 1.0 };
+ const float phase = 30.0;
+ const float radius = 20.0;
+ const float color2radius = 10.0;
+ 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;
+ }
+}