AWS Thinkbox Discussion Forums

Krakatoa random velocity before partitioning

Hi there,

After some digging we found a way to have random positioning of the particles before partitioning process (simple noise modifier or thinkboxsoftware.com/krak-pa … sing-magma). Is there a way to make random velocity via magma (let’s say between .9 and 1.1 values) before the partitioning process, also?
Another aproach could be using the repopulation tool, and managing somehow to have random velocity per particle, right? Is this achievable with magma modifier?

Thanks!
prt_cloner_magma.jpg

Hi there,

Talking about randomization, this should be very simple, but how to randomize one value from magma flow?
The idea is to have density controlled by age (simple fade in by age) but then having the final result with some variation, so particles assume random values between .9 and 1 for example. This value should be obtained and kepted until the end per particle… I ask about keeping value, because we’ve managed to make random values to color but are always changing. Any tips?

Cheers!

Another question should be on how to convert 32 float point result (working with output color on the viewport) to 16 float point (not working on output density while rendering because it needs a 16 floating point value).

Helpppp :slight_smile:

The only way to produce consistent “random” values per particle is to use a Noise operator with the ID of the particle as the input. But since ID is an Integer, you have to convert it to a Float first, and then divide by a float to produce a fractional value since round values (1.0, 2.0, 3.0) will always produce the SAME noise value.

So

InputChannel ID -> ToFloat -> Divide (<-123.456) -> Noise (Normalize On) -> Add (1.0) -> Divide (2.0) 

should produce unique per-particle values between 0.0 and 1.0.
The Normalize option produces output between -1.0 and 1.0, so adding 1 and dividing by 2 should bring it to the 0 to 1 range.
If you want your values to be between 0.9 and 1.1, you can use instead

InputChannel ID -> ToFloat -> Divide (<-123.456) -> Noise (Normalize On) -> Multiply (0.1) -> Add (1.0) 

-1.0 to 1.0 times 0.1 will give you -0.1 to 0.1, and adding that to 1.0 will produce 0.9 to 1.1.

You can change the Divisor to any other value to control how often the values repeat.

Then we come to the partitioning part.
We can add an InputValue multiplied by a large Integer (e.g. 1000000) to the ID channel to shift the noise input by a million for each partition.
When the option to affect Modifiers of PRT Loaders is on, the Krakatoa partitioning code will look for Modifiers that contain a “seed” property.
Unfortunately, simply exposing a Magma InputValue called “seed” to the UI will not help, because internally the property is not called “seed” when exposed to the UI. But you can work around it like this:

*Create an AttributeHolder modifier below the Magma.
*Animation > Parameters Editor > Add a new Integer with name Seed and range 0 to 100.
*Now create a bi-directional Wire Controller from the new Seed parameter to the InputValue node’s track.

Now if you partition, the AttributeHolder’s Seed parameter will be incremented by 1, and the Magma will shift the IDs by a million for each partition, producing new randomization on each iteration!

Please let me know if you have any questions…

Hi Bobo,

Thanks again for your support. The “random” values worked perfectly. I’m still trying to understand this value (<-123.456), hehehehe!
Now we’ll try to make it work with velocities… since we are still learning how to use magma (each day we are feeling more and more confortable!) we think in lot of concepts that turn out to be wrong. One of them is that we want to change position of particles based on it’s velocity. Because if I change velocity values using magma they don’t assume different position. Only the vector representation and motion blur at render time, so i think.
But this is part of the learning process. Thanks for helping so much!

Cheers for now,

My test setup looked like this:

InputChannel:Position -> Add <- (InputChannel:Velocity -> Multiply <- Random value) -> Output:Position

So I was adding Velocity (divided by FPS 30 because our Velocity is per second, but you want per frame) times the random value to the Position input and outputting the offset Position as the new Position.

The 123.456 is meant to produce a non-round value. For example, when ID is 1, the input into the Noise will be 0.00810005184033177812337998963193
When ID is 100, the input will be 0.99630637636080870917573872472784 and so on. The problem is that input values 1,2,3,4,5 etc. all produce the SAME noise value, so if you would just use the ID as input of the Noise, you would get no randomization. If you would divide by 100.0, every 100 particles you would get the same random values. But using a value with decimal positions like 123.456 will produce the same value much less frequently. ID 0, ID 123456 and ID 236912 will produce the same random value (because the input in Noise will be 0, 1000 and 2000 respectively), but most other IDs will generate unique values…

Gotcha! Is there a way to expose values beside the input’s? This way I could avoid going in magma… Maybe i’m beeing too lazy, but this way I could easily make copy’s of prt loader and just change the divide (exposed value) in 3dsmax side menu :smiling_imp:

When you need a value to be exposed, you connect an InputValue node and check the “Expose” checkbox so it shows up in the command panel.
Some other controls (e.g. InputTexmap, InputObject, InputParticles and Curve) can also be exposed…

