Rotating Billboard Sprite 3D

A minimal rotating/spinning billboard sprite 3D shader. Its actually applied on a Meshinstance.

Usage: Add a meshinstance>Add a quadmesh>Assign a shader material>Assign this shader.

Shader code
shader_type spatial;
render_mode unshaded,cull_front;

uniform sampler2D tex;

uniform vec4 albedo_color :hint_color = vec4(1.0);
uniform float scale = 1.0;
uniform float rotation_speed = 1.0;

void vertex(){
	float time = TIME*rotation_speed;
	float sine = sin(time)*scale;
	float cosine = cos(time)*scale;
	MODELVIEW_MATRIX = INV_CAMERA_MATRIX * mat4(CAMERA_MATRIX[0],CAMERA_MATRIX[1],CAMERA_MATRIX[2],WORLD_MATRIX[3]);
	MODELVIEW_MATRIX[0][0] *= sine;
	MODELVIEW_MATRIX[0][1] += cosine;
	MODELVIEW_MATRIX[1][0] += cosine;
	MODELVIEW_MATRIX[1][1] *= -sine;

}

void fragment(){
	vec4 tex_samp = texture(tex,UV);
	ALBEDO = tex_samp.rgb*albedo_color.rgb;
	ALPHA = tex_samp.a*albedo_color.a;
}
Tags
3d, billboard, facing, rotating, spinning, sprite
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

Local Space Y-Billboard Shader

Billboard Sprite3D Sway (Godot 4.0)

Spatial View-Depending Directional Billboard

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments