ive got a billboard looking at a camera. the problem im having is as a pivot the camera around (ie look left and right) the billboard appears to stretch a little as it reaches the edge of the camera view. is this normal?
ive ensured all parent/child scaling is correct. actually i dont even have to move to see the effect just pivot the camera.
is this a known 3D effect that has to be corrected thru script at runtime or a known 3D effect that noobs run into because they dont set something up correctly?
There are two ways of doing a billboard, and neither is 100% correct, so you have to choose whichever is least wrong for your circumstance:
point the billboard directly at the camera location. This looks right for things which are supposed to be ‘spherical’, but it’s bad if you get too close to them because they can pivot a lot as you pass them.
align the billboard along the camera’s forward vector. This is how Unity’s particle effects work, and it’s probably the most common solution because it’s a lot cheaper to calculate when there are many particles. It looks right in the majority of cases, but the billboards will seem more distorted and will drift a bit relative to non-billboard objects as they get close to the edge of the view.
The first calculates the billboard’s forward vector like this:
var forward = (Camera.main.transform.position - billboard.position).normalized;
The second is as simple as this:
var forward = -Camera.main.transform.forward;
The latter is cheaper not just because it’s simpler, but because it’s the same for all billboards so you only have to calculate it once per frame.
In either case, you could then pass the vector to Quaternion.LookRotation, using the camera’s up vector as the second parameter, then use the resulting quaternion to orient the billboard.
Just a clarification here: Depending on how you define distortion, you could also say that it is approach 1 that distorts objects.
The thing is, perspective distorts everything. If you have a real sphere (not a billboard) it will be more oval towards the edges of the screen - that’s just how perspective works. This is sometimes referred to as perspective distortion.
Approach 1 will distort the billboards in a way that is similar to the perspective distortion of real 3d objects. So a billboard with a circle texture will be more oval towards the edges of the screen, just like a real 3d sphere would.
Approach 2 will make the billboard images always appear the same no matter where on the screen they are. So a billboard with a circle texture will remain a circle no matter if it’s in the center or towards the edges.
If you want the billboards to simulate real 3d objects, you’re best off using method 1. If you want the images to always look the same regardless of screen position, you’re best off using method 2.