Author Topic: 2D Lightning & Kerning  (Read 2430 times)

Offline S.O.P.M.

  • Prof. Inline
  • *****
  • Posts: 529
    • View Profile
2D Lightning & Kerning
« on: 2013-Apr-29 »
Hello guys,

I wonder how to make good light effects in a 2D game. Then I thought I can make a kind of mask for each light that has a gradient from completely transparent to non transparent pixels. The result you can see in the attached file (you can move the lights by mouse). It looks quite good for the first try but it seems that GLBasic doesn't use the entire transparency range. The gradient suddenly stops before the last very transparent pixels and so I have these annoying edges. It still doesn't look like a natural light. I could use several masks that can be combined to make various light shapes but I always have these edges. So anybody an idea for a workaround?

The second thing is the font kerning option. I know this was thematised before but I think this is still important to change. As you can see in this demo the lettering "Lightning Demo" doesn't look nice. That is because the font kerning option always uses a single pixel space between the letters. 1 pixel space looks good for small fonts which 1 or maybe 2 pixel thickness. But in this case it would be really helpful to just have the option to make the space bigger. I am sure this would be really easy and fast to implement. And yes, I know there's a workaround for this but it cannot use in every situation. So please Gernot, think about it!

Thanks,
S.O.P.M.
« Last Edit: 2013-Apr-29 by S.O.P.M. »
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

Offline fivesprites

  • Mr. Polyvector
  • ***
  • Posts: 101
    • View Profile
    • FiveSprites
Re: 2D Lightning & Kerning
« Reply #1 on: 2013-Apr-29 »
For the alpha issue, try using:

ALPHATESTING 0.001


//Andy

Offline S.O.P.M.

  • Prof. Inline
  • *****
  • Posts: 529
    • View Profile
Re: 2D Lightning & Kerning
« Reply #2 on: 2013-Apr-29 »
Omg this works very well, thank you so much! I did not know about the ALPHATESTING command O_O
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

Offline fivesprites

  • Mr. Polyvector
  • ***
  • Posts: 101
    • View Profile
    • FiveSprites
Re: 2D Lightning & Kerning
« Reply #3 on: 2013-Apr-29 »
More than welcome :)

//Andy

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1779
    • View Profile
    • Homepage
Re: 2D Lightning & Kerning
« Reply #4 on: 2013-Apr-29 »
The font kerning distance can be adjusted with the fontlibrary from PeeJay after some changes I did. Yes I finally put together a new homepage and I think I got the latest code there too... Let me know if anything breaks, haven't touched it in quite a while :-)

Bitmap font routines

Offline S.O.P.M.

  • Prof. Inline
  • *****
  • Posts: 529
    • View Profile
Re: 2D Lightning & Kerning
« Reply #5 on: 2013-Apr-30 »
Wow, that's some nice work. But I assume it could be too slow on mobile devices which I would like to code for. The DrawText Function processes every single char with GLBasic commands and I think this will become slow when printing too much text at a time. So I still want to request to have this implemented as standard. 0 = no kerning, X = kerning + additional pixel space
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

Offline Albert

  • Dr. Type
  • ****
  • Posts: 257
    • View Profile
    • Blog
Re: 2D Lightning & Kerning
« Reply #6 on: 2013-Apr-30 »
With ALPHATEST it looks quite cool!

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1779
    • View Profile
    • Homepage
Re: 2D Lightning & Kerning
« Reply #7 on: 2013-Apr-30 »
When using text in games, you print to an off-screen buffer. No need to print every letter each VBL. Just draw it once and then paste the image to the screen every frame.

Offline S.O.P.M.

  • Prof. Inline
  • *****
  • Posts: 529
    • View Profile
Re: 2D Lightning & Kerning
« Reply #8 on: 2013-May-01 »
Oh cool, so that's faster? I didn't consider this before, will give it a try as far as I understand right. With off-screen buffer you mean a virtual screen?
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium