ZFGC

Resources => Coding => Topic started by: MG-Zero on November 12, 2009, 06:21:01 pm

Title: Image Tearing
Post by: MG-Zero on November 12, 2009, 06:21:01 pm
I've got some..interesting image tearing problems going with the Harvest Engine.  I've ran it on multiple computers and get different results on every one of them (distortion, tiles splitting up).

Are there any articles out there I can look through the deal with this?  This is openGL btw.
Title: Re: Image Tearing
Post by: Wasabi on November 13, 2009, 06:21:50 am
vsync?
Title: Re: Image Tearing
Post by: Windy on November 13, 2009, 10:20:17 am
Edge clamping enabled?
Title: Re: Image Tearing
Post by: MG-Zero on November 13, 2009, 03:00:08 pm
vsync?

Tried with vsync on and off, doesn't change anything.

Quote
Edge clamping enabled?
uhh...details nao?
Title: Re: Image Tearing
Post by: TheDarkJay on November 13, 2009, 05:43:16 pm
Screenshots of what you're talking about may help somewhat =P (So would the rendering code but I'm not gonna ask for that because if you didn't give it originally I assume you don't want to ;P)
Title: Re: Image Tearing
Post by: MG-Zero on November 21, 2009, 04:01:37 pm
Sorry, took forever to get this up.

As you see, the top of the tree is separated from the bottom when the screen scrolls.  The top of the tree is on a separate layer from the bottom.  My rendering code looks like this..

Code: [Select]
for (int i = 0; i < HMD.layerCount; i++)
{
                for (int j = 0; j < 2500; j++)
{
//draw the tiles skipping -1s
if (HMD.layers[i].getTileNum(j) != -1)
{
HVSTGFX::createTilePNG(HMD.layers[i].getTileNum(j), tileCoordX[j], tileCoordY[j], HMD.tileSet);
}
}
}
Title: Re: Image Tearing
Post by: TheDarkJay on November 21, 2009, 04:39:46 pm
You sure the widths and heights of the images are right? If they're like 1 pixel off things can get a bit weird...
Title: Re: Image Tearing
Post by: MG-Zero on November 21, 2009, 04:56:43 pm
Yes, tiles are all 16x16.  The tearing only occurs when the screen scrolls.
Title: Re: Image Tearing
Post by: Zaeranos on November 21, 2009, 05:15:48 pm
Hmm, is the rendering done in a separate thread from the game loop?

And does the top layer move down when scrolling up, left when scrolling right and right when scrolling left.
Title: Re: Image Tearing
Post by: Xiphirx on November 21, 2009, 05:20:23 pm
Well, check your second layer rendering. From that screenshot it seems that it only happens on the top part of the tress...
Title: Re: Image Tearing
Post by: Infinitus on November 21, 2009, 05:20:32 pm
If the rendering coordinates are in float point, convert them to integers. I had the same problem a while back, that fixs it :3
Title: Re: Image Tearing
Post by: MG-Zero on November 21, 2009, 05:48:08 pm
Hmm, is the rendering done in a separate thread from the game loop?

And does the top layer move down when scrolling up, left when scrolling right and right when scrolling left.

No, it's all the same thread.

And yes, they move in all directions.

Quote
If the rendering coordinates are in float point, convert them to integers. I had the same problem a while back, that fixs it :3
Yea, but then the coordinates get all screwed up D=

EDIT: ahh..that's interesting.  The tearing occurs on the layer that the player is being rendered on..gonna take a look through the rest of the map creation and see what's going on here.
Title: Re: Image Tearing
Post by: Zaeranos on November 21, 2009, 06:46:55 pm
Hmm, is the rendering done in a separate thread from the game loop?

And does the top layer move down when scrolling up, left when scrolling right and right when scrolling left.

No, it's all the same thread.

And yes, they move in all directions.
Ah well, if it was in a different thread, than maybe it would be possible that the viewport gets updated after the bottom layer was rendered.  But if it is in the same thread, then I don't think that is the problem.
Title: Re: Image Tearing
Post by: Windy on November 21, 2009, 07:41:40 pm
How are you executing your games logic?
You're not doing it all in the same loop are you?
Title: Re: Image Tearing
Post by: MG-Zero on November 21, 2009, 07:56:09 pm
How are you executing your games logic?
You're not doing it all in the same loop are you?

You're referring to the main loop, I assume?
Title: Re: Image Tearing
Post by: Zaeranos on November 21, 2009, 09:43:31 pm
How are you executing your games logic?
You're not doing it all in the same loop are you?

You're referring to the main loop, I assume?
If I am guessing right, I think Windy means. Do you update one layer, then render it and then go to next layer update that and render it and so on till you get to last layer.

That could explain why the top layer seems to shift in the opposite direction of the scrolling and why the tearing takes place in the layer that Link is on, because the viewport is updated there.

That is how you can make the multithreaded image tear in a single thread. The piece of code you gave suggests you didn't though.
Title: Re: Image Tearing
Post by: MG-Zero on November 22, 2009, 04:42:45 pm
The way I'm executing the player code may relate to that.  Alright, that shouldn't be too hard to fix.  I can just use the player reference I have in the main.cpp to call the player from the proper layer after everything is drawn.

Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved