For a propagating fire effect I’m using a visual effect which spawns in positions provided by a 1-D texture, sequentially based on the particleId over the texture index:
I plan to have fires going out, so I’d like to disable some texture index positions and later re-enable them somewhere else (reusing that index in the texture).
I don’t know how to disable certain spawn locations.
Since the particles are spawned in each position given by the texture as follows:
uint width, height;
attributeMap.t.GetDimensions(width, height);
uint count = width * height;
uint id = particleId % count;
uint y = id / width;
uint x = id - y * width;
float3 value = (float3)attributeMap.t.Load(int3(x, y, 0));
value = (value + valueBias) * valueScale;
position = value;
So my assumption was that I could use the following for disabling particles for a certain texture index (position):
(particleId % count) as index for the X coord when sampling a second texture containing just 0 or 1 in the red component, then using that – just for testing – for the alpha cutoff, which does not show the particles if 1, but does if 0.
This does not work - all particles are still shown, as far as I can see (at least none of the fire columns are removed).
The textures look as follows:
So the EnabledMap is just a stripey 0/1 map, and the PositionMap is the positions on a 10x10 grid.
What’s the best way of disabling visual effects parts where the visual effect is distributed over a set of positions given by a texture?
(A dirty idea is to just move them far out of sight via position map, but I’d rather do a clean solution!)
Looks like you figured it out on your own in no time!
Just FYI, we added also a Get Texture2D Dimensions operator, so if your PositionCount == the texture width, you might not need to separately change that value but derive it from here:
Oooh, thank you – I was looking for that, but could not find it. I guess that’s a version 10+ feature? (I’m still on Version 9.0.0-preview.54, as I’m still on 2020.1)
@florianhanke how do you create a 1D texture? 2D render texture with ySize=1? And why the 0.5 in V?
I’m currently unpacking particle id as uv and the op takes 4 modulos and 2 divs, that’s a bit much.
I was thinking about combining occupancy and gameplay map together like you but since this is only one vfx graph asset containing many graphs I’m sure the value from the texture sampling is cached for all graphs.
What do you use this for by the way? I’m trying to replicate the good old shuriken effect I had with Emit() on c# with a gpu only thing, so far it’s a big fail as I am unable to get a value from a texture map with particle index. I might stick to shuriken, or maybe there is a way to emit particles from c#, maybe with vfx events.
I’m not sure I understand what you are saying. I do it to halve the amount of data that is pushed to and stored in the graphics memory.
I have never worked with Shuriken, so I don’t know what the effect is you mention, I’m afraid. I’m using it to simulate a spreading fire. Here it is when in almost full swing:
To add/remove fire emitters end I have a system that maps fire entities to texture indices and increases/reduces texture sizes when it must/can. Whenever a fire is added/removed, I apply the texture. I just use a single instance of the VFX effect for now.
Gorgeous effect.
Do you know how the value bias in set alive from map works?
I tried that to tell the map block to read only the alpha channel and it’s not doing a thing
It’s either alive = map value * scale + bias or alive = (map value + bias) * scale (can’t check my laptop right now to confirm). Either way, input the vector into the value scale instead of the bias.
ah yeah that makes sense, I connect 0,0,0,1 to scale and that doesn’t work either
i use random constant because i don’t want to spawn a particle at each point of the map, they’re lava bubbles which i spawn when the position is valid (alpha =1) and the blissmap is = 0 @VladVNeykov , any google doc with more documentation on these types of blocks and use case?