Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Some sort of flickering  (Read 14264 times)

0 Members and 2 Guests are viewing this topic.

etixpp

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
    • FoxFire Development Website
    • Email
Some sort of flickering
« on: November 19, 2013, 05:32:38 pm »
Hej guys, i created a video to show you what i mean
http://www.youtube.com/watch?v=AalWbLu21fQ&feature=youtu.be
The thing is... i really got no clue what could cause this, i discommented everything except the map rendering...
Its kinda hard to create a minimap example for this... could this be caused by my graphic card / driver or something? Normally everything should be fine with this...

If you don´t see, there are something like "Stripes" i only notice them if i zoom out kinda much but this stripes are creating some darker and lighter layers and a flickering... you can notice it best at 00:37 .
Its probably kinda senseless to show code here cause there are a lot of dependencies and unneccesary stuff, so before i try to create a minimal example i just wanted to ask if somebody had this once aswell and knows a cause or solution :)


Ok, just for your Info, i checked a few more things now:
-2 Mates have the same prob with my executable, so i am pretty sure its not about the graphic card
-i discomented every drawing except the background and this layers still exists with the same phenomen, so i am pretty sure it´s not about too much drawing on a frame
-Not about Fps aswell, i tried with 30, 60 and unlimited, no reaction
« Last Edit: November 19, 2013, 05:43:06 pm by etixpp »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Some sort of flickering
« Reply #1 on: November 19, 2013, 05:46:19 pm »
I guess you mean the vertical stripes in the teal area starting at 0:37. Does it look exactly like that in the original application (even when not recording) and isn't this the result of video compression?

Do you adhere to the clear/draw/display cycle for every frame? And there is no texture or shader involved that may cause such a result?

Try to reproduce the problem by rendering only the teal area. Then your code should be minimal.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

etixpp

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
    • FoxFire Development Website
    • Email
Re: Some sort of flickering
« Reply #2 on: November 19, 2013, 05:51:47 pm »
No, its not only in the video, its in the main application >.<
My clear Draw Display Area looks like this atm
->
                window.clear();
                MainMap.RenderActualMap(window,MainPlayer,MainRenderChunk,MainView);
                /*display window gui and so on */
                       
                if (EscMenue)
                {
                        desktopx.Update(1.F);
                        sfgui.Display( window);
                }
                // MINIMAP
                UserInterface.DrawOnRenderTexture(MainPlayer.GetPlayerDirection(),MainRenderChunk.GetBgSprite(),MainRenderChunk.GetMainSprite(),MainRenderChunk.GetCollisionSprite(),MainPlayer.GetPlayerSprite());
                UserInterface.update(MainPlayer.GetPlayerSprite(),window.getView(),window);
                // TGUI Für statisches Menü. Atm nicht nötig gui.draw();
                //RECOURCE DATAwindow.draw(loadstuff);
                window.draw(LocalRectangle);
                for (int i = 0; i < ZoneContainer.size(); i++)
                {
                        window.draw(ZoneContainer.at(i));
                }

                window.display();

But i deleted everything except this for testing:
window.clear();
MainMap.RenderActualMap(window,MainPlayer,MainRenderChunk,MainView);
window.display();

RenderActualMap just draw´s the Background, Foreground and Player and a few physics, i deleted everything there aswell except background and player, still no reaction >.<

This vertical Things are like Layers, they go over the HUD etc. aswell if i draw it and if i zoom out enough, it can even overlay parts of the HUD

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Some sort of flickering
« Reply #3 on: November 19, 2013, 05:56:41 pm »
What happens if you draw only the teal texture? That is, get rid of all custom code such as RenderActualMap() or SFGUI. Simply use an image file that contains nothing but the teal background, load it with a sf::Texture and draw it using a sf::Sprite.

If you provide a minimal and complete example that reproduces the problem, you help us find the problem, and we don't waste time with guessing.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

etixpp

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
    • FoxFire Development Website
    • Email
Re: Some sort of flickering
« Reply #4 on: November 19, 2013, 07:08:27 pm »
It does no problems with Sf Image and some Color Fill, but that does not make it better ... D:
I have no clue what could cause it with the texture, the only thing i notice it, that it´s only a realy big problem if i zoom out a lot, but still even if i dont, if i look carefully i can exactly see what happens,
created one more video to show what´s about the view->

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Some sort of flickering
« Reply #5 on: November 19, 2013, 07:24:31 pm »
Looks like screen tearing, how are you limiting your FPS?
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

etixpp

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
    • FoxFire Development Website
    • Email
Re: Some sort of flickering
« Reply #6 on: November 19, 2013, 07:31:30 pm »
screen tearing <- That´s the word i was looking for D:
But i still think its something about the view, if i zoom in very much the problem disappears >.<

window.setFramerateLimit(60); // FPS
« Last Edit: November 19, 2013, 07:33:35 pm by etixpp »

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Some sort of flickering
« Reply #7 on: November 19, 2013, 07:37:11 pm »
window.setFramerateLimit(60); // FPS

