Skip to main content
gamedev.net
🔒 Locked

High frequency flicker?

Started by MarkS 11 replies 2.5k views
Original Post
MarkS
MarkS
I have been having an issue with my tile engine and I am quite perplexed. I am using a double-buffered OpenGL context and VBOs. When I scroll around the tile map, I see what I can only describe as a high frequency flicker. Basically, the frame is drawn in full, then a near instantaneous frame of black and then the next frame. this appears to be happening at or near the screen refresh rate. I have tried this with v-sync on and off with the same effect. I AM NOT seeing tearing! The frame is blitted to the screen in full. So long as the tile map is not being scrolled, the flicker does not happen.

I would think that this may be a driver issue and the context is not actually doubled buffered and so I am seeing the driver clear the screen, EXCEPT for the fact that my clear color is a shade of light blue and not black. My other thought is that this may be a form of ghosting known to plague LCD screens. I am willing to bet this is not anything in my code, but a driver or hardware issue.

My set up is a nVidia GTX 260 with the latest drivers (maybe one or two generations back) and an HP 23" LCD monitor on Windows 7 x64.

Does anyone know what I'm talking about? Has anyone else experienced something similar?
No, I am not a professional programmer. I'm just a hobbyist having fun...
MarkS
MarkS
Oops... I meant to post this in the OpenGL forum. Can someone move this please?
No, I am not a professional programmer. I'm just a hobbyist having fun...
MarkS
MarkS
Looking at the problem again, it isn't a black flicker, but a very light colored (but not white) flicker. I'm testing it on a laptop with an AMD graphics card and I see the same thing.

I am getting very high frame rates. Under Windows 7 on my home computer, I see around 500 FPS with v-sync turned off. On this laptop with Windows 7 x32, I am seeing around 170 FPS. This is half of what I am seeing on XP (seems pretty typical). With v-sync on, the frame rate never drops below the refresh rate. I am using QueryPerformanceXXXX for frame rate calculations. I am fairly sure they are accurate.
No, I am not a professional programmer. I'm just a hobbyist having fun...
MarkS
MarkS
Thank you!

OK, I don't think this is a hardware or OpenGL issue after all. I'm beginning to think this may be an aliasing issue. I remember reading a vague reference to this in the book "Graphics Programming Principles and Practice". I cannot remember all of what I read, but I do recall that aliasing issues can arise when the image has too sharp of a change in intensity between pixels. This is definitely the case.

One of the tiles is a hedge where the texture it a random combination of various shades of green with some black thrown in for good measure. Only tiles with this texture are flashing. Since I am using a tile sheet, I can rule out problems with the texture loading.

Oh well... The tile images that I am using were made by my dad when he created the original version of this game. They are not bad for programmer art, but I was going to change them out in the future anyway. I want 64x64 pixel tiles due to the higher resolution of monitors these days and the fact that the game will run full screen. This way less of the tile map is visible at once. I guess I need to up the time table for image creation.

[Edited by - maspeir on June 29, 2010 2:09:37 PM]
No, I am not a professional programmer. I'm just a hobbyist having fun...
Atrix256
Atrix256
Are your tiles all stored in a single bitmap (or do you have multiple tiles in the same files?)

If so, could the flicker of this tile be due to you seeing the starting edge of a neighboring tile?
MarkS
MarkS
Quote:
Original post by Atrix256
Are your tiles all stored in a single bitmap (or do you have multiple tiles in the same files?)

If so, could the flicker of this tile be due to you seeing the starting edge of a neighboring tile?


It is a single bitmap, but I am not seeing the edges of the neighboring tiles. This flickering is restricted to one tile image out of nearly a dozen and it is the tile image with the greatest frequency changes. The reason I haven't noticed this before is that the tile map I'm using has a great deal of these tiles and it is impossible to scroll to any part of the tile map and not have them visible on screen. Because of this, I was mistakenly thinking that the whole map was flickering.

After posting this thread, I did some more careful observations while trying to eliminate any possible source of the flicker. It was then that I noticed that the issue was restricted to one image.

I believe the correct term for this issue is "temporal aliasing". I'm 1000 miles from home on business and I didn't think to bring that book, so it will be Monday before I can find that reference.
No, I am not a professional programmer. I'm just a hobbyist having fun...
Ashaman73
Ashaman73
Quote:
Original post by maspeir
I have been having an issue with my tile engine and I am quite perplexed. I am using a double-buffered OpenGL context and VBOs. When I scroll around the tile map, I see what I can only describe as a high frequency flicker. Basically, the frame is drawn in full, then a near instantaneous frame of black and then the next frame. this appears to be happening at or near the screen refresh rate. I have tried this with v-sync on and off with the same effect. I AM NOT seeing tearing! The frame is blitted to the screen in full. So long as the tile map is not being scrolled, the flicker does not happen.

I would think that this may be a driver issue and the context is not actually doubled buffered and so I am seeing the driver clear the screen, EXCEPT for the fact that my clear color is a shade of light blue and not black. My other thought is that this may be a form of ghosting known to plague LCD screens. I am willing to bet this is not anything in my code, but a driver or hardware issue.

My set up is a nVidia GTX 260 with the latest drivers (maybe one or two generations back) and an HP 23" LCD monitor on Windows 7 x64.

Does anyone know what I'm talking about? Has anyone else experienced something similar?

When you turn on v-sync, use double-buffering and your fps are around 60fps and still encounter some flickering, I would bet that is has something to do with texture filtering.

When you build a 2d engine and use nearest filtering without mipmapping try to switch to linear filtering. This will blur the image somewhat, but check if the flickering is gone.
MarkS
MarkS
This is a form of aliasing. The flickering is only perceived. Filtering (and thus antialiasing) will not help unless I scale the texture and I do not want to do that. Since the texture is being blitted to the screen in a 1:1 ratio, only nearest filtering is done, even with GL_LINEAR set.

I changed the offending tile image to a green square and the problem stopped. I need an image with fewer changes in frequency.
No, I am not a professional programmer. I'm just a hobbyist having fun...
Ashaman73
Ashaman73
Quote:
Original post by maspeir
This is a form of aliasing. The flickering is only perceived. Filtering (and thus antialiasing) will not help unless I scale the texture and I do not want to do that. Since the texture is being blitted to the screen in a 1:1 ratio, only nearest filtering is done, even with GL_LINEAR set.

My attempt to get a 1:1 rendering of gui elements failed. The reason was that some pixel rows/columns were missing where other rows/columns were duplicated. I used GL_NEAREST too, but it might be an issue with the used technique (orthogonal projection + standard quad rendering). To track this kind of error, I had to take screenshots and had to upscale them in a paint tool, but then they were clearly visible. GL_LINEAR help me to get rid of the artifacts, but it tends to blur the image a little bit.

An other test would be to make a black'n'white checkboard tile with each box of one pixel size.
MarkS
MarkS
I am really getting a 1:1 rendering. Just to be sure, I did as you suggested and took a screen shot. Everything is pixel perfect, at screen resolution and scaled.

The images I am using were originally designed for an 8-bit monitor. As such, there is a certain amount of dithering going on. For instance, one of the tiles looks like floor tiles. To get a brown color, my father used alternating green and red pixels in a 50% pattern. I recently changed this so that a solid color is used instead of the dither. This tile is the most common in the tile map as it is floor tile. With the dither, the whole image flickers. With my changes, there is no flicker.

I do not want to sound argumentative, but this is an aliasing issue. I could site that reference if I were home and I will do so when I get home Monday. Hopefully, someone can step in and better explain what is going on.

Here is the test app:
http://rapidshare.com/files/404074494/Gardener.zip.html
In the main directory is a file "Tiles.tga". This is the old tile set. The file by the same name in the Data directory has the updated floor tiles. Replace the file in the Data directory with the one in the main directory to see the difference.
No, I am not a professional programmer. I'm just a hobbyist having fun...
Decrius
Decrius
Perhaps slightly off-topic, but 500 FPS isn't that high. I get 5000 FPS when drawing nothing, and 3500 FPS when drawing menu and stuff. There is no need to bring it down to 60 FPS for me, so I'll just leave it at full speed.
[size="2"]SignatureShuffle: [size="2"]Random signature images on fora
xelanoimis
xelanoimis
Hi there,

I experienced some flickering with games doing scrolling, made with my DizzyAGE engine. These games use retro graphics with few clean colors and display sprites at 1:1 (pixel perfect) or in multiple 2:1 etc. So no anti-aliasing or blurring.

After some tests I concluded it's a limitation of the LCD monitor. Like when you scroll a page of texts. Depending on how the scrolling works the effect can be more or less visible. For example when I scroll with 4 pixels step the flickering is more visible than if I scroll with some acceleration down to 1 pixel step when close to target position.

Depending on monitor I suppose, some players find it difficult to play. I wonder if a 100Hz monitor is free of this issue. Obviously a CRT monitor works fine.

VSync doesn't help, I also have lots of fps and I tried both DirectX and OpenGL.

Alex

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.