Jump to content

Recommended Posts

Hello, I`m working on Ink style effect. I would like to add point in between two (or more) nearest existing points, interpolate velocity and push new point slightly in vel direction, to have little bit more circular interpolation. That works well, better than point jitter or different cheap techniques. I would like to still fell motion from original sim. But I stuck on duplicated positions of some points, which is logical, other points can have similar near point. So I would like to add some counter, so if there were pair in past, don`t create new point. We are talking about millions of new points, so I need it as cheap and straight forward as possible. 

Basic idea, with some new points duplicated:

float maxDistance = chf("maxDistance");
float minDistance = chf("minDistance");
int maxPoints = chi("maxPoints");

int nearPnts[] = nearpoints(0,@P,maxDistance, maxPoints);

foreach (int pnts; nearPnts){
    float distance = distance(point(0,"P",pnts), @P);

    if (distance > minDistance){
        
        vector nearPos = point(0,"P", pnts);
        vector nearVel = point(0,"v", pnts);
        
        vector centerPos = lerp(nearPos, @P, 0.5);
        vector centerVel = lerp(nearVel, @v, 0.5);
                
        centerPos += centerVel * chf("pos_offset");
        
        int newPoint = addpoint(0,centerPos);
        
        setpointattrib(0,"v",newPoint,centerVel);
        setpointattrib(0,"id",newPoint,@id*1000);
        setpointattrib(0,"newBorn",newPoint,1);
        
    } 
           
}

 

I`m trying to add some counter ("tested") but seems like I cant read this attribute and my head is twisted :blink: I can see in spreadsheed, that "tested" has some range, so I need to connect with it. Any idea? Thanks a lot

 

float minDistance = chf("minDistance");
int maxPoints = chi("maxPoints");
i@tested = 0;

int nearPnts[] = nearpoints(0,@P,maxDistance, maxPoints);

foreach (int pnts; nearPnts){
    float distance = distance(point(0,"P",pnts), @P);
    setpointattrib(0,"tested",pnts,1,"add");

    if (distance > minDistance && point(geoself(), "tested", pnts) == 1){
        
        vector nearPos = point(0,"P", pnts);
        vector nearVel = point(0,"v", pnts);
        
        vector centerPos = lerp(nearPos, @P, 0.5);
        vector centerVel = lerp(nearVel, @v, 0.5);
                
        centerPos += centerVel * chf("pos_offset");
        
        int newPoint = addpoint(0,centerPos);
        
        
        setpointattrib(0,"v",newPoint,centerVel);
        setpointattrib(0,"id",newPoint,@id*1000);
        setpointattrib(0,"newBorn",newPoint,1);
        
    }
          
}

Krakatoa.thumb.jpg.53e76941de729d5039cecc53032446f5.jpg

  • Like 1
Link to comment
Share on other sites

On 10/5/2020 at 2:34 PM, blackchicken said:

int nearPnts[] = nearpoints(0,@P,maxDistance, maxPoints);

instead of maxDistance - It should be minDistance  second Code

Or  @blackchicken Ah never Mind Here you have Magic ...Just Holding Lines For Topic..:wub:
Lava Vex..Magma.
 

int iteration = @ptnum%4;
float frameOffset = @Frame - iteration*30;
@life = 120;
int cycleCount = floor(frameOffset/@life);
@age = ((frameOffset/120) - cycleCount ) * @life * @Timeinc;
int clusterId = iteration * 1000 + cycleCount;

vector g = set(0,-9.8,0);

float dist = length(@P);
vector vDir = set(0,1,0) + vector( onoise(@P*0.5 + set(0,rand(@ptnum) * 4,0) + clusterId ,5,0.5,1))*1.25;
float vSpeed = fit( onoise(@P*2,5,0.5,1),-1,0.4,0,1 ) * fit01(pow( rand(@ptnum) ,0.5),0.5,1) * 15;
@v = vDir * vSpeed;

vector particle(vector v, gravity; float age){
    return v * age + gravity*0.5*pow(age,2);
}

vector rest = @P + particle(@v, g, 32.0/24);
float noise =  abs( onoise(rest*set(1,0.75,1)*0.25 + clusterId + 11 ,3,0.4,1 ) );
if(noise>0.005)removepoint(0,@ptnum);

float colorNoise = abs( onoise(rest*set(1,0.75,1)*0.25 + clusterId + 100 ,3,0.4,1 ) );
@Cd = chramp("color",fit(@age,0, fit(colorNoise,0.4,0,0.5,15), 0, 1 ));

@P = @P + particle(@v, g, @age);
if(@P.y<0)removepoint(0,@ptnum);

 

mod1452201401.gif

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...