EdwinFumano Posted Saturday at 08:02 PM Share Posted Saturday at 08:02 PM Hey guys. I have this infection setup but i would like to stop the infection and fade it out to 0 over some time. Then start again at a different spot and repeat the whole thing. basically like an animated attrib noise but with a fade in/out(growth) to it. Any help would be awesome! Infection.hiplc Quote Link to comment Share on other sites More sharing options...
Librarian Posted Saturday at 08:36 PM Share Posted Saturday at 08:36 PM This effect Or?! @EdwinFumano 1 Quote Link to comment Share on other sites More sharing options...
EdwinFumano Posted Sunday at 05:28 AM Author Share Posted Sunday at 05:28 AM yes, kinda @Librarian. but the task it to make them disappear after some time again. idea is to grow some plants on this infected spots and have them fade out again and start again in a different spot Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted Sunday at 09:34 PM Share Posted Sunday at 09:34 PM Hi @EdwinFumano, you could calculate a bunch of eikonal distances using attribute fill inside a for loop and remap them as animation: float speed = chf('speed'); float t = @Time * speed; int i = floor(t); float u = frac(t); int n = npointsgroup(0, 'start'); string att = 'dist_' + itoa(i%n); float dist = point(0, att, i@ptnum); float mask = chramp('shape', dist - u + 1.0); float fade = 1.0 - smooth(0.5, 1.0, u); f@mask = mask * fade; setdetailattrib(0, 'active_dist', att, 'set'); infection.hip 3 Quote Link to comment Share on other sites More sharing options...
EdwinFumano Posted Monday at 08:07 AM Author Share Posted Monday at 08:07 AM wow, thanks @konstantin magnus for looking into it. will check it out asap. cheers! Quote Link to comment Share on other sites More sharing options...
EdwinFumano Posted Monday at 01:32 PM Author Share Posted Monday at 01:32 PM yo @konstantin magnus first of all thanks again for sharing this setup. how would i go about changing it towards the mask not appearing after another but rather staying around for some time while the next appears. so there are multiple spots bulding up / fading at at the same time? Quote Link to comment Share on other sites More sharing options...
Librarian Posted Monday at 03:31 PM Share Posted Monday at 03:31 PM combine in Solver that setup and this setup. float max_age = chf("infect_lifetime"); float fade_duration = chf("fade_duration"); if (@infect < 1) { string hdapath = "../../../.."; float radius; if ((chi(hdapath + "/useradiusattrib") == 1) && haspointattrib(0, chs(hdapath + "/radiusattrib"))) { radius = point(0, chs(hdapath + "/radiusattrib"), @ptnum); } else { radius = chf(hdapath + "/radius"); } float resist; if ((chi(hdapath + "/useresistattrib") == 1) && haspointattrib(0, chs(hdapath + "/resistattrib"))) { resist = point(0, chs(hdapath + "/resistattrib"), @ptnum); } else { resist = 0; } float strength = chf(hdapath + "/strength"); int npts[] = nearpoints(0, @P, radius); float accum = 0; int cnt = 0; foreach (int npt; npts){ float infection = point(0, "infect", npt); accum += infection * strength; cnt++; } float avginfect = accum / max(cnt, 1); @infect = clamp(@infect + avginfect * (1 - resist), 0, 1); } if (@infect > 0.01) { @infect_age += 1; } else { @infect_age = 0; } if (@infect_age > max_age) { float t = fit(@infect_age, max_age, max_age + fade_duration, 1, 0); @infect = clamp(t, 0, 1); } if (@infect <= 0.01 && @infect_age > max_age + fade_duration) { @infect = 0; @infect_age = 0; if (rand(@ptnum + @Frame) < 0.91) { @infect = 0.1; } } 1 Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted Tuesday at 08:15 AM Share Posted Tuesday at 08:15 AM 18 hours ago, EdwinFumano said: so there are multiple spots bulding up / fading at at the same time? Put the relevant parts of the code inside a loop to offset the time and increment the mask number with each iteration. float speed = chf('speed'); int num = chi('infections'); float t = @Time * speed; int n = npointsgroup(0, 'start'); float mask_collect = 0.0; for(int k = 0; k < num; k++){ t += 1.0 / float(num); int i = floor(t); float u = frac(t); string att = 'dist_' + itoa(i+k%n); float dist = point(0, att, i@ptnum); float mask = chramp('shape', dist - u + 1.0); float fade = 1.0 - smooth(0.5, 1.0, u); mask_collect = max(mask_collect, mask * fade); } f@mask = mask_collect; infection_multiple.hip 1 Quote Link to comment Share on other sites More sharing options...
EdwinFumano Posted Tuesday at 11:53 AM Author Share Posted Tuesday at 11:53 AM thanks @konstantin magnus, really appreciate it! also thanks @Librarianfor looking into it as well- Quote Link to comment Share on other sites More sharing options...
EdwinFumano Posted Tuesday at 02:19 PM Author Share Posted Tuesday at 02:19 PM @konstantin magnus one more question though. some of the points get more infected than others. is there a way to make this more uniform? cheers! Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted Tuesday at 03:03 PM Share Posted Tuesday at 03:03 PM 41 minutes ago, EdwinFumano said: some of the points get more infected than others. This could be due to the internal order of the point group. try shuffling starting points by randomly picking a point number out of the array: int seed = chi('seed'); int pts[] = expandpointgroup(0, 'start'); int iter = detail(1, 'iteration', 0); int pick = pts[int(rand(iter, seed) * len(pts))]; i@group_boundary = i@ptnum == pick; infection_multiple_01.hip 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.