Forums
You are not logged in.
#1 2012-07-26 07:55:35
- GreenEminence89
- New member
- From: Poland
- Registered: 2012-07-26
- Posts: 1
- Website
Fibonacci sequence coordinates
Hello,
I'm having trouble with setting up correct coordinates for little shader taken from GuoQiang Xie Slim template. It's based on Fibonacci sequence, distributing little dots across the surface.
Here's the code:
Code:
float circle(float centerx, centery, radius)
{
float result;
extern float s,t;
float tt = 2*sqrt(pow(centerx-s,2)+pow(centery-t,2));
if( pow(s-centerx,2) + pow(t-centery,2) <= radius *radius)
// result = 1;
result = abs (smoothstep(0,radius*2,tt)-1);
else
result = 0;
return result;
}
surface tiaDot(float spread_radius = .05; float seed_num = 80; float dot_radius = .02)
{
float i = 0 ,x = 0, y = 0, r =0;
float result = 0;;
for(i=0; i<= seed_num; i+=1)
{
x = sqrt(i) * spread_radius * cos (radians(i*137.5));
y = sqrt(i) * spread_radius * sin (radians(i*137.5));
result += circle(x+.5, y+.5, dot_radius);
}
Ci = result;
}Everything looks great attached to simple polygon, but not so great when attached to a sphere.
Any idea how to alter the code to make an even distribution across the sphere? The idea was to make the dots dissapear on bottom and top part of a sphere (just like a strawberry pattern).
Offline

