diff --git a/projects/fire_works/shaders/trail.geom b/projects/fire_works/shaders/trail.geom
index 39ab595a98f78e9d85d3906a83a591667729cebc..3db1cd8c59e67ccf1ff7f23e487b4a71b130d425 100644
--- a/projects/fire_works/shaders/trail.geom
+++ b/projects/fire_works/shaders/trail.geom
@@ -43,11 +43,16 @@ void main() {
 
     const uint indexOffset = (gl_InvocationID * (INSTANCE_LEN - 1));
     const uint instanceIndex = startIndex + indexOffset;
-
-    uint count = INSTANCE_LEN;
+        
+    uint count = min(INSTANCE_LEN, useCount);
 
     if (indexOffset + INSTANCE_LEN > useCount) {
-        count = indexOffset - useCount;
+        if(indexOffset >= useCount){
+            count = indexOffset - useCount;
+        }else{
+            count = 0;
+            return;
+        }
     }
 
     if (count <= 1) {