Author Topic: Some scrolling grayscale issues...  (Read 3238 times)

0 Members and 1 Guest are viewing this topic.

Offline nxtboy III

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 795
  • Rating: +26/-1
  • NXT!
    • View Profile
    • Program NXT
Some scrolling grayscale issues...
« on: March 13, 2012, 08:45:45 am »
Hi,
I have a game that is in 4-level grayscale. It also scrolls.
Here is some very super simple pseudo:

Code: [Select]
Game loop:
-Calculates stuff, moves character, etc
-Displays everything and uses stuff similar to pxl-test for collision, it draws the next frame out of 3 for 4-lvl grayscale
End game loop

So in my game, when the character moves right (map scrolls left), the grayscale looks really bad, because it is scrolling to the left. However, when it scrolls to the right (player moves left), the grayscale looks fine. How can I fix this?

I am using this routine for grayscale (example of light gray):

100
010
001

010
001
100

001
100
010

Thanks, and have a nice day,
nxtboy III

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Some scrolling grayscale issues...
« Reply #1 on: March 13, 2012, 04:19:02 pm »
That's because when you're scrolling the screen left, the image is following the shifting of the grayscale dithering mask, so grays get stuck on the same dither pattern for multiple frames. The "proper" way to fix this would be to display each frame three times, so every frame is displayed with all three dithering masks. This should look much nicer, but it would add a lot of time to each frame. The "improper" way to fix this would be to account for the amount the screen has scrolled when shifting the grayscale dithering mask between frames, so the image doesn't follow the mask. I would do this by shifting the grayscale mask right instead of left (or left twice) if the screen has scrolled one pixel to the left since the last frame.

Offline nxtboy III

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 795
  • Rating: +26/-1
  • NXT!
    • View Profile
    • Program NXT
Re: Some scrolling grayscale issues...
« Reply #2 on: March 13, 2012, 05:26:01 pm »
Oh, cool! The "proper" way is too slow, but the "improper" way works! Thanks a lot! :D
Except going up still looks weird...

Is there a way to fix the scrolling for going up?
« Last Edit: March 13, 2012, 07:11:07 pm by nxtboy III »

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Some scrolling grayscale issues...
« Reply #3 on: March 13, 2012, 08:54:27 pm »
Yeah, do the same thing for scrolling up as scrolling left. You may also have to account for scrolling in both directions at once, in which case I think you'd want down and right to rotate the mask right and all other diagonals to be the normal rotate left.
« Last Edit: March 13, 2012, 08:54:56 pm by Runer112 »

Offline nxtboy III

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 795
  • Rating: +26/-1
  • NXT!
    • View Profile
    • Program NXT
Re: Some scrolling grayscale issues...
« Reply #4 on: March 13, 2012, 09:55:39 pm »
Ok. :)
Thanks for the help. :) :thumbsup:

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Some scrolling grayscale issues...
« Reply #5 on: March 14, 2012, 03:38:46 pm »
Keep in mind that if you add up diagonal and vertical scrolling later, maybe calculating how much columns you scrolled might end up being a major hassle, so if you ever go that far, You might better go with the proper method Runer112 mentionned.

Offline nxtboy III

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 795
  • Rating: +26/-1
  • NXT!
    • View Profile
    • Program NXT
Re: Some scrolling grayscale issues...
« Reply #6 on: March 14, 2012, 06:30:02 pm »
Well, the proper way makes it go too slow, so I just flip the way the lines move in grayscale (Or I keep it on the same frame).
« Last Edit: March 14, 2012, 06:30:19 pm by nxtboy III »