Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualIcebone1000

Posted 02 April 2013 - 09:25 AM

One way I use to find the smoothness of my rendering, more intuitive then inspecting the variation of frame times, is to render a sprite model moving at constant speed in a loop, rendering it against the empty render target WITHOUT clearing it. That way the sprite will create a pattern on the screen, that pattern will be constant almost times, but when it jitters it will leave a gap on the pattern...can you understand it?

Heres my example:

https://lh3.googleusercontent.com/-pjanW27XNKY/UVrw6Nt0uyI/AAAAAAAAAgg/hundTIgOGaI/s1076/Untitled-1.png

I think its an osome way to check for jittering/stuttering or wathever its called..

Im current using Glenns method, my test loop current looks like that:

 

 

        //========================================================================
        // game loop vars
        //========================================================================
        double frameDeltaAccumulated = 0.0;
        const double fixedStep = 1.0/24.0;
        //========================================================================
        bool bGoingRight = true;
        while( Msg.message != WM_QUIT ){

            win::UniqueHigPerfTimer().Update();
            win::UniqueFileLogger()<<win::UniqueHigPerfTimer().GetDeltaSeconds()<<SZ_NEWLINE;

            while( PeekMessage( &Msg, NULL, NULL, NULL, PM_REMOVE )    ){

                TranslateMessage( &Msg );
                DispatchMessage( &Msg );

                win::UniqueFileLogger()<<"WM"<<SZ_NEWLINE;
            }

            //========================================================================
            // GLENN loop
            double currentFrameDeltaSec = win::UniqueHigPerfTimer().GetDeltaSeconds();
            if( currentFrameDeltaSec > 0.25 )//fixedStep )//0.25
                currentFrameDeltaSec = 0.25;

            frameDeltaAccumulated += currentFrameDeltaSec;

            while( frameDeltaAccumulated > fixedStep ){

                frameDeltaAccumulated -= fixedStep;
            //========================================================================
            
                mySprite.m_trafo.Step(); //saves previous trafo for interpolation

                if( bGoingRight ){

                    const DirectX::FXMVECTOR vVel = DirectX::XMVectorSet( (float)(100.0*fixedStep), 0.0f, 0.0f, 0.0f );
                    mySprite.m_trafo.m_vCurrentPosition = DirectX::XMVectorAdd( mySprite.m_trafo.m_vCurrentPosition, vVel);

                    if( DirectX::XMVectorGetX( mySprite.m_trafo.m_vCurrentPosition ) > 500.0f ) bGoingRight = false;
                }
                else{
                    const DirectX::FXMVECTOR vVel = DirectX::XMVectorSet( -(float)(100.0*fixedStep), 0.0f, 0.0f, 0.0f );
                    mySprite.m_trafo.m_vCurrentPosition = DirectX::XMVectorAdd( mySprite.m_trafo.m_vCurrentPosition, vVel);

                    if( DirectX::XMVectorGetX( mySprite.m_trafo.m_vCurrentPosition ) < -500.0f ) bGoingRight = true;
                }
            }

            //------------------------------------------------------------------------
            // interpolate:

            const double alpha = frameDeltaAccumulated / fixedStep;

            mySprite.Update( alpha, myWindow.m_device.GetContext() );

            //------------------------------------------------------------------------
            myWindow.m_spriteRenderer.Render( &mySprite ); // queue sprite commands
            myWindow.m_spriteRenderer.Raster( myWindow.m_device.GetContext()); // execute commands

            myWindow.m_swapChain.m_pSwapChain->Present(1, 0);        
        }
 

Im totally new to fixed time steps, previously Id just gather the delta with the hig perf counters and update with it.

 

Heres how my deltas look like(im rendering a single sprite, and my deltas are far from constant):

 

0.016912
0.016572
0.016887
0.016759
0.016487
0.015790
0.016446
0.016867
0.016665
0.016744
0.016644
0.016964
0.016686
0.016564
0.016661
0.017432
0.016770
0.016777
0.016366
0.017165
0.017188
0.016933
0.016495
0.016738
0.016733
 

 

I will try your method later.


#1Icebone1000

Posted 02 April 2013 - 09:18 AM

One way I use to find the smoothness of my rendering, more intuitive then inspecting the variation of frame times, is to render a sprite model moving at constant speed in a loop, rendering it against the empty render target WITHOUT clearing it. That way the sprite will create a pattern on the screen, that pattern will be constant almost times, but when it jitters it will leave a gap on the pattern...can you understand it?

Heres my example:

https://lh3.googleusercontent.com/-pjanW27XNKY/UVrw6Nt0uyI/AAAAAAAAAgg/hundTIgOGaI/s1076/Untitled-1.png

I think its an osome way to check for jittering/stuttering or wathever its called..

Im current using Glenns method, my test loop current looks like that:

 

 

        //========================================================================
        // game loop vars
        //========================================================================
        double frameDeltaAccumulated = 0.0;
        const double fixedStep = 1.0/24.0;
        //========================================================================
        bool bGoingRight = true;
        while( Msg.message != WM_QUIT ){

            win::UniqueHigPerfTimer().Update();
            win::UniqueFileLogger()<<win::UniqueHigPerfTimer().GetDeltaSeconds()<<SZ_NEWLINE;

            while( PeekMessage( &Msg, NULL, NULL, NULL, PM_REMOVE )    ){

                TranslateMessage( &Msg );
                DispatchMessage( &Msg );

                win::UniqueFileLogger()<<"WM"<<SZ_NEWLINE;
            }

            //========================================================================
            // GLENN loop
            double currentFrameDeltaSec = win::UniqueHigPerfTimer().GetDeltaSeconds();
            if( currentFrameDeltaSec > 0.25 )//fixedStep )//0.25
                currentFrameDeltaSec = 0.25;

            frameDeltaAccumulated += currentFrameDeltaSec;

            while( frameDeltaAccumulated > fixedStep ){

                frameDeltaAccumulated -= fixedStep;
            //========================================================================
            
                mySprite.m_trafo.Step(); //saves previous trafo for interpolation

                if( bGoingRight ){

                    const DirectX::FXMVECTOR vVel = DirectX::XMVectorSet( (float)(100.0*fixedStep), 0.0f, 0.0f, 0.0f );
                    mySprite.m_trafo.m_vCurrentPosition = DirectX::XMVectorAdd( mySprite.m_trafo.m_vCurrentPosition, vVel);

                    if( DirectX::XMVectorGetX( mySprite.m_trafo.m_vCurrentPosition ) > 500.0f ) bGoingRight = false;
                }
                else{
                    const DirectX::FXMVECTOR vVel = DirectX::XMVectorSet( -(float)(100.0*fixedStep), 0.0f, 0.0f, 0.0f );
                    mySprite.m_trafo.m_vCurrentPosition = DirectX::XMVectorAdd( mySprite.m_trafo.m_vCurrentPosition, vVel);

                    if( DirectX::XMVectorGetX( mySprite.m_trafo.m_vCurrentPosition ) < -500.0f ) bGoingRight = true;
                }
            }

            //------------------------------------------------------------------------
            // interpolate:

            const double alpha = frameDeltaAccumulated / fixedStep;

            mySprite.Update( alpha, myWindow.m_device.GetContext() );

            //------------------------------------------------------------------------
            myWindow.m_spriteRenderer.Render( &mySprite ); // queue sprite commands
            myWindow.m_spriteRenderer.Raster( myWindow.m_device.GetContext()); // execute commands

            myWindow.m_swapChain.m_pSwapChain->Present(1, 0);        
        }
 

 

 

Heres how my deltas look like(im rendering a single sprite, and my deltas are far from constant):

 

0.016912
0.016572
0.016887
0.016759
0.016487
0.015790
0.016446
0.016867
0.016665
0.016744
0.016644
0.016964
0.016686
0.016564
0.016661
0.017432
0.016770
0.016777
0.016366
0.017165
0.017188
0.016933
0.016495
0.016738
0.016733
 

 

I will try your method later.

Im totally new to fixed time steps, previously Id just gather the delta with the hig perf counters and update with it.


PARTNERS