write particle id via mascript?

It’s funny I just posted a high-five that the older advection/conservation is still included in PFD and now I hit a snag ;]

I’m running a Multi-pass liquid sim with a v2.2 sim box and under output, there’s no option to save ‘particle id’ or ‘particle velocity’. The sim RnD is complete and was designed to be run at half-speed for rendering. I went to do a playback at 0.5 speed, and for every in-between frame, PFD threw an error stating the particle id isn’t found. Reading the box contents, it’s only finding size and position for the particles. Is there a way I can write the particle id via maxscript at sim time (i guess velocity also)? Need to do this as a Multi-pass sim using an older sim box - can’t get this look with Flip solver. Running version 3.11.

Thanks in advance!

Hey, what kind of particles are these? I think you should be able to get their channels exported via maxscript indeed, by using the $.prt_expmask option of the simulator.

It should look like something along these lines:
“Liquid 80000402 Splashes 80000406 Mist 80000404 Foam 80000406 WetMap 80000404”

Each of these numbers is a Hexadecimal number, and each bit in these numbers denotes which particle channels are exported:
Bit 0 is always 0
Bit 1 is the velocity
Bit 2 is the size
Bit 3 is Age
Bit 10 is ID

You can get the number you need using Windows’ calculator. For example, here’s what the number 80000406 from the string above would mean:

You can switch bits on and off for the channels you need.

Hope this helps!

I think my head just spun, hah ;D Ok, so I’m fairly light on maxscript. It’s the foam and splashes. Firstly, thank you! Much appreciated that technical breakdown. So now, for me to actually implement… would it be easier for me to sim in a v3 box and set conservation/advection via maxcript back to the older direct-symmetric and multipass? Then I might get my particle id’s via the interface. Or should I go with the above method… and then the big question.. what do I type and where? hah. sorry. I’m staring at the sample commented code in the script simulation window.

..and I now see the title is missing an ‘X’. yesh.

Indeed, that sounds like the easiest way :slight_smile: Just enable the systems and channels you need in v3, copy the string and plug it into the same parameter in v2 :wink:

Great! ;] So to change conservation/advection to older method, I’d just enter lines as… ?

fn OnSimulationStep=(

$.refltype=whatever will sim as direct-symmetric
$.advtype=whatever will sim as multipass

)

Or maybe there’s more to it?? Or less to it? ;]

Thanks again Svetlin!

Maybe..
$.refltype=0
$.advtype=3

Sounds like this should do it..

It’s working! Eureka. Thanks a ton!

I moved them over to only set once when the sim starts - I guess doesn’t need it set every frame.

..aand the sim still looks like Flip. I’ve polled the v3 box and it’s definitely set to 0 and 3 to match with the 2 types. Are there any other params that come to mind that were hard coded for v3? I guess I can set those via script also.

Hmm, the most certain way to know if you are running a grid or a FLIP simulation would be to send over the Phoenix log file. However, whether the FLIP or grid liquid solver is created should depend solely on the advtype parameter.

I might be missing something though - can you explain in more detail what you want to do and why?

Copy that regarding the advtype param - will keep that in mind. Thanks!

I just scanned the log for that string and it’s set to 4 :confused: Seems it’s not picking up the script setting.

Sure thing - I’m basically trying to achieve those little chaotic waves on the surface of my larger storm swells. The sample shows smaller tests I’m running of just the smaller waveforce active (larger swells turned off). I tried for days to get the little waves working in v3 like I had a couple years back in v2 and couldn’t replicate the look, so I loaded in one of my older v2 boxes and voila, there were those little details again. Based on the # of grids and frames I need for the camera angle, I need to stay around the grid spacing I’m at now - about 125mill. With v2 multi-pass, I can get those details, but with flip it’s unknown how small the spacing would need to be. The 2nd part of it is that I have the whole thing RnD’d already at 30fps and then need to render it for 60fps (it’s for two 8k playback screens that are to emulate live action). So I need to tween the sim frames that I’m currently running that move good at 30fps, so need that particle ID which I was going to get from the v3 sim box. But it seems it’s stuck at flip even with advtype scripted to be type 3 for multipass. Hopefully all that made sense.

On another note, if the ocean tex shader idea works out, then maybe I can forego doing all this and just try for adding the little waves with the ocean text as a bump for reflection warping.

Trying all sorts of ideas. Is anything added to the script like an override for params set in the interface? Or do I need to be simming solely from maxscript to change parameters via script. I’ve still been simming using the menu rollups. The log file still shows flip solver.

Maybe you could take a look at my scene, script, and log? It’s definitely not picking up the script setting to force it to multipass. Probably user error. Keeps reverting to flip solver when simming. Let me know if that means email (and which) or post a link. Thanks!

Indeed, you are correct, there are more fail-safes added to prevent switching to the old solver. An alternative that would work would be to save a simulator from v2 and use it - it is a 3rd type of simulator, as opposed to the fire/smoke sim and the liquid sim in v3, and won’t undergo automatic conversion. This 3rd type of simulator is no longer available for creation in Max, but can still be loaded from scenes created using v2. I’m sorry to have mislead you!

I see. However that’s where I’m having the problem with saving out particle ID. I have a v2 box and though it has the export section for particles under the ‘liquid’ rollup, whenever I check all 3 of the channels, they uncheck themselves, so then I can’t retime after my v2 sim. I scanned through the changelogs from the downloads page and couldn’t find when that bug was fixed to determine if my v2 box is just a bit too old. Would you have a later v2 box you could attach that would still allow multipass? Maybe I have an older early v2 box that had issues. Thank you!

Hmm, but wouldn’t editing the prt_expmask in v2 work out for enabling these particles? If you are using an older version, it might not be available, and instead of it there were several other parameters you can access by script:

fmid
fmvel
fmage
fmszexp

spid
spvel
spage
spszexp

lqid
lqvel
lqage
lqrgb
lqvisc
lqprt

These can be set to 0 and 1, in case “prt_expmask” does not exist in the v2 build you are using.

Cool - I’d like to give it a go, definitely.. so what would I put in here?

fn OnSimulationStep=(

…something that makes this work…

)

Actually.. I’m looking at the 2.2 help file and noticed that in the official release there was ‘export’ added to the bottom of the splash/mist and foam rollups. My v2 box doesn’t have those. Would you be able to attach an official 2.2 release scene file with a v2 box in it? Let’s call it max 2016. That’d be awesome!

Another option - a new nightly of unlocked access to the refltype and advtype for v3? ;D

You can grab any of these v2-grade scenes: Chaos Docs

In the script you can type e.g. $.fmid=1 to enable the foam ID channel export. It’s up to you to check if the long list of parameters exists with your v2 install, or if it’s v3.

When my colleagues are back in the office on Tuesday, they’ll see if they can set up a v3 scene with the desired detail - after all, it’s important to be able to get the desired result with the latest version :slight_smile:

Fantastic - thanks again Svetlin!