Pixel Perfect Billboard Sprites 2

I spent some time researching the issue of billboard sprites. I personally believe that the correct course of action is not to just perform a Transform.LookAt, but to actually align all billboard sprites to point the same direction that the camera is pointing. If you simply have each sprite look at the camera, multiple billboards across your screen will create a curve around your camera and they jut into each other if they overlap; This is because each billboard sprite would exist in 3D space at slightly different angles. Worse still, objects on the edge of the screen get warped like a funhouse mirror. Therefor aligning seems to be the way to go.

Here is an example I created in Unity that demonstrates this issue:

Billboard Sprite Align Technique Vs LookAt Technique

Billboard Sprite Align Technique Vs LookAt Technique

The Code

Here is the key line of code:

MyTransform.forward = MyCameraTransform.forward;

Here is an entire Unity class file for you to play with:

// BillboardSprite.cs
using UnityEngine;
using System.Collections;

public class BillboardSprite: MonoBehaviour {

	public Transform MyCameraTransform;
	private Transform MyTransform;
	public bool alignNotLook = true;

	// Use this for initialization
	void Start () {
		MyTransform = this.transform;
		MyCameraTransform = Camera.main.transform;
	}
	
	// Update is called once per frame
	void LateUpdate () {
		if (alignNotLook)
			MyTransform.forward = MyCameraTransform.forward;
		else
			MyTransform.LookAt (MyCameraTransform, Vector3.up);
	}
}

Bonus

Now that you are aligning objects with the camera, depending on your game, you might not need to keep rotating the sprites every frame unless the camera rotates. This might be particularly true for an orthographic camera. So for further optimization, you could (in theory) set up a C# event system to achieve tighter results.

My laptop was struck by lightning! LOL

I wish I were kidding folks, but my laptop was struck down by lightning. I lost about $4,000 worth of electronics in the blink of an eye. So please if I may suggest one thing to you: Backup is important.  The backup service that I personally use is Backblaze. They offer unlimited backup (including external hard drives) for $5/month or less. Please do me a favor and check out their free trialLet's thwart the mighty Zeus together! 

Click here to price compare. Or click here to download the Backblaze install file immediately.  A big thank you to the folks at Backblaze and thank you dear reader for supporting websites such as this one.

2 thoughts on “Pixel Perfect Billboard Sprites

  1. Pingback: Billboard experiments – Reeltrash

  2. Reply Laszlo Aug 3,2017 12:19 pm


    Thank you for your input in this Justin! I’ll be testing this out shortly.

Leave a Reply

  

  

  

This site uses Akismet to reduce spam. Learn how your comment data is processed.

My ads are tame because I respect you. Please disable your adblocker or whitelist this site!