I am implementing particle system in which I want particles to rotate around each other i.e. its own axis along with translational motion outwards from the emitter.
I have outward motion of particles working but I am not able to figure out how to add rotational motion along with it.
here are the equations I am using for motion:
My geometry shader:
vec3 dir= GetRandomDirectionFromTexture();
vec3 vel= normalize(dir);
out.position=input.position + (vel * DeltaTimeInSec);
out.velocity= input.velocity+ (Acceleration * DeltaTimeSec);
You need to define a local coordinate system for each particle, so that it makes sense to talk about local rotations. Presumably your particles are essentially just points, so that in and of itself is not enough to define a unique local coordinate system. You could perhaps use cross products of a particle’s position vector with a coordinate axis and/or the view vector to (artificially) define such a local coordinate system.
Can you please specify the equations?
I am using billboard technique to render particles. Here is my part of the geometry shader:
vec3 cameraV=normalize(EyePosition.xyz - pos );
vec3 up= vec3(0.0, 1.0, 0.0);
vec3 right= normalize(cross(up,cameraV))*0.01;
gl_Position=vec4(pos - (right + up),1.0);
gl_Position=vec4(pos + ( right- up),1.0);
gl_Position=vec4(pos- (right - up),1.0);
gl_Position=vec4(pos + ( right+ up),1.0);
This looks like you have a local coordinate system (right, up, cameraV) - if you want to rotate the billboard, apply a rotation matrix to these base vectors - sorry don’t have any canned code for that.