// cannabis curve plasma shader

vec3 hsv2rgb(float h,float s,float v) {
	return mix(vec3(1.),clamp((abs(fract(h+vec3(3.,2.,1.)/3.)*6.-3.)-1.),0.,1.),s)*v;
}


void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
        vec2 pos = -1.0 + 2.0 * ( fragCoord.xy / iResolution.xy );
        pos.x *= iResolution.x/iResolution.y;
        pos.y += 0.6;
        
        float r = length(pos);
        float th = atan(pos.y, pos.x);
        
        
        float color = 1.0/((r*2.0) - pow(1.5*(1.0+sin(th))*(1.0+0.9*cos(8.0*th))*(1.0+0.1*cos(24.0*th))*(0.5+0.05*cos(140.0*th)), sin(iTime)*0.3+0.8));
        fragColor = vec4(hsv2rgb(((color+iTime/1.5) - th * 1.114), 1.0, clamp(5.0 - abs(color), 0.0, 1.0)) * (color < 0.01 ? vec3(0.0, 1.0, 0.0) : vec3(1.0))
                        + (color < 0.01 ? vec3(0.0, smoothstep(-5.0, 0.0, color), 0.0) : vec3(0.0)), 1.0 );    
}
