1
\$\begingroup\$

I am currently working on some FX trail effect. Here's the situation, you have a fast moving object that puts trail on another object.

Here's how it works for the moment. I have some kind of stamp texture (the object) that is printed onto another texture of the receiver object. When the object is moving not to fast, you can see the trail effect. But the problem appears when the object is moving to fast, then you don't see the trail but only the stamp texture printed at some points.

The issue is quite logical and linked to the time when the update function is called (I am using Unity). The function is not called enough so it's missing some positions and thus the trail effect

\$\endgroup\$
  • \$\begingroup\$ Would a TrailRenderer be suitable for your purposes? Can you include a sample image so we know what kind of trail you have in mind? \$\endgroup\$ – DMGregory Dec 18 '17 at 1:04
1
\$\begingroup\$

You could find the distance traveled per frame and then draw the stamp texture in all the positions along the line segment calculated. For example:

vec2 prevPoint; // contains the previous position of the moving object
vec2 currentPoint; // contains the current position of the moving object
vec2 direction = currentPoint - prevPoint;
double distance = direction.legnth();
direction.normalize();
const double spacing = <distance between stamps you want>;
for (double distTraveled = 0.0; distTraveled < distance; distTraveled += spacing)
{
    vec2 stampPos = prevPoint + direction * distTraveled;
    placeStamp(stampPos);
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.