Author Topic: Camera shaking with X-Frame enabled  (Read 53 times)

Paul_S

  • Newbie
  • *
  • Posts: 7
    • View Profile
Camera shaking with X-Frame enabled
« on: June 05, 2021, 05:39:18 PM »
Hello,
i have no idea why my camera is shaking when X-Frame is enabled. I tried all different settings and options, still shaking. Besides that, X-Frame is really nice and works fine. I want to use it with quad downsampling and i noticed that it stops shaking when no rotation forces are applied to the camera.
With X-Frame disabled i have smooth Camera Movement. Any idea whats wrong with my setting?
Thank you in advance.

Have a nice day

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7103
    • View Profile
Re: Camera shaking with X-Frame enabled
« Reply #1 on: June 05, 2021, 05:51:48 PM »
Hi,
What do you mean by “rotating forces”?

Paul_S

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Camera shaking with X-Frame enabled
« Reply #2 on: June 05, 2021, 06:19:16 PM »
Camera rotation from an orbit cam script. In my case:
transform.rotation  =  Quaternion.Slerp(transform.rotation, Merged_Rotation, 0.1f*(cam_lerp));
When i freeze the movement the camera isn't shaking anymore.
But when im moving with my fixed first person camera, its shaking again.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7103
    • View Profile
Re: Camera shaking with X-Frame enabled
« Reply #3 on: June 05, 2021, 07:44:25 PM »
Could you please try the following change?
Edit XFrameManager.cs and add this line:
Code
    [DefaultExecutionOrder(100)]
just before the class declaration so it should look like this:

Code
    [ExecuteInEditMode]
    [RequireComponent(typeof(Camera))]
    [AddComponentMenu("Rendering/X-Frame FPS Accelerator", 90)]
    [DefaultExecutionOrder(100)]
    public class XFrameManager : MonoBehaviour {
    ...

Paul_S

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Camera shaking with X-Frame enabled
« Reply #4 on: June 05, 2021, 08:26:43 PM »
i changed XFrameManager.cs but doesn't fix the shaking, i also tried "[DefaultExecutionOrder(10000)]" and "[DefaultExecutionOrder(-100)]" without success.

I noticed that the shaking of the camera gets stronger the further you get away from the center of the map. But even at the farthest point i have no shaking when i turn off X-Frame. Maybe the Render Camera should be fixed at Position 0,0,0 ?

Paul_S

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Camera shaking with X-Frame enabled
« Reply #5 on: June 05, 2021, 08:29:59 PM »
Yes i tested it, and when i unparented the Render Camera and changed the position to 0,0,0 there is absolutely no shaking, even when i enter areas where it was shaking very bad everything is fine now. I thing i have to change the code a little bit to unparent the render camera from the main camera on activation.

Paul_S

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Camera shaking with X-Frame enabled
« Reply #6 on: June 05, 2021, 08:42:33 PM »
After commenting out the "parent to maincamera" line and changing the position to 0,0,0 under "void SetupSecondCameraBillboardWorldSpaceMode" everything works fine now  :)

Code

void SetupSecondCameraBillboardWorldSpaceMode() {

 

Code
            xFrameCamera.renderingPath = RenderingPath.Forward;
        xFrameCamera.transform.position = new Vector3 (0,0,0);//GetFarCameraPos();
            xFrameCamera.transform.rotation = Quaternion.Euler(0, 0, 0);
        // xFrameCamera.transform.SetParent(mainCamera.transform, true);

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7103
    • View Profile
Re: Camera shaking with X-Frame enabled
« Reply #7 on: June 05, 2021, 08:59:11 PM »
Seems like a floating point issue. When you refer to “far”, which distance aprox are you referring?

Paul_S

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Camera shaking with X-Frame enabled
« Reply #8 on: June 05, 2021, 09:22:41 PM »
my farthest point is at "x 14.000 y 120.000 z 630.000" but that shaking was also noticeable at "x 30.000 y 160.000 z 240.000"
Other objects and scripts don't have floating point issues at all. Perhaps the orthographic view is more prone to floating point errors.

 

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7103
    • View Profile
Re: Camera shaking with X-Frame enabled
« Reply #9 on: June 06, 2021, 06:04:32 PM »
That explains it. X-Frame adds a camera and billboard children to the main camera. Each child transform implies a matrix multiplication which considering such high values will introduce inacccuarcies producing that jittering in the billboard position relative to the x-frame camera. Positioning it at 0 solves that - the reason it's positioned a bit far away is to prevent the billboard from being captured by the main camera (you can of course cull it using layers, etc. but in most cases the "far position" keeps it out of view).

Paul_S

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Camera shaking with X-Frame enabled
« Reply #10 on: June 06, 2021, 08:08:34 PM »
Good to know! Thanks for the explanation, i was just asking myself about the FarCameraPos. I will check if it could get into the field of view of the main camera.