Jeez… so simple! :slight_smile: Using this formula and the other for particle jittering, i’m having a “stoke” result but with super accurate results.
So, if I expose the values that basically give us the random position based on velocity and the other that give’s us random position to have jittering effect and make an attribute holder below magma, add two integers with same name (can this happen?) Seed, and then a bi-directionl wire controller from that seed parameter to the input value node track, and then (arf arf) start partitioning process, i would have this random effect on all the partitions automatically?!?

O_o Cheers!

I would go with two AttributeHolders, each one with its own “Seed” parameter. Krakatoa can only modify one parameter by name if there are multiple in the same object, but it will process all modifiers it finds and affect each Seed in every modifier. Also don’t forget to make the AttributeHolder’s parameter the Master.

Another important thing:
Magma will NOT be able to handle undo/redo/copy/paste/save/load preset if there are nodes that have a Wire Controller connected to them. So if you intend to do the wiring, be sure it is the last thing you do. Otherwise if you try to perform an undo on the Magma flow for example, the wiring would be lost, and trying to redo could even cause it to corrupt the flow or throw a MAXScript error because it does not expect InputValue nodes to have controllers that are not Bezier type…

So it is kind of a hack, but it should do it.

Hi Bobo,

Two questions:

1 - We have floating numbers 0 to .3 to define radius jittering and integer values from 30 to 150 to define velocity randomization. So I assume integer number will have to be replaced by float (0 to .3) when defining the jittering attribute holder and the integer values limit should be set to 30 to 150 ( second attribute holder - velocity). But when I attempt to connect the floating (jittering), it becomes invalid. It should work, or this value has to be converted inside magma to integer value and then continue the process as you described? This, of corse, if this values we’re talking about are directly related to our llimits. Please advise :slight_smile:

2 - The attribute holder should be created at base level (magma in this case) or at current?

Thanks!

PS: In the viewport everything is working. If I change the value in the attribute holder, it reflects on the position and jitter… so i’ll give it a try (partitioning). I just didn’t like the red color while connecting attribute holder.

AttributeHolder is an empty MODIFIER found in the 3ds Max Modifiers list. You add it to the modifier stack! You don’t add a CustomAttribute to the base object or Magma, it has to be an independent Modifier on the stack below the Magma, because the Partition code checks each modifier on the stack for a Seed property.

I am not sure what the problem is with the wiring of the inputs. What was the error message when the node turned red?
All InputValue nodes use floating point controllers, the InputValue Integer node just has a flag that says “I am integer, I will round off the floating point value”.
If your flow uses Integer inputs for some values, you should expose them as Integer values in the Parameter Editor. If you use floats in the flow for other things, expose them as Floats in the Parameter Editor. I would expect that to work…

I was refering inside the Parameter Editor - Add to type… we can choose Selected Objects Base Level or Current modifier. If I choose current modifier it will add this inside the Attrib Holder modifier. If I choose Object’s base level, it will add this in the Magma modifier. Since I didn’t know where to put it, i’ve asked. Sorry for that.

Cheers

Current Modifier would be the right place to add it, so it becomes part of the AttributeHolder modifier. So to Krakatoa, it will appear as if there is a modifier of class AttributeHolder with a property named “Seed”.

This should be the only thing you wire to your Magma.

I might have misunderstood your other questions about the integer vs. float problem. Can you post a screenshot of the flow?
In general, you should never perform mathematical operations on integers (e.g. dividing one int by another). Always convert them ToFloat first. Same with mixing Floats and Integers - the Integers should be explicitly converted to Floats. Only use Integers where required, e.g. in the control socket of a Mux operator.

Maybe with this image I can clear my messy thoughts:

1 - Basically my magma flow is flattening sim into a mesh, then moving up 0,1 in z, then making random positioning (exposed value number 26) based on velocity channel and then making random positioning to get the jittering effect (with exposed value 50 to control the ammount of “jittering”)

2 - I thought that this attribute holders would control this values, and each time the partition started it would give random values with limit’s pre-defined in the attrib holder. On the first value (E26) it should go from 35 to 200 and on the second value (E50) it should go from 0 to .35.

Cheers,

PS: For anyone trying this aproach based in real flow sim - bin format, change index to ID to avoid “animated jittering per particle” (input channel 20 and 30)

The Seed Increment of Krakatoa adds 1 to the current Seed value (since all Seed parameters of various modified are generally Integers) for each partition.
In other words, the Seed is incremented by N-1, and then decremented back by the same value after partitioning to preserve the original Seed value.
So partition 1 does not increment at all, partition 2 increments by 1, partition 3 increments by 2 and so on.
You should only wire that integer value into the Magma, and then use it to define the randomness of the various values you use. Do this by ADDING the Seed value coming from the AttributeHolder to the ID or Index value you are using to generate the random value. See the example I posted earlier. In my example, I took the Seed value, multiplied it by a large number and added it to the Integer value before it gets converted to a float to drive the Noise.

I hope this helps.

Indeed it helps! Thanks again!
It worked perfectly!

Cheers,

Privacy | Site terms | Cookie preferences