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; } }