Archived post by mattiasmalmer

cateye…

“`
#bind layer src? val=0 #bind layer !&dst
inline float2 fibonacci_spiral(int n ,int samples) { float phi = (1.0f + sqrt(5.0f)) / 2.0f; // Golden ratio float angle = 2.0f * M_PI * phi * n; float r = 1.0f * sqrt((float)n /samples); // Normalized radius float x = r * cos(angle); float y = r * sin(angle); return (float2)(x,y); }
inline float2 scale_along_vector(float2 pos, float2 dir, float scale) { // Normalize the direction float2 n = normalize(dir); // Project pos onto dir float proj_len = dot(pos, n); float2 proj = proj_len * n; // Compute the component orthogonal to dir float2 ortho = pos – proj; // Scale only the projection return proj * scale + ortho; }

@KERNEL { float2 pos=(float2)(@ix,@iy); float4 color=(float4)(0,0,0,0);
for (int i=0; i<@samples; i++) { float2 disc=fibonacci_spiral(i,@samples)*@radii; float2 dir=pos-(float2)(@xres,@yres)*.5f; float dist=length(dir)/length((float2)(@xres,@yres)*.5f); disc=scale_along_vector(disc , dir ,(1-pow(dist,1.0f)*@squash)); color+=@src.bufferSample(pos+disc); }
@dst.set(color/@samples); }
“`
just make radii, squash and (int)samples in the bindings

Attachments in this post:
http://fx-td.com/houdiniandchill/wp-content/uploads/discord/20253105/22/25/image.png