# Tunnel Speed Lines

This is a 3D Particles Shader updated for Godot 4, to draw Tunnel Speed Lines.

Tunnel dimensions are set by **Tunnel Radius** and **Tunnel Length**.

Velocity is set by **Lifetime ( = Preprocess )**.

Draw Pass 1 draws **Quad-stripes** with editable **size x=3.0, y=0.4**.

Draw Pass 1 Material has a Shader Param **Texture Albedo**, to use your own **texture with alpha channel**.

##### Shader code

```
// particles shader for Godot 4
shader_type particles;
uniform float tube_radius : hint_range( 0.0, 10.0 ) = 3.0;
uniform float tube_length : hint_range( 0.0, 100.0 ) = 50.0;
float rand_from_seed(inout uint seed) {
int k;
int s = int(seed);
if (s == 0)
s = 305420679;
k = s / 127773;
s = 16807 * (s - k * 127773) - 2836 * k;
if (s < 0)
s += 2147483647;
seed = uint(s);
return float(seed % uint(65536)) / 65535.0;
}
uint hash(uint x) {
x = ((x >> uint(16)) ^ x) * uint(73244475);
x = ((x >> uint(16)) ^ x) * uint(73244475);
x = (x >> uint(16)) ^ x;
return x;
}
void start() {
if (RESTART_VELOCITY) {
VELOCITY = (EMISSION_TRANSFORM * vec4( -tube_length / LIFETIME * 1.0, 0.0, 0.0, 0.0)).xyz;
}
if (RESTART_POSITION) {
uint alt_seed1 = hash(NUMBER + uint(1) + RANDOM_SEED);
// set particle position by tube_radius and tube_length
float a = rand_from_seed( alt_seed1 ) * TAU;
TRANSFORM = mat4(
vec4( 1.0,0.0,0.0,0.0 ),
vec4( 0.0,sin(a),-cos(a),0.0 ),
vec4( 0.0,-cos(a),sin(a),0.0 ),
vec4( tube_length, sin( a + PI ) * tube_radius, cos( a + PI ) * tube_radius, 1.0 )
);
TRANSFORM = EMISSION_TRANSFORM * TRANSFORM;
}
}
```

This coulde be used in a sprite node or how?

Particles shader are 3D. You could draw this to a 2D viewport, explained here: https://docs.godotengine.org/en/stable/tutorials/rendering/viewports.html

I have created today an update for Godot 4

Hi. Did you still have the 3.x version?

No 3.x version?

Doesn’t work in 4.1 version