Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Suggestion / Idea  Multiple user data and more flexible diffuse
#2
(18-11-2021, 06:02 AM)Chua Polar Wrote: Currently, there is only one Vecotr4List userdata provided and all the terms of each vecotr4 will be manipulated by the diffuse. 
However, I want to use the userdata for different usages, like temperature and fluid number(like fluid1: water, fluid2: lava, fluid3: wine......) at the same time.
It will be great if you can either make diffuse a vector4 or make the userdata a List of vector4list with multiple diffuse. Really thanks! Sonrojado

User data is intended to be used to store values that can vary wildly per-particle and change as a result of particle interaction, such as temperature, viscosity, color, etc.

Using it to store a "type" does not make sense, as many particles will share the exact same type (many "wine" particles, "lava", "water", etc) and there can be no intermediate values. Unity already contains a functionality for this: tags.

You can tag each emitter with the type of fluid it's emitting, then at runtime retrieve the type of a particle like this:
Code:
var type = solver.particleInActor[particleIndex].actor.tag;

This way the "type" is stored once for all particles of the same type, instead of storing it for every single one.

FYI, the reason why there's only 4 user data channels is because 4 is the length of the SIMD registers used to perform vector operations. This means operating with pairs of user data with 4 components is very efficient. In addition to this we know the data for particle n is at n*4 in the data arrays, making memory access efficient too. Using a variable size for the amount of user data channels would make both accessing the data and operating with it considerably less efficient.

Note that if you really want extra per-particle storage, nothing prevents you from declaring an array of the same size as the emitter's capacity and store your own data there. It can be as simple as floating point values, or as complex as per-particle structs/classes.
Reply


Messages In This Thread
RE: Multiple user data and more flexible diffuse - by josemendez - 18-11-2021, 09:44 AM