shader_type spatial; //render_mode unshaded; uniform sampler2D billboards[255]; uniform int numframes[255]; uniform float sizes[255]; //COLOR/INSTANCE_CUSTOM is our custom data, used as follows: // x=image index // y=frame in image index // z=visible (0 = invisible, 1 = visible) void vertex() { COLOR = INSTANCE_CUSTOM; //send instance_custom info to fragment float size = sizes[int(COLOR.x)]; vec3 cam_right_worldspace = vec3(VIEW_MATRIX[0][0],VIEW_MATRIX[1][0],VIEW_MATRIX[2][0]); vec3 cam_up_worldspace = vec3(VIEW_MATRIX[0][1],VIEW_MATRIX[1][1],VIEW_MATRIX[2][1]); vec3 vert_pos_world = cam_right_worldspace * VERTEX.x * size + cam_up_worldspace * VERTEX.y * size; VERTEX = vert_pos_world; } void fragment() { int image_index = int(COLOR.x); float frame_index = COLOR.y; float uv_x_space = 1.0/float(numframes[image_index]); vec2 uv_out = vec2(uv_x_space * (frame_index + UV.x),UV.y); ALBEDO.rgb = texture( billboards[image_index] ,uv_out).rgb; ALPHA = texture(billboards[image_index] ,uv_out).a * COLOR.z; }