Updated TyFlow support - TyCache, Custom properties

Forums: Updated TyFlow support - TyCache, Custom properties
3D Studio Max Plugin (Export Script Plugins developed by [gk] and KilaD; Integrated Plugin developed by Karba)
Forum rules
Please post only in English in this subforum. For alternate language discussion please go here viewforum.php?f=18

Updated TyFlow support - TyCache, Custom properties

Postby neonZorglub » Wed Mar 06, 2024 12:47 am

neonZorglub Wed Mar 06, 2024 12:47 am
Updated TyFlow support - TyCache, Custom properties
(from 2023.1.2 - 14.10, 2024.1 Alpha3 - 15.04)


Direct support of tyCache.

-Particles exported by a TyFlow objects, and loaded in a tyCache objects can now be converted to Octane instances.
(in previous versions, a tyMesher object was needed to display the particles, so this method was limited to the creation of a single mesh)

To use instances, the Elements / Particle interface / 'Enable particle interface' need to be enabled.

-Note that when using the PRT file format, the particle meshes need to be set in the Mesh override panel of the tyCache object.

The samples xxxx.max shows the usage of a tyFlow object and the resulting tyCache object.
-Create or check the existence of a 'temp' folder on your C drive (or modify the input / output of the tyCache / tyFlow objects)
-Load the xxxx.max
-Select tyFlow001, select tyFlow in the Modify panel, and click on the Open Editor button
-In the tyFlow editor, Event_001, select the 'Export Particle (PTR)' operator, and press the 'Generate PRT files' button.

Samples

--- instances_age_gradient01.max
instances_age_gradient01.png

Basic simulation with particles, Octane geometry modifier set Particle UID to 'Age'.
Gradient Texture, using Instance range with Maximum ID set to 101 (number of frame, that will be the highest age of the oldest particle)
You can change the Octane geometry modifier Particle UID to 'Birth Unique ID', and set the Maximum ID to 200 (the number of particles at the last frame) to observe the result.

--- instances_age_gradient11_tyCache.max
instances_age_gradient11_tyCache.png

Illustrates the usage of the TyCache.
An Export Particle operator has been added to the TyFlow Event_001.
For this sample, the Global Settings / Coordinates is set to Local, so we will be able to move the tyCache, to see both the original tyFlow object, and the resulting tyCache.
After opening this sample for the first time, select this Export operator, and press the 'Generate PRT files' button.

In tyCache / Render, the Rendering is set to Instances.

Note that the original tyFlow uses a build-in shape (torus).
For the tyCache, we need to set the geometry to a similar torus created in the scene (Torus001), with the Mesh overrides panel.

For real usage scenes, you would not move the tyCache object, and hide or delete the tyFlow object.

--- random_from_instance_tyCache.max ---
random_from_instance_tyCache.png

Same tyFlow / tyCache object, but with random color for each particle.
Using a Gradient Texture, and a Random color texture as Input.
The Particle UID of the Octane geometry modifier is not used, and can be set to None.

Note that multiple objects using the same material will result in different colors for each objects.
(the tyFlow and tyCache colors don't match)

--- random_from_instance_tyCache2.max ---
random_from_instance_tyCache2.png

Same as previousely, but we use the Particle UID to create random colors.
The Particle UID of the Octane geometry modifier is set to Birth unique ID.
The Gradient texture uses an simple OSL texture (InstanceIDAsRandom01.osl) that reads the particle ID (instance ID), and uses a noise function to create a random grey value based of this ID.
This way, both the tyFLow and the tyCache object will have the same random colors.

------------------------------------------------------------------------------------
Particle properties, TyFlow custom properties

Rendering particles as instances sharing the same mesh is much more efficient than using a single big mesh for all the particles.
However, the material setting is usually different for those 2 methods, and may need special care to achieve the desired effect.

Octane instances (scatter node) use some common settings (mesh, material, layer, ..), and very few data per particle : a matrix (position, scale, rotation), and an integer (user ID).

There are several single particle data generated by tyFlow that can be used by Octane particle textures.
The 2 first basic data are Age and Birth ID (as seen in previous samples).

TyFlow can also create custom data per particle, with the use of the Custom Properties operator.
The 3 types of properties created by tyFlow (float, vector, transform matrix) can be read by Octane to set the integer used by Octane (instance UID).
The Octane Instance ID is the only user defined parameter that can be set per particle.
This can seems limited, but as it's a 32 bits integer value that can be read by an OSL texture, many effects can be created..

Note that the main vectors per particle (vector, velocity) are already used by Octane when creating the particle instances (Scatter node).

To select a custom property as source of the Octane Particle ID, set the Particle UID to Custom Float / Custom Vector / Custom TM.
For Float, the Element index specify witch Custom float we want to read. The Component Index is not used.
For Vector, the Element index specify witch Custom vector we want to read. The valid Component Index values are 0,1,2, for x, y, z.
For TM, the valid Component Index values are from 0 to 11, corresponding to the 12 floats of the 4x3 matrix.
The resulting single float value is then multiplied by 'value Multiplier', and 'value Offset' is then added to the result, to be set as the Particle UID (Octane instance ID)


--- customFloat_randomScale_tyCache.max ---
customFloat_randomScale_tyCache.png

In this sample, we read the random scale of the particle to set the particle color from a Gradient texture.

The Event_001 also has a Export Particle (PTR) operator. As for all those samples, use it to create the cache files, for the tyCache object.

In Event_001, an operator Custom Properties do a SET operation, and the Float Data is reading the 'Scale magnitude' with a multiplier of 10.0, and store it as 'myMagnitude' (a user defined property name)
The Scale (Absolute) operator is set to 500 %, with a random variation of 100 %
In Octane geometry modifier, Particle UID is set to Custom Float, and the Element Index is set to 1.
Note the custom property information line, "Custom float: myMagnitude" , that confirm that we selected the correct custom float.
The value Multiplier is set to 1.0, and the value offset to -25
Those have been determined by trial and error, based on the idea that the original data value (size / scale of the particle) should be between 0 to 50.0 (5.0 from the 500%, and x 10 from the multiplier).
(we can check the original scale in the tyCache object, with the Current File info / Open tyParticleViewer dialog, and that's in the range 0 to 5.0)

We will re-use our shader InstanceIDAsColor.osl, that basically scales the Instance ID to a value between 0.0 and 1.0 by dividing by the maximum value (parameter 'instanceCount').
So in our case, we will set instanceCount to 50.

The actual smallest particle scale is not 0, to we can adjust Value offset to have a better fit from the smallest / biggest particle to the gradient colors (red for smallest to blue for biggest)

tyCache_octane_samples.zip
(3.79 MiB) Downloaded 19 times
neonZorglub
OctaneRender Team
OctaneRender Team
 
Posts: 899
Joined: Sun Jul 31, 2016 10:08 pm

Return to Autodesk 3Ds Max


Who is online

Users browsing this forum: No registered users and 18 guests

Sat Apr 27, 2024 7:43 pm [ UTC ]