KRAKATOA - per point random value


#1

Hi.

So I have a problem figuring out how the random-per-point works in krakatoa. I finally found there is a channel called RandomValue in the input channel. But it errors out:

Magma Channel “RandomValue” Not Available in this PRT Object:

So it looks like that this input is looking for an ACTUAL channel called RandomValue.

So what now create new channel, recache and finally get random-per-point value. Come on, this just sounds silly.

Anyone? I noticed that Krakatoa is kind of dead :slight_smile:


#2

Dead? You mean like this?
http://www.thinkboxsoftware.com/krakatoa-mx-2x-change-log/2016/5/2/krakatoa-mx-250-change-log.html

Back to your question: The channels shown in the Magma editor are not all channels that exist in a particle source. They are some typical channels that COULD exist in some objects. Each object has a dynamic list of channels it might have, for example a PRT Loader will have whatever channels were saved in the source file sequences; the PRT Volume might have one or more mapping channels depending on what mapping coordinates exist in the source mesh, plus a SignedDistance value, the nearest point’s surface Normal; the PRT FumeFX will have channels based on what was exposed in the FumeFX sim; the PRT Hair will have SplineID, Distance, HairLength and HairRoot channels no other object provides that describe the particle’s position within a hair setup or set of splines, and so on.

The RandomValue is a special channel generated only the the PRT Maker object. It is generated internally by the object based on the transformations a particle would go to produce a fractal distribution, but is available even when the Fractal option is not used. Here is an example that employs the RandomValue to do something productive (it was written before there was a PRT Surface object to do the same): http://www.thinkboxsoftware.com/kra-prt-maker-surf-placement

So how do you get a Random value in a Magma? Well, you don’t really want a random value in Magma, since a fully random value would be bad for producing consistent results on multiple machines on the same frame. So for that reason, a “pseudo-random” value would be needed. And the reason we have not added a dedicated PseudoRandom operator to Magma is that you can use a Noise value with any input channel as the “seed” to produce more or less the same result.

For example, you can base the “random” value on the ID channel of the particle (assuming it exists - some objects like PRT Volume will not have an ID channel because there is no ID to track over time, each frame is independent from the rest). But if you are working on data coming from a PFlow, TP, Naiad, Bifrost or RealFlow simulation that has an ID, you could take the ID, convert to Float, divide by another floating point value like 0.123, and feed that into a Noise function. You might want to disable the Normalize option. The output of the Noise function loops through the same pattern every full integer value, so the output from inputs 1.0, 2.0, 3.0 etc. would be the same. But since we divided the ID by a non-round floating point value, no obvious wrap-around will occur. Using a very small divisor ensures a very high-frequency noise that is more or less a random pattern. Using a larger divisor will scale the noise pattern larger and thus produce similar values for particles with IDs that are close together, so we don’t want that.

If you don’t have an ID channel, you can use the Index channel to base the variation on. Or you can use the Position (which will result in the same random value in the same point in space, so it won’t be localized to the particle).

Also note that the results of the Noise operator is in a range from a negative minimum to a positive maximum. So if you want only positive “random” values, you will need to take the Absolute value of the Noise’s output.

Here is a screenshot from an example where I turned the vertices of a 50x50 segments Plane primitive to PRT Source in the newest Krakatoa MX 2.5.0, and then set the Radius channel based on the ID channel according to the above explanation. I then created a Frost mesh from the points and set it to use the “random” Radius channel.

I have also created a screenshot of the result of using the Frost Random Radius By ID variation option. In the Magma version, I also introduced a Power operator to add a Bias to the values, as the Magma version tends to produce smaller values with few large ones, but a bias of about 0.3 shifts this towards the look of the built in random variation of Frost. In fact, I would say the Magma version looks more random than the random feature of Frost itself :wink:


Random Radius By ID In Frost

Finally, you can select all the nodes that defined that “random” value except for the InputChannel, create a BLOP compound, save it to disk, and reuse it as a custom operator whenever you need a random value generated…


#3

I just wanted to mention that Krakatoa MX 2.6 (currently in Beta) adds not one, but seven dedicated Random operators to Magma (they will also be available in Stoke/Genome a bit later).

They include

UniformRandom (float32[1])
VecUniformRandom (float32[3])
UniformOnSphere (float32[3])
GaussianRandom (float32[1])
ExponentialRandom (float32[1])
TriangleRandom (float32[1])
WeibullRandom (float32[1])

All of them accept a Seed input which can be set to the ID of the particle (or any other channel if desired) to produce a consistent value over time.


#4

Good afternoon friends, I calculate with Dyverso in RealFlow, imported in 3D max but not working with Krakatoa. Has anyone had this problem?