Moving Arrow on Tiles/Cells for Voxel Engines/Games

Can be used to show a direction for one tile or cell, can be chained

 

Can be also used for acceleration in racing games

Shader code
shader_type spatial;
render_mode shadows_disabled;

uniform vec4 arrow_color : source_color = vec4(0.0,1.0,0.0,1.0);
uniform vec4 background_color : source_color = vec4(0.0);
uniform float arrow_angle : hint_range(0.1, 1.0) = 0.2;
uniform float frequency : hint_range(2.0, 16.0, 2.0) = 8.0;
uniform float speed : hint_range(0.1, 2.0) = 0.5;

void fragment() {
	float offset = TIME * speed;
	
	offset -= abs(UV.y - 0.5) * arrow_angle;
	
	if (int((UV.x + offset) * frequency) % 2 == 0) {
		ALBEDO = arrow_color.rgb;
		ALPHA = arrow_color.a;
	} else {
		ALBEDO = background_color.rgb;
		ALPHA = background_color.a;
	}
}
Live Preview
Tags
arrow, guide
The shader code and all code snippets in this post are under MIT license and can be used freely. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

guest

1 Comment
Oldest
Newest Most Voted
punchinelli
punchinelli
22 hours ago

This is fabulous – thank you! I am using it as a direction indicator when placing building block items in my game – works far better than an arrow!