ISF - Masking - Vignette Spot


/*{
	"CREDIT": "Joris de Jong",
	"DESCRIPTION": "Vignette Spot",
	"CATEGORIES": [
		"filter"
	],
	"INPUTS": [
		{
			"NAME": "inputImage",
			"TYPE": "image"
		},
		{
			"NAME": "center_x",
			"TYPE": "float"
		},
		{
			"NAME": "center_y",
			"TYPE": "float"
		},
		{
			"NAME": "Radius",
			"TYPE": "float",
			"DEFAULT": 0.5
		},
		{
			"NAME": "Softness",
			"TYPE": "float",
			"DEFAULT": 0.2
		},
		{
			"NAME": "keep_ratio",
			"TYPE": "bool",
			"DEFAULT": 0.0
		}
	]
}*/

#define aspectRatio RENDERSIZE.x/RENDERSIZE.y
vec2 Position = vec2(center_x, center_y);

float circle(in vec2 center, in float lRadius, in float blur) {
	float aspect = RENDERSIZE.x / RENDERSIZE.y;
	vec2 pixel = isf_FragNormCoord.xy;
    vec2 dist = pixel - center;
   	if (!keep_ratio) dist.y /= aspectRatio;

	return 1.-smoothstep( lRadius - ( lRadius * blur ),
                         lRadius + ( lRadius * blur ),
                         dot( dist, dist ) * 4.0 );
}

void main() {
	float mask = circle( Position, Radius, Softness );
	vec4 color = IMG_NORM_PIXEL(inputImage, isf_FragNormCoord.xy);
	color.a = mask;
	gl_FragColor = color;
}