Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Flashing sprite edges

Author
Message
Chara Bill
7
Years of Service
User Offline
Joined: 6th Apr 2017
Location:
Posted: 3rd Jul 2017 19:19 Edited at: 3rd Jul 2017 19:35
Hi there guys!
So, I've encountered some kind of problem: when you make your character move, the edges of other sprites begin to change their colors and brightness. It kinda looks flashy. It'd be nice if somebody gave me a hand with it.
Here's the code:


All the assets are attached to the post within an archive.

Attachments

Login to view attachments
Chara Bill
7
Years of Service
User Offline
Joined: 6th Apr 2017
Location:
Posted: 6th Jul 2017 12:26
Anybody?..
Supertino
7
Years of Service
User Offline
Joined: 22nd Jun 2017
Location: Behind you!
Posted: 6th Jul 2017 12:41
I just tested your .exe and I don't see any flashing, all looks fine (using windows 7), maybe a graphics driver issue? are you all up to date?


PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 6th Jul 2017 13:28
it looks fine here to, Windows 10
Chara Bill
7
Years of Service
User Offline
Joined: 6th Apr 2017
Location:
Posted: 6th Jul 2017 16:06
Hm. I think different machines show different results...
Chara Bill
7
Years of Service
User Offline
Joined: 6th Apr 2017
Location:
Posted: 6th Jul 2017 16:40
Okay... And here I also decided to upload my WIP major project. Do the edges shake here, look flashy or somehow unusual on your machines? Because on my machine all the sprites shake when I move the character...

Attachments

Login to view attachments
Supertino
7
Years of Service
User Offline
Joined: 22nd Jun 2017
Location: Behind you!
Posted: 6th Jul 2017 16:44
All looks rock solid to me, no shinny edges or stuttering of any kind, nothing looks out of place or wrong.
Chara Bill
7
Years of Service
User Offline
Joined: 6th Apr 2017
Location:
Posted: 6th Jul 2017 16:45
Maybe it really does depend on videocard somehow...
Chara Bill
7
Years of Service
User Offline
Joined: 6th Apr 2017
Location:
Posted: 6th Jul 2017 17:14
Anyway, Windows said my drivers are up-to-date.
Supertino
7
Years of Service
User Offline
Joined: 22nd Jun 2017
Location: Behind you!
Posted: 6th Jul 2017 18:35
As a double check I also just tried on my home PC (windows 10) and all is fine here too,

Work PC: Windows 7, i3 cpu, intel graphics, 1080p resolution

Home PC: Windows 10, i5 cpu, GTX 1070 graphics, 1440p resolution

If you have a discrete graphics id recommend heading over to Nvidia or AMD sites for the latest drivers and not rely on windows.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 6th Jul 2017 23:01 Edited at: 6th Jul 2017 23:36
It does blink for me (maybe it's my name haha). if you repeatedly hit the left right arrows you'll see it (windows 10 here)
Maybe try SetGenerateMipmaps( 1 ) at the start of your program
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 7th Jul 2017 01:52
How about capturing a video or something and uploading to youtube?
Chara Bill
7
Years of Service
User Offline
Joined: 6th Apr 2017
Location:
Posted: 7th Jul 2017 08:03 Edited at: 7th Jul 2017 08:06
nz0 wrote: "How about capturing a video or something and uploading to youtube?"

Yeah, here we go...

My notebook:
https://www.youtube.com/watch?v=-XzH51zWInM&feature=youtu.be - test project
https://www.youtube.com/watch?v=b7zf4FsriYE&feature=youtu.be - major project

My work PC:
https://www.youtube.com/watch?v=dbzn7NZDwpc&feature=youtu.be - test project
https://www.youtube.com/watch?v=yTi0kIqr_Oc&feature=youtu.be - major project

blink0k wrote: "Maybe try SetGenerateMipmaps( 1 ) at the start of your program"

I'll try it, thank you.
Supertino
7
Years of Service
User Offline
Joined: 22nd Jun 2017
Location: Behind you!
Posted: 7th Jul 2017 08:39 Edited at: 7th Jul 2017 08:48
hum, I don't see any issue with either video (maybe the 720p and compression hides it)?! there might be a slight shimmering but I think that's just scrolling pixels that are larger than native pixels (sub-pixel shimmering I think its call), are you using Integers or Floats with your scrolling x and y values? Maybe try and caste them down to Integers if you're floats.

David,
Chara Bill
7
Years of Service
User Offline
Joined: 6th Apr 2017
Location:
Posted: 7th Jul 2017 09:21 Edited at: 7th Jul 2017 09:24
I'll try to demonstrate it more clearly.

1.


2.


See a thin gap between bridge and ground? It appears and disappears depending on our moving.

Here we go further...

3. Original sprite of the room. All the cracks are sole-colored.


4. A screenshot of the room in program:


See? The cracks have something similar to shades. Completely not sole-colored.
Supertino
7
Years of Service
User Offline
Joined: 22nd Jun 2017
Location: Behind you!
Posted: 7th Jul 2017 09:46
oh I see, looks like the images are being unintentially mipmapped (filtered)

Try setting using;



On any image you load.
Chara Bill
7
Years of Service
User Offline
Joined: 6th Apr 2017
Location:
Posted: 7th Jul 2017 10:06 Edited at: 7th Jul 2017 10:18
Supertino wrote: "Try setting using;"

So, I tried to apply this to the room (I'm using Tier 2 if it matters):


I've tried it several times on different machines, I guess it's still the same.

Attachments

Login to view attachments
Supertino
7
Years of Service
User Offline
Joined: 22nd Jun 2017
Location: Behind you!
Posted: 7th Jul 2017 10:26 Edited at: 7th Jul 2017 10:28
If it helps this is a screenshots @ 300% from your test project.


The background looks good but the character is blurred. Is the character being scaled?

This is a screen shot from full project @ 300%


All looks blurred.

I'd look into what you're doing differently for the background on each.
Chara Bill
7
Years of Service
User Offline
Joined: 6th Apr 2017
Location:
Posted: 7th Jul 2017 10:53
Supertino wrote: "The background looks good but the character is blurred."

Hm... I tried to zoom the test project and it has shades too...

Supertino wrote: "Is the character being scaled?"

Yes, scale x and scale y are both equal to 2, in both projects.
Chara Bill
7
Years of Service
User Offline
Joined: 6th Apr 2017
Location:
Posted: 7th Jul 2017 11:36 Edited at: 7th Jul 2017 12:03
Here comes a screenshot of the test project.
Oh wait. I think it depends on what application we use for zooming. For example, when I use Magnifier or Windows Photo Viewer, it has shades. When I look at it in IrfanView, everything seems to be okay. Even in the main project. Strange.
I think we might be on wrong way.

Attachments

Login to view attachments
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 7th Jul 2017 19:40
I opened that last one in Pro Motion NG, it has shades there.
13/0

Attachments

Login to view attachments
Chara Bill
7
Years of Service
User Offline
Joined: 6th Apr 2017
Location:
Posted: 7th Jul 2017 20:31 Edited at: 7th Jul 2017 20:53
Are there any ideas where are those shades coming from?
Because I have a feeling I've run out of them.
I even tried to disable everything but room sprite and camera.
This is everything that happens to the room:

And I just move my camera and... still see these shady/flashing/shaking edges.
My virtual resolution is equal to the window's size.
Completely no idea.
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 7th Jul 2017 21:16
If this is 2D sprites try using a Floor() around your x and y when positioning camera and / or sprites.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 8th Jul 2017 14:57 Edited at: 7th Aug 2017 15:36
I remember a command for this try SetSpriteSnap() on it

Using AGKv2 Tier1
Chara Bill
7
Years of Service
User Offline
Joined: 6th Apr 2017
Location:
Posted: 10th Jul 2017 21:38
janbo wrote: "I remember a command for this try SetSpriteSnap() on it"

Yes, thanks, it did help! But unfortunatelly there's a side-effect: this function makes the whole sprite shake by a pixel...
But as for flashing edges, it did help, thanks a lot! Are there any ideas what can I do with the side-effect?
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 10th Jul 2017 22:57
Test the simple way of just using Floor(x), Floor(y) when positioning camera. It could be the built in PixelSnap function is rounding instead of using floor. No idea.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
Chara Bill
7
Years of Service
User Offline
Joined: 6th Apr 2017
Location:
Posted: 7th Aug 2017 02:11
GarBenjamin wrote: "Test the simple way of just using Floor(x), Floor(y) when positioning camera."

It's gotten really better, but the edges still shake a little. It's not as terrible looking as it was without Floor(), but the problem still isn't completely solved.
janbo wrote: "I remember a command for this try SetSpriteSnap() on it"

It helps with the edges, but also makes the sprites shake by a pixel themselves, ending up looking even worse.
Chara Bill
7
Years of Service
User Offline
Joined: 6th Apr 2017
Location:
Posted: 7th Aug 2017 03:02
Also, I noticed that edges shake A LOT more when virtual resolution is higher than the window size. Maybe it could give somebody a clue about what's happening and how to fix it...
Chara Bill
7
Years of Service
User Offline
Joined: 6th Apr 2017
Location:
Posted: 7th Aug 2017 22:34 Edited at: 7th Aug 2017 22:39
Hello once again!
So, now I tried to make my program as illustrative as possible.
Here we have 3 modes: where the camera position coordinates are Round()-ed, Floor()-ed or left as they are. Press Z to switch these modes.
And also we have 4 available resolutions: 1280 x 720, 1366 x 768, 1600 x 900 and 1920 x 1080 - press X to switch them.
The size of the window is 1280 x 720, so any different virtual resolution will cause scalling.

As for me, I'd say that edges look better in Nothing mode in resolutions 1280 x 720 and 1366 x 768, and in Round() or Floor() modes in resolutions 1600 x 900 and 1920 x 1080.
Hope it will give any of you ideas!

Attachments

Login to view attachments
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 7th Aug 2017 22:42
Quote: "The cracks have something similar to shades. Completely not sole-colored."


Quote: "makes the sprites shake by a pixel themselves, ending up looking even worse"


I think you have to have either one or the other. I believe it's all down to how you want to cope with a sprite pixel effectively half way between two screen pixels. I've noticed this problem is exacerbated when sprites are moving relatively slowly.

However, I think the problem is one of perception rather than an actually show stopper. I ran the tier one demo you uploaded on your original post and didn't see any issue. I saw the shading as more of a fading but nothing unexpected, but I'm wondering if I only noticed it because you pointed it out and we're all now looking at this like a scientist with a microscope.

I believe the reason the "shading" is noticeable is that the cracks are much lighter than the black background so shows up as a blur during movement. I didn't notice anything in the lighter areas of the map where the colours are more similar to each other but looking at your screen grabs from you're post on the 7th July you can definitely see the same kind of "shading", it's just less prominent.

Quote: "Also, I noticed that edges shake A LOT more when virtual resolution is higher than the window size."


I've had this issue before, I get smoother movement if the virtual resolution is lower than the device screen resolution but you're not going to be in control of what device the player is going to be using, especially if you plan to have this on mobile devices.

My general feeling on this is that you're probably driving yourself crazy trying to solve this. I'm guessing that there's more to your game than scrutinizing the background for graphical oddities and that the players are going to simply go through this level and not even notice.
Hover Car Race Challenge! - available now on Google Play
Invaders of the 29th Dimension - available now on Google Play
Find me on indieDB
Chara Bill
7
Years of Service
User Offline
Joined: 6th Apr 2017
Location:
Posted: 8th Aug 2017 18:20 Edited at: 8th Aug 2017 18:29
29 games wrote: "I believe it's all down to how you want to cope with a sprite pixel effectively half way between two screen pixels."

29 games wrote: "I believe the reason the "shading" is noticeable is that the cracks are much lighter than the black background so shows up as a blur during movement."

It's not only seen during movement.
For example, we set our mode to Nothing and our resolution to 1280 x 720 (in the program from the previous post).

Position A (the character's not moving): see the screenshot 1 from the archive I'm attaching.

Position B (the character's not moving): see the screenshot 2 from the archive I'm attaching.

The edges' brightness is different now. And not during the movement. So, why have it changed?

29 games wrote: "My general feeling on this is that you're probably driving yourself crazy trying to solve this. I'm guessing that there's more to your game than scrutinizing the background for graphical oddities and that the players are going to simply go through this level and not even notice."

People, whom I give my program to test, notice it and find it disturbing.

Attachments

Login to view attachments
Chara Bill
7
Years of Service
User Offline
Joined: 6th Apr 2017
Location:
Posted: 15th Aug 2017 13:36
Okay, it's me again.
What about the post above - I fugured out why it happens:

Chara Bill wrote: "For example, we set our mode to Nothing and our resolution to 1280 x 720 (in the program from the previous post).

Position A (the character's not moving): see the screenshot 1 from the archive I'm attaching.

Position B (the character's not moving): see the screenshot 2 from the archive I'm attaching.

The edges' brightness is different now. And not during the movement. So, why have it changed?"


The point is, my character's speed here is equal to 1.5, and the coordinates weren't being rounded - resulting in the camera stopping half-way through scrolling pixels. For example, the coordinates are: 2; 3.5; 5; 6.5 - and so on. As we can see, some of the coordinates here would be integers, while the others would be fractional.

So, I think it could explain the shimmering in the example provided.

BUT!

...Well guys, I've encountered the same problem while the coordinates were being rounded as well (I used Floor)!

I'm attaching a new archive with two screenshots making my point clear (at least, I hope it will be clear now). See the difference between the edges in two screenshots? For some reason, pixels are rearranging - not only during the movement itself (it's highly important!) but when the character just changes their position.
The camera coordinates are both integers now (I've illustrated in pos1.png where they can be seen).
How do you reach this result? Set the resolution equal to 1920x1080 (press X to switch the resolution) and set the "Floor()"-ing of the camera coordinates (press Z to switch the modes, it should print "agk::Floor() is used").

I'm attaching this version of program as well, so everyone can test it and see this issue by themself.

Also, the sprite of the room has been slightly changed from the previous time.

I think, it most likely looks like an AppGameKit bug? I guess, I have no more to tell you now. Also, I have no idea what else can I do, so... if you can come up with something, any help would be highly appreciated.

Of course, I can just give up on solving this problem (and to be honest, I'm getting tired with trying to solve this edges-shimmering issue) and move forward, but still, I don't think those rearranging-by-themselves pixels are something good and not to be solved.

So once again, if somebody helped with this, it would be nice. Not trying to be annoying (even if I already am...).

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-22 20:38:05
Your offset time is: 2024-11-22 20:38:05