Jump to content

Frame drops when rotating camera


Michael_J
 Share

Recommended Posts

Could someone confirm this so we can find out if it's local or not, please?

 

Using the tutorial found here (I'm using c++):

 

http://www.leadwerks.com/werkspace/page/tutorials_legacy/_/making-a-first-person-camera-r15

 

 

To prepare, do two things:

 

Comment out this line:

window->HideMouse();

 

Add this line just before context->Sync(true):

cout << Time::UPS() << endl;

 

 

Compile and run. Do you notice two things--a spiking of the mouse pointer, and a drop in frame rate from 60 (vsync'ed) to about 30-ish as you rotate the camera? It seems to get worse as you rotate faster.

 

It's very noticeable if you turn vsync off: context->Sync(false). For me, I go from the 300's with drops down into double digits.

 

I've seen this type of thing before in engines, but only when video memory was being offloaded to system memory. I can't imagine this would be happening though for a scene with two textured boxes...

 

What it does do though is make the character controller, in this example, very choppy when you look around...

 

I don't care what the consensus is, I just need to know if it's a local issue or something that Josh may need to take a look at smile.png So, either way, thanks in advance for the confirmation.

--"There is no spoon"

Link to comment
Share on other sites

In that tutorial there are no lights created.

 

Sorry, I should have mentioned in my post that I tried disabling both lighting for the camera and physics for the world with no help. If this is not a local issue to me then hopefully there's some issue Josh can track down using this tutorial code that will help smooth things out.

 

Hence, I need someone to confirm my findings....

--"There is no spoon"

Link to comment
Share on other sites

Well, I'm not sure what precisely is causing it. I've tried both the latest AMD release and beta drivers (WARNING: for me, I got a noticeable pause every second in debug mode with the beta driver), and did some other suggestions I found to no avail.

 

Actually, it was better when I had my video driver completely uninstalled, but that makes my triple-monitor setup useless...

 

If anyone else runs across this, or something similar, please leave a comment. Thanks...

--"There is no spoon"

Link to comment
Share on other sites

I changed from dual 7770s to dual r7 260x's and my gfx performance has suffered in leadwerks. Its fine everywhere else. Also leadwerks will tend to stutter when a light goes into the view frustum, whether or not you see it. So I can make a room of lights and be a distance from it and not looking at it. When I turn around and look at the lights, I ca see in the debug screen that the lights are then being loaded for the first time. Over the next few months I think there will be some optimizations as the feature set gets finalized.

  • Upvote 1
Link to comment
Share on other sites

Some more info on this: this has NOTHING to do with the camera itself rotating. The FPS stuttering is a direct result of the mouse pointer being re-centered over and over (as is common practice for any sort of "mouse look".

 

This is either an issue with my Radeon r9 290, or Windows 8.1 (both Microsoft and AMD have confirmed cases of stuttering when turning the camera, which again would use this method).

 

So, the question now is what to do about it. I've tried re-centering the mouse on one frame and taking a difference reading on the next, but that didn't help. Obviously you have to recenter the mouse or eventually you'll hit a stop, so I'm not sure how else this could be managed in game code.

--"There is no spoon"

Link to comment
Share on other sites

I understand this is how it works on the 3.1 demo. I'm sure there may be other performance issues at the moment; but, this CAN drop frame rate briefly (micro-stutter) as verified by both MS and AMD (for various reasons). I tested my prog, as well as the tutorial above, on my other rig (Win 7 with nVidia) and all is well--FPS is stable when moving the mouse.

 

I've confirmed this by locking the camera and moving the mouse--when the mouse is still the FPS are stable, when it moves they drop. I've done this with physics and camera lighting enabled and disabled--same result.

 

Now, I've had 3 people tell me they have Win 8.1 and no problems, but I'm not sure (except in one case) what vid cards they have. My guess would be nVidia. Sometime this week I'll verify by moving my nVidia to this 8.1 rig and see what happens...

 

Otherwise, there is something wrong with this rig, which could certainly be possible. Actually I'd prefer that because then it's an isolated case and doesn't reflect a deeper issue... smile.png The other possibility is the mouse is reflecting another issue in which case I'd still like to know what that issue is that seems to be machine-specific (based on my local test here)...

 

Oh well--too busy to really worry about it right now ;)

--"There is no spoon"

Link to comment
Share on other sites

I was working on exactly the same thing last night creating a 3rd person camera. I had the same jittering that you describe when rotating. I was doing some testing and coming from that it seems that if you set the cameras rotation to the players rotation you get some nasty jittering. There is definitely something wrong going on here I think.

 

Here is what I came up with that gave me good results.

 

I have an interface manager that manages everything GUI

 

This takes place every game loop to give me the mouses offset.

Vec3 mousePosition = context->window->GetMousePosition();
if (mousePosition != mousePreviousPosition)
{
mouseDelta = mousePreviousPosition - mousePosition;
}
else
{
mouseDelta = 0.0F;
}
if ((cursor) && cursor->IsVisible())
{
cursor->SetPosition(mousePosition.x, mousePosition.y);
cursor->Render();
}
else
{
context->window->SetMousePosition(context->GetWidth() / 2, context->GetHeight() / 2);
mousePreviousPosition = context->window->GetMousePosition();
}

 

 

In the player controller's update, and the yaw value is used in the characters SetInput() function for rotation.

 

float cameraTopAngle = 45;
 float cameraBottomAngle = -45;
 yaw += TheInterface->GetMouseDelta().x / mouseSensitivity;
 pitch += TheInterface->GetMouseDelta().y / mouseSensitivity;
 //Adjust and set the camera rotation
 if (pitch > cameraTopAngle)
 pitch = cameraTopAngle;
 else if (pitch < cameraBottomAngle)
 pitch = cameraBottomAngle;

 

 

My camera object Update

 

 

if (GetCameraTarget())
{
//GameObject *objectTarget = (GameObject*)TheGameWorld->FindObjectByAddress(Object::GetAddress(GetCameraTarget()));
if (!TheMainWindow)
{
Vec3 lastPosition;
BaseObject* object = (BaseObject*)GetCameraTarget()->GetUserData();
if (object->GetBaseType() == kObjectCharacter)
{
GameCharacter *character = static_cast<GameCharacter*>(object);
if(character)
{
 //Figure out new position
 //lastPosition = entity->GetPosition();

 //Calculate the furthest TPS pivot position
 tpsPivot->SetPosition(GetCameraTarget()->GetPosition());
 tpsPivot->Move(0.0F, GetHeight(), -GetCamDistance(), false);

 //Use a pick to determine where the camera should be
 PickInfo pick;
 Vec3 pickPos = GetCameraTarget()->GetPosition();
 pickPos.y += GetHeight();
 character->entity->SetPickMode(0);
 if (TheGameWorld->world->Pick(pickPos, tpsPivot->GetPosition(), pick, 0.0F, true))
 {
 //Store distance
 float distance = tpsPivot->GetPosition().DistanceToPoint(pick.position);
 std::cout << distance << std::endl;
 tpsPivot->SetPosition(pick.position);
 }
 character->entity->SetPickMode(Entity::SpherePick);
 tpsPivot->SetRotation(GetCameraTarget()->GetRotation());

 Vec3 rot = tpsPivot->GetRotation();
 rot.y = -character->GetYaw();
 rot.x = -character->GetPitch();
 //Apply position
 lastPosition.x = Math::Curve(tpsPivot->GetPosition().x, entity->GetPosition().x, (GetSmoothness()) / Time::GetSpeed());
 lastPosition.y = Math::Curve(tpsPivot->GetPosition().y, entity->GetPosition().y, (GetSmoothness()) / Time::GetSpeed());
 lastPosition.z = Math::Curve(tpsPivot->GetPosition().z, entity->GetPosition().z, (GetSmoothness()) / Time::GetSpeed());
 entity->SetRotation(rot);
 entity->SetPosition(lastPosition);
}
}
}
}

 

The important thing to note is that the delta of the mouse movement is fed into the pitch and yaw variables which is accessed by the camera to set it's rotation opposed to camera->SetRotation(character->GetRotation()) (Although I would have thought the set rotation method should work). Obviously there are declarations which I haven't included above. I coded it in the early hours of last night and haven't looked at it since but hope it helps.

trindieprod.png?dl=0spacer.png?dl=0steam-icon.png?dl=0twitter-icon.png?dl=0spacer.png?dl=0
Link to comment
Share on other sites

  • 1 month later...

I DID find the cause of this and it's a very real issue for a lot of people. There's two reasons actually:

 

The first is a virus that you can find in your processes list with the name stij.exe Removal is easy (one of many videos here:

) as long as you get all of it so it doesn't come back.

 

MY issue though was Windows 8.1 and my high performance gaming mouse. As I understand it, M$ set the mouse poll rate down to 125 for Win8.1 from Win7's 1000. What this did was cause any high performance mouse with DPI's in the thousand's to basically "flood" the system with any fast motion inputs. In a small Le test app I went from 1000 UPS down to *2* (yes, two).

 

You have three options here:

1) buy a cheap, low poll-rate mouse

2) set Win8.1's poll rate back up to 1000 through some method I wasn't 100% comfortable with.

3) If you're fortunate (as I was) your high performance mouse comes with software to allow you to lower the poll rate. My Logitech did. Setting it down to 500 helped. 250 helped even more, and at 125 everything is now as smooth as glass :)

 

Anyway, I just wanted to report back on this to say that this wasn't an Le issue, but it is real and I wanted to pass on the info if anyone else has a similar problem.

 

Thanks :)

  • Upvote 2

--"There is no spoon"

Link to comment
Share on other sites

I'll also point out dumping to console is exceedingly slow, it will always cause a frame rate loss, especially if you're calling it every cycle. Best to put it on a 500ms timer or some such or draw it on your context in game.

 

I doubt that's the center of your problem but it certainly will have an effect.

Coding for Christ.

Link to comment
Share on other sites

Yeah, console writing will slow things down, but that's a steady, constant hit. This was absolutely system pauses when moving the mouse quickly. :)

 

AMD also had an issue with this a year or so ago, but that was fixed with a driver update. Whatever, I'm just happy I found the problem, and also pretty happy it wasn't an issue with either my code nor with Le 3.1 :)

--"There is no spoon"

Link to comment
Share on other sites

  • 2 years later...

Not sure if I should bring back old topic. But is the mouse rotating around object stuttering is a known bug or fixed ? I get a strange stuttering when I try to rotate while looking at the stairs railing in the AI-Event demo.

 

Windows 10 64Bit

GTX970

 

My settings

1920x1080, msaa2, vsync=on,anisotropy filtering=16, fullscreen on.

 

Funny thing is, I want to record and show this to Josh, when I turn on Shadowplay and try to record it, the stuttering when rotating is almost gone. But if I turn off recording, the stuttering is back.

Link to comment
Share on other sites

I doubt Shadowplay records at a variable framerate, so it probably drops to a lower framerate, so if you're getting around 45 FPS on the other thread you commented on, it samples at 30, and you don't get the stuttering you would normally get with V-sync enabled. Turn off V-Sync if you don't want that stuttering.

Link to comment
Share on other sites

It is possible there may be something to what you are saying, but if a problem exists, it also existed in 4.1 since I do not think anything I have done would have changed this. So it will be deferred until after the release of 4.2.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...