Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
20 May, 2013, 08:31:02 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1]   Go Down
  Print  
Author Topic: Some scrolling grayscale issues... -  (Read 410 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
nxtboy III
LV8 Addict (Next: 1000)
********
Offline Offline

Last Login: 15 May, 2013, 02:00:51
Date Registered: 30 March, 2011, 22:57:58
Posts: 784


Topic starter
Total Post Ratings: +23

View Profile WWW
« on: 13 March, 2012, 14:45:45 »
0

Hi,
I have a game that is in 4-level grayscale. It also scrolls.
Here is some very super simple pseudo:


1
2
3
4
5
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
Logged

Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 06:42:06
Date Registered: 02 July, 2009, 06:38:05
Posts: 1679


Total Post Ratings: +492

View Profile
« Reply #1 on: 13 March, 2012, 22:19:02 »
0

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.
Logged
nxtboy III
LV8 Addict (Next: 1000)
********
Offline Offline

Last Login: 15 May, 2013, 02:00:51
Date Registered: 30 March, 2011, 22:57:58
Posts: 784


Topic starter
Total Post Ratings: +23

View Profile WWW
« Reply #2 on: 13 March, 2012, 23:26:01 »
0

Oh, cool! The "proper" way is too slow, but the "improper" way works! Thanks a lot! Cheesy
Except going up still looks weird...

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

Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 06:42:06
Date Registered: 02 July, 2009, 06:38:05
Posts: 1679


Total Post Ratings: +492

View Profile
« Reply #3 on: 14 March, 2012, 02:54:27 »
0

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: 14 March, 2012, 02:54:56 by Runer112 » Logged
nxtboy III
LV8 Addict (Next: 1000)
********
Offline Offline

Last Login: 15 May, 2013, 02:00:51
Date Registered: 30 March, 2011, 22:57:58
Posts: 784


Topic starter
Total Post Ratings: +23

View Profile WWW
« Reply #4 on: 14 March, 2012, 03:55:39 »
0

Ok. Smiley
Thanks for the help. Smiley Grin
Logged

DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 05:36:37
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50204


Total Post Ratings: +2611

View Profile WWW
« Reply #5 on: 14 March, 2012, 21:38:46 »
0

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.
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
nxtboy III
LV8 Addict (Next: 1000)
********
Offline Offline

Last Login: 15 May, 2013, 02:00:51
Date Registered: 30 March, 2011, 22:57:58
Posts: 784


Topic starter
Total Post Ratings: +23

View Profile WWW
« Reply #6 on: 15 March, 2012, 00:30:02 »
0

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: 15 March, 2012, 00:30:19 by nxtboy III » Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.2 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.