GLBasic forum

Main forum => GLBasic - en => Topic started by: S.O.P.M. on 2013-Apr-29

Title: 2D Lightning & Kerning
Post by: S.O.P.M. 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.
Title: Re: 2D Lightning & Kerning
Post by: fivesprites on 2013-Apr-29
For the alpha issue, try using:

ALPHATESTING 0.001


//Andy
Title: Re: 2D Lightning & Kerning
Post by: S.O.P.M. on 2013-Apr-29
Omg this works very well, thank you so much! I did not know about the ALPHATESTING command O_O
Title: Re: 2D Lightning & Kerning
Post by: fivesprites on 2013-Apr-29
More than welcome :)

//Andy
Title: Re: 2D Lightning & Kerning
Post by: Moru 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 (http://bjornrosenthal.eu/bitmap-font-routines/157/)
Title: Re: 2D Lightning & Kerning
Post by: S.O.P.M. 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
Title: Re: 2D Lightning & Kerning
Post by: Albert on 2013-Apr-30
With ALPHATEST it looks quite cool!
Title: Re: 2D Lightning & Kerning
Post by: Moru 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.
Title: Re: 2D Lightning & Kerning
Post by: S.O.P.M. 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?