Hi all -
I’m trying to figure out how to drive the emission of particles from a surface, based on the local value of a texture map on that geo. For example, if I had a specific set of black and white values on a textured sphere, I’d want lots of particles coming from the sphere where the material is white, and none where the material is black.
I’ve seen lots of tutorials that allow you to do clever things with particle data (eg through instancing) ONCE the particles are created, but here I’d like to have TOPs drive the initial creation (birth rate) of the particles.
Any relevant tutorials out there for this?
thanks!
Hello,
SOP particles are produced by vertex, using the normal vector as emiting speed.
Using point SOP, you can transfer the UV values to the N values but you cannot use the texture pixel values (affected to the image through the fragment shader, long after the particle production and affecting the pixel space between the vertex after the camera view…) to change the production of particles.
One possible way would be to use GPU particles, so you can map some texture colors to affect the initial speed of particles, but that’s another story and use GLSL shader…
Here is a simple example of dynamic GPU particle system:
– first texture is for initial position, with feedback Top to change in time. Alpha is for initial age of particle
– second is for speed, Alpha is for life of particle
– third is for acceleration.
I use a compute shader with minimal GLSL to move the particles:
layout (local_size_x = 8, local_size_y = 8) in;
void main()
{
ivec2 xy = ivec2(gl_GlobalInvocationID.xy);
vec4 initPos = texelFetch(sTD2DInputs[0], xy, 0);
vec4 pos = texelFetch(sTD2DInputs[1], xy, 0);
vec4 initSpeed = texelFetch(sTD2DInputs[2], xy, 0);
vec4 speed = texelFetch(sTD2DInputs[3], xy, 0);
vec4 accel = texelFetch(sTD2DInputs[4], xy, 0)/100;
pos.xyz += speed.xyz;
pos.a += 1;
speed.xyz += accel.xyz;
if (pos.a > initSpeed.a){
pos = initPos;
speed = initSpeed;
}
imageStore(mTDComputeOutputs[0], xy, TDOutputSwizzle(pos));
imageStore(mTDComputeOutputs[1], xy, TDOutputSwizzle(speed));
}
GPUparticlesWithAge.toe (12.6 KB)
Hope that helps,
Jacques
Merci for the reply, Jacques. Makes sense, and your toe file is very helpful.
I just hope that Derivative makes doing things like this a little more straightforward in the future… the fact that sop particles are only emitted from verts, and use the vert normal as initVel is really clunky. Either way, thank you!