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;
}