Lets say it this way, setFramerateLimit is not perfect when it comes to preventing screen tearing. Instead you should use window.setVSyncEnabled(true) to avoid screen tearing.

On my own laptop, if I don't use VSync I always will get screen tearing with just setFramerateLimit. So what I do is that I first enable VSync and then measure the FPS over multiple frames, if it is over the acceptable limit I then use setFramerateLimit.
« Last Edit: November 19, 2013, 07:43:20 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Some sort of flickering
« Reply #8 on: November 19, 2013, 07:38:51 pm »
Make sure you set the view to and game objects to integer position. Also try to play around with the zooming factor, so it isn't off big time.

For screen tearing the first solution one should try is turning on VSync.

But I wonder, why is your game so much stretched in the width, like the ratio doesn't fit at all, thus can of course also lead to issues.

The fact that the cross on the minimap texture is disappearing is because the texture gets scaled and not all pixels can be mapped 1:1 thus OpenGL has to interpolate, which can remove the few pixels width line.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

etixpp

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
    • FoxFire Development Website
    • Email
Re: Some sort of flickering
« Reply #9 on: November 19, 2013, 07:48:39 pm »
i tried setVerticalSyncEnabled but did not help at all >.<
I played a bit with the ratio aswell, should not be the problem :/

Quote
The fact that the cross on the minimap texture is disappearing is because the texture gets scaled and not all pixels can be mapped 1:1 thus OpenGL has to interpolate, which can remove the few pixels width line.
Ye that seems legit, isnt such a problem anyways, i just thought it could have something together with the strips.

I just cheked all Objects should be integer positioned

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Some sort of flickering
« Reply #10 on: November 19, 2013, 07:52:56 pm »
i tried setVerticalSyncEnabled but did not help at all >.<
I played a bit with the ratio aswell, should not be the problem :/

Be sure you are not using setFramerateLimit and setVerticalSyncEnabled at the same time. Also are you sure that the VSync is being turned on? (What is your FPS with just VSync?)

Also depending on your GPU manufacturer, it may be possible to force VSync on for all applications. If you can force VSync on try to do that and see if it makes a difference.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

etixpp

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
    • FoxFire Development Website
    • Email
Re: Some sort of flickering
« Reply #11 on: November 19, 2013, 07:58:06 pm »
i tried setVerticalSyncEnabled but did not help at all >.<
I played a bit with the ratio aswell, should not be the problem :/

Be sure you are not using setFramerateLimit and setVerticalSyncEnabled at the same time. Also are you sure that the VSync is being turned on? (What is your FPS with just VSync?)

Also depending on your GPU manufacturer, it may be possible to force VSync on for all applications. If you can force VSync on try to do that and see if it makes a difference.

I took care of this.
58-62 fps

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Some sort of flickering
« Reply #12 on: November 19, 2013, 08:03:58 pm »
It's not screen tearing, that would only be lines that separate vertical parts of the screen, as a result of more than one frame being visible at the same time.

Concerning integer coordinates, make sure that position and origin of each drawable object, as well as center, size and zoom factor of the view are integral (just to see whether the issues disappear then).
« Last Edit: November 19, 2013, 08:08:02 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

etixpp

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
    • FoxFire Development Website
    • Email
Re: Some sort of flickering
« Reply #13 on: November 19, 2013, 08:16:18 pm »
The map which is the only affected object (Shapes or something do not give a shit on it) is at position and origin 0,0 and never changes, so i am pretty sure, that this part should be fine.

The view center allways gets done by something like this:
MainView.setCenter(MainPlayer.GetPlayerSprite().getPosition().x+16,MainPlayer.GetPlayerSprite().getPosition().y+16);

And the Player allways moves only 4 pixels, not more and not less, so it´s pretty impossible, that the map or the player or the view have a non integer value.

The view without defined is like this
                MainView = sf::View(sf::FloatRect(0, 0, 512, 512));
        MainView.zoom(1);

And makes problems without zooming in or out, if i go for 300,300 size or something like that it goes to a acceptable size (same effect as zooming in a lot).

i dissabled everything else and still problems, so i think it´s pretty sure not about this :/


Viewsize 400,400 is like a absolute charm, couldnt be better, if i put 700 700 without zooming out or something, just the size of the view, its already messed up >.<
« Last Edit: November 19, 2013, 08:22:04 pm by etixpp »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Some sort of flickering
« Reply #14 on: November 19, 2013, 08:23:54 pm »
[...] so i am pretty sure, that this part should be fine.
[...] so it´s pretty impossible, that the map or the player or the view have a non integer value.
[...] so i think it´s pretty sure not about this :/
It would really be helpful to quit speculating and find the issue in a less time-wasting way. Obviously there is a problem somewhere, but with the information you gave us so far, it's not possible to determine it exactly.

There are of course distortions if the view is zoomed at a non-integral ratio, but I'm not sure if it's only that.

Provide a complete and minimal code example, so we actually see the problem.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: