AWS Thinkbox Discussion Forums

Multiple custom geometry question (continue inside)

The question is a bit long.

I’m using frost to mesh some particles, now i have three different custom geometries that i want to use, i would like to use every custom geometry with the particles based on the particle radius, so if the radius is 1cm it will pick CG1(Custom Geometry 1), if the radius is 0,5cm it will use CG2 and if the radius is 0,2cm it will use CG3.

Can that be done with magma or in some way?

Cheers.

Absolutely.

Switch the Frost custom geometry option from “Cycle Shapes” to “Use ShapeIndex Channel”.

Add a Magma to your PRT Loader and set a flow to output to ShapeIndex channel (set the “Channel List Sorting” option to “Frost Channels Only” and you will see it easily on the list).

Now do your math, for example you can use Switch operators with logical comparisons of the Radius input channel to send out 1,2,3…, or just take the Radius, scale by some factor and convert to Integer to produce values like 1,2,3 etc. The ShapeIndex picks the corresponding Geometry object from the list, so if you have a Box, a Sphere and a Torus, a value of 1 will produce Box, 2 will pick the Sphere and 3 will be the Torus…

Also note that the >> button has various options to reorder the objects on the list to match your ShapeIndex channel values.

See the middle section of this tutorial for some examples.

Thanks.

Another question, can i assign random radius to the particles from the magma editor? (i don’t fully understand the magma editor just yet).

Cheers.

Yes, you can assign a pseuso-random Radius. Magma does not provide a Random function per se, but you can use a Noise function with some constant particle channel (like the ID channel converted to Float and multiplied by a value less than 1.0) as the input to get a Float value out that could be used as Radius. This way, a particle with a specific ID will always produce the same “random” Radius. Note that the output of Noise can be normalized, but between -1.0 and 1.0, so you might also need an Abs operator to remove the sign, and then multiply by the Max. radius. Output the result of the calculation to the Radius channel and enable the option to use the Radius channel in Frost.

EDIT2: I’ve found the answer to the first question, using a switch operator :slight_smile:

Thank for the scheme Bobo!

Without it i couldn’t make it work :slight_smile:

Another question about magma, is there some kind of “if” compare node?

i’ve found the “less” or the “less or equal” node, but i’m not sure what it does, what i want to do is limit the radius, so if it is smaller than 1cm it will return 1 cm, this way i can define the size limits.

Thanks again!!!

Cheers.

EDIT: and another question i forgot, is there a way to see a sample value of the calcs, i mean, this calcs are made for every particle, but is there a way to see the numeric results, at least for one sample particle?

You take two values, e.g. the Radius value and a 1.0 Float InputValue and pass into the Less operator. The output of this operator will be a “boolean” which is technically 0 if False and 1 if True. You feed that into a Switch’s 3rd socket and then pass the value to output when True into the first socket of the Switch, and the value to output when False into the second socket. You can chain multiple Logical operators and Switches to perform multiple tests.

From the “Debug” menu, select the “Debug Mode” option - a Debugger window will open underneath the MagmaFlow Editor. It will show the first N values (you can change the Count, or press the “Next >>>” button to show the next 100 and so on). Each column shows one node. If you select a line (e.g. I have selected particle 6 with ID 5), the values of that row will be shown at the sockets of the nodes in the Editor. Note that this has improved in the latest versions, earlier builds of Krakatoa might not have all these options.
[attachment=0]Frost_Magma_Radius_ShapeIndex_Example_Debug_v002.png[/attachment]

A note about my 9:Multiply node after the ID>ToFloat - when the Noise operator gets a round input value, e.g. 1,2,3,4,42,100 etc., it always produces the SAME value - it is cyclic. You have to input a value between 0.0 and 1.0, or between 1.0 and 2.0 etc. to produce variable values. So inputting the ID>ToFloat>Noise would NOT produce variable shapes/radii because round inputs always generate the same Noise output. Multiplying by 0.123 or anything else that causes decimal places in the Noise’s input solves this problem.

Privacy | Site terms | Cookie preferences