nord
15-02-2011 17:03:18
Hi all.
I have saved a physx scene replay log. Log format is like
frame 1
nodeID x y z yaw pitch roll
nodeID x y z yaw pitch roll
nodeID x y z yaw pitch roll
...
frame 2
nodeID x y z yaw pitch roll
nodeID x y z yaw pitch roll
nodeID x y z yaw pitch roll
...
frame n
...
The positions and orientations in a frame belong to scene nodes identified by "nodeID". This log is created by running physx engine solely on a C++ program (There is no relation with Ogre or NxOgre). Each frame is a snapshot of physx world at that time stamp. There are (almost) 16.6 miliseconds between frames. So that makes the input signal (replay log) 60Hz.
In my replay log, actually there are 20 cars, and 4 x 20 = 80 tires. So at each frame, I have 100 scenenodes, with changing x y z yaw pitch roll values. When i replay my log in my "X" rendering engine, I see that cars move very smoothly. So I am sure that my log is correct and smooth.
My first test :
I created a very basic Ogre application, and before rendering, i filled a
Results :
When the scene is simple, Ogre runs at 60 fps (Vsync is enabled always). And since my input signal is 60Hz, everything is rendered correctly, there is no jitter, cars and their tires (actually cubes and cylinders
move smoothly. If i decrease the Ogre fps by increasing (for example) triangle count, car movements slow down as expected, since Ogre consume a 60Hz input signal in for eg 40Hz (fps).
But,
if the Ogre fps is not stable, for example if it fluctuates between 28 and 37, then I see jitter, which is (you can disagree with me at any point) because of the changing velocities (Consuming 60Hz input signal at varying frequencies).
My second test :
What I also tried is, I launched a tester thread prior to rendering with Ogre. This tester thread reads all the replay log file, and fills its own
In other words :
Ogre runs at 60fps, so it reads the bufferFrame temp variable 60 times a second, updating its whole scenegraph. Tester thread (my primitive physx engine simulator:) loop runs at 60Hz, it writes the current frame to bufferFrame 60 times a second.
Results
If Ogre runs at 60fps, there is some little jitter : Because even if both reader(Ogre) and writer(tester thread) seem to run at 60Hz, sometimes Ogre reads the same frame from bufferFrame, and sometimes it skips a frame. So depending on (slightly) changing frequencies of Ogre due to unpredictable nature of rendering, i see skips or freezes (you may disagree with my conclusions
.
If Ogre runs at 30fps, or especially at a range of 30-40fps, there is terrible jitter which i believe that the great increase in number of frame skips cause this stalls and jitters.
(Note that i tried to use bufferFrame write&read operations with/without a slim lock, it doesnt change anything in terms of jitter and performance, but i think the lock prevents the "very rare" crushes during read.)
Question
How can I smoothly carry my physics world's x y z yaw pitch roll information to my Ogre scenegraph?
My limitations are :
I do not want to count on stable 60 fps.
My physx has to run on a different thread (which was tester thread in the example above) than Ogre rendering thread.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I am an ex Ogre, NxOgre and Axiom(C# Ogre) user and rightnow i am working on a piece of Openscenegraph code working with physx (no wrapper between).
We had kind of jitter, or stall (whatever it is called) problem (we even have network between physx and graphics, this is an extremely simplified version of our nightmare jitter&stall problem), and I remembered NxOgre community had a similar problem and it was fixed (around 2008 i guess). So i tried to reproduce my jitter problem with an ogre application. I obviously lack the knowledge to connect a physx engine to a graphics engine. And here i am
Thanks in advance for all the comments.
Arif Yetkin
I have saved a physx scene replay log. Log format is like
frame 1
nodeID x y z yaw pitch roll
nodeID x y z yaw pitch roll
nodeID x y z yaw pitch roll
...
frame 2
nodeID x y z yaw pitch roll
nodeID x y z yaw pitch roll
nodeID x y z yaw pitch roll
...
frame n
...
The positions and orientations in a frame belong to scene nodes identified by "nodeID". This log is created by running physx engine solely on a C++ program (There is no relation with Ogre or NxOgre). Each frame is a snapshot of physx world at that time stamp. There are (almost) 16.6 miliseconds between frames. So that makes the input signal (replay log) 60Hz.
In my replay log, actually there are 20 cars, and 4 x 20 = 80 tires. So at each frame, I have 100 scenenodes, with changing x y z yaw pitch roll values. When i replay my log in my "X" rendering engine, I see that cars move very smoothly. So I am sure that my log is correct and smooth.
My first test :
I created a very basic Ogre application, and before rendering, i filled a
std::dequeue<frame> inputFrames
with the log. frame
(c++ struct) consists of std::vector<int> ids
and std::vector<double> data
, simply holding ids and x y z h p r values of the sceneNodes for that frame. Then I created 20 cubes and 80 cylinders in my Ogre application with appropriate "nodeID" s. During my each render loop, I dequeued a single frame, and updated my whole scene with the the information extracted from that frame.Results :
When the scene is simple, Ogre runs at 60 fps (Vsync is enabled always). And since my input signal is 60Hz, everything is rendered correctly, there is no jitter, cars and their tires (actually cubes and cylinders

But,
if the Ogre fps is not stable, for example if it fluctuates between 28 and 37, then I see jitter, which is (you can disagree with me at any point) because of the changing velocities (Consuming 60Hz input signal at varying frequencies).
My second test :
What I also tried is, I launched a tester thread prior to rendering with Ogre. This tester thread reads all the replay log file, and fills its own
std::dequeue<frame>
. When Ogre starts rendering, this tester thread behaves like a physx engine, it dequeues a frame, and puts this frame in a temp variable that also Ogre application has access to. Than during the render loop, after each renderOneFrame, i check this temp variable (frame bufferFrame;
) and update the Ogre scene with this information.In other words :
Ogre runs at 60fps, so it reads the bufferFrame temp variable 60 times a second, updating its whole scenegraph. Tester thread (my primitive physx engine simulator:) loop runs at 60Hz, it writes the current frame to bufferFrame 60 times a second.
Results
If Ogre runs at 60fps, there is some little jitter : Because even if both reader(Ogre) and writer(tester thread) seem to run at 60Hz, sometimes Ogre reads the same frame from bufferFrame, and sometimes it skips a frame. So depending on (slightly) changing frequencies of Ogre due to unpredictable nature of rendering, i see skips or freezes (you may disagree with my conclusions

If Ogre runs at 30fps, or especially at a range of 30-40fps, there is terrible jitter which i believe that the great increase in number of frame skips cause this stalls and jitters.
(Note that i tried to use bufferFrame write&read operations with/without a slim lock, it doesnt change anything in terms of jitter and performance, but i think the lock prevents the "very rare" crushes during read.)
Question
How can I smoothly carry my physics world's x y z yaw pitch roll information to my Ogre scenegraph?
My limitations are :
I do not want to count on stable 60 fps.
My physx has to run on a different thread (which was tester thread in the example above) than Ogre rendering thread.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I am an ex Ogre, NxOgre and Axiom(C# Ogre) user and rightnow i am working on a piece of Openscenegraph code working with physx (no wrapper between).
We had kind of jitter, or stall (whatever it is called) problem (we even have network between physx and graphics, this is an extremely simplified version of our nightmare jitter&stall problem), and I remembered NxOgre community had a similar problem and it was fixed (around 2008 i guess). So i tried to reproduce my jitter problem with an ogre application. I obviously lack the knowledge to connect a physx engine to a graphics engine. And here i am

Thanks in advance for all the comments.
Arif Yetkin