PDA

View Full Version : question about shader ...

vbk!!!
03-05-2004, 01:17 PM
i tried to work from blotch.ls (from Lscript documentation)
it allow to make a circle of color on a surface.
i tried to duplicate the code generating the circle to have to circle on the surface.
The probleme is there is only one of the twice circle displaying on the surface ( generating by the last piece of code)
how can i generate two or more circles on a surface ?

here is the code :

for(i = 1; i <= 3; i++)
{
d = sa.oPos[i]- center[i] ;
d = d * d;
if(d > r2)
return;
localr2 += d;
}

if(localr2 > r2)
return;

d = sqrt(localr2);

if(d > 1.0)
d = 1.0;

for(i = 1; i <= 3; i++)
sa.color[i] = color[i];

if i use 2 lscript shader i can have a lot of circles but i want to have this with only one lscript.

thanks for your help.

fxnut
03-09-2004, 06:38 AM
I guess you're after circles being tiled all over your object huh?

What you need to do is to take the sa.oPos[] position vector and do the modulus of each x,y,z coordinate with the diameter of the circle. To that, add the center[] vector and then subtract the radius from each x,y,z, coordinate.

(The modulus is just the remainder of dividing one number by another. I.e. 22 mod 10 is 2. I can't remember what the syntax is in LScript for modulus, but most languages usually use something like 22%10, mod(22,10), or 22 mod 10, etc.)

Putting that above the code you posted will effectively remap the oPos[] position into the circle's position no matter where oPos is in space. That will make the pattern tile across the surface.