To create a spectrum with a custom number of lines, use the Iterator module. For examples, see the sample project called IteratorSpectrumExamples.magic.
Because of the (different) way in which an FFT generates a spectrum, the number of lines in the FFT Color Lines and Spectrum modules cannot be changed.
An alternative method to *simulate* more lines with a Spectrum module is to use some type of pixelation effect afterwards. For this, I use the code below. I think I've shared it before but I can't remember.
- Code: Select all
/*{
"DESCRIPTION": "Creates a pixelation grid effect on its input.",
"INPUTS": [
{
"NAME": "inputImage",
"TYPE": "image"
},
{
"NAME": "numPixels",
"LABEL": "# Pixels",
"TYPE": "float",
"DEFAULT": 64.0,
"MIN": 1.0
},
{
"NAME": "gridx",
"LABEL": "Grid X",
"TYPE": "bool",
"DEFAULT": 1.0
},
{
"NAME": "gridy",
"LABEL": "Grid Y",
"TYPE": "bool",
"DEFAULT": 1.0
},
{
"NAME": "gridSize",
"LABEL": "Grid Size",
"TYPE": "float",
"DEFAULT": 0.25,
"MIN": 0.0,
"MAX": 1.0
},
{
"NAME": "softness",
"LABEL": "Softness",
"TYPE": "float",
"DEFAULT": 0.25,
"MIN": 0.0,
"MAX": 1.0
},
],
}*/
float myStep(float pixelLocation, float flooredPixelLocation)
{
if (softness == 0.0)
return (1.0-abs(flooredPixelLocation-pixelLocation)*numPixels*2.0 > gridSize ? 1.0 : 0.0);
else
return smoothstep(gridSize*(1.0+softness)-softness, gridSize*(1.0+softness), 1.0-abs(flooredPixelLocation-pixelLocation)*numPixels*2.0);
}
void main()
{
vec2 pixelLocation = vv_FragNormCoord;
vec2 flooredPixelLocation = (floor(pixelLocation * numPixels)+.5) / numPixels;
vec4 color = IMG_NORM_PIXEL(inputImage, flooredPixelLocation);
gl_FragColor = color * (gridx ? myStep(pixelLocation.x, flooredPixelLocation.x) : 1.0) * (gridy ? myStep(pixelLocation.y, flooredPixelLocation.y) : 1.0);
}