Hi *
Now this is a somewhat late reply, but anyway…
Considering all that buzz about smooth scrolling in the last time, I
decided to try and roll my own in a pet project of mine. Turns out that
the difference of subpixel accurate rendering is much greater than I
expected.
Actually, I was a bit surprized myself that it had such great effect even
without sync’ed flips, and that it reduces the inevitable tearing on such
setups as an extra bonus. Indeed, it takes h/w acceleration, but it does
make a difference, and not just to rendering speed.
In fact, I was quite confident with what I had before, until
I first ran the game real smooth. So in the end, you managed to
convince me ![:slight_smile: :slight_smile:](https://discourse.libsdl.org/images/emoji/apple/slight_smile.png?v=12)
Good!
My eyes are starting to hurt from all this tearing and
jittering in “modern” games…
Anyway, I was curious whether we ended up with the same solutions and
downloaded smoothscroll. And the comparison turned out with interesting
results.
smoothscroll uses the pretty straightforward method of just rendering
all tiles as quads, with float coordinates. Fair enough, and that’s
what I had at first.
Yeah, that’s the easy solution. I didn’t want to use any more
sophisticated “tricks”, as that would make the code a lot harder to
understand.
Now what I’m working at is kind of a Raptor clone, and the tiles can be
rather bright in places. I got a rather annoying flicker, or shimmer,
where the tiles met.
Yeah, you can’t just merge tiles together in any way you like. Look
carefully at the “tile palette” texture of my demo, and how the tiles are
used. If you use the map editor to make a map that breaks the rules,
you’ll see the very same effect. (It’s not really a matter of brightness
- although the bigger the “incompatibility” between adjacent tiles, the
more obvious the flicker.)
The problem is that the pixels around each tile matter, so it’s
important how tiles are placed on the tile palette textures. If you check
the TODO file (Unix end-of-line format - use something more sophisticated
than Notepad if you’re on Windows), there’s some info on this, and IIRC,
I describe one or two approaches to deal with it.
Maybe this is what someone else described earlier
in this thread, I don’t know.
No, that’s a different problem, which is caused by the fact that texture
interpolation isn’t always as gamma correct as one would want it to be,
and more commonly, that card/monitor combos usually aren’t gamma
calibrated. You’ll see that effect even if you’re just scrolling a
single, huge texture, and there will be more of it if there are small
details and/or bright/sharp transients in the image.
Anyway, what I finally ended up with is, well, “interesting”. I added a
1 pixel transparent border around the tile graphics inside the texture.
Then, I render the tile quads 1 pixel wider than they actually should
be. This means that the tiles are actually overlapping each other, but
the overlapping parts are transparent. Now this flickering/shimmering
effect is gone.
Right, that’s the first solution I considered when I first started
playing with OpenGL and 2D - but that way requires that the tiles are
completely rendered with alpha blending. No big deal with a modern 3D
card, probably, but I’d rather use that power for other stuff. ![:slight_smile: :slight_smile:](https://discourse.libsdl.org/images/emoji/apple/slight_smile.png?v=12)
I guess one can’t see the effect in smoothscroll because the tile edges
are basically black.
Well, almost! ![:slight_smile: :slight_smile:](https://discourse.libsdl.org/images/emoji/apple/slight_smile.png?v=12)
The blue “construction” tiles have everything but black edges, BUT,
they’re drawn to fit together, on the map (of course) as well as on the
tile palette; the latter being the important and rather non-standard
part. If you look at the tile palette, you’ll notice that every single
tile is placed so that adjacent tiles provide the border pixels that are
necessary to get interpolation right.
//David Olofson — Programmer, Reologica Instruments AB
.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |
-------------------------------------> http://olofson.net -'On Friday 29 March 2002 19:51, Nicolai Haehnle wrote: