Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Valve's vector text rendering method  (Read 6004 times)
0 Members and 1 Guest are viewing this topic.
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Posted 2008-04-11 09:56:20 »

Valve have a whole bunch of handy papers on their site, one in particular caught my eye Improved Alpha Tested Magnification. I know we've had discussions here before about various methods of doing scalable text, and this seems like a nice new approach.

Has anyone tried anything similar to this? It would require a proper GLSL shader to do anti-aliased text, but a simpler one than the previous approaches mentioned (which I'd find, but the forum search is  broken). Plus I think you could fall back to just alpha testing for shader-less cards (although you'd get no antialiasing). Plus the various effects like outlines, glows and drop shadows would be really useful I think.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #1 - Posted 2008-04-11 10:07:47 »

And the original curve/vector rendering thread by Spasi is here: http://www.java-gaming.org/forums/index.php?topic=14778.0

Btw I don't think I've seen him post recently, is he still around? Huh

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Spasi
« Reply #2 - Posted 2008-04-11 13:29:51 »

Yeah, I'm still here. Haven't had much to contribute lately, non-gaming related work has taken over. Sad

That's an interesting technique tbh. Despite the disadvantages, the ease of implementation and the ability to use it on very old GPUs while maintaning very good quality, makes it a very good alternative to my approach.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #3 - Posted 2008-04-11 13:36:26 »

Yeah, I always prefer stuff that can work on older GPUs without too many changes - I've only got one pair of hands so I don't like having to maintain separate rendering paths for different hardware.

I'm not sure how good the quality would be for smaller text compared to an unscaled bitmap font. I suspect the lack of antialiasing when using the alpha-test fallback would make it slightly worse (unless theres another non-GLSL fallback path I missed). It might be best to have regular bitmap fonts for small text, and use this method for larger text (say, anything over 16 or 24 pt).

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #4 - Posted 2008-04-12 14:46:19 »

I've managed to hack together something which does the basic image processing, and the results are impressive.

This is the original, high resolution input image (300x300x1):

<img src="http://members.gamedev.net/tang/Images/a_300x300.png"/>

This produces the following low-res distance map (37x37)

<img src="http://members.gamedev.net/tang/Images/DistanceMap.png"/>

And when drawn in game, with bilinear filtering and an alpha test of 0.5f, we get rather good quality output. This is drawn with a scale factor of 16, so we're actually drawing it twice as big as the original input image, but with only one eighth of the memory.

<img src="http://members.gamedev.net/tang/Images/ImprovedAlphaScale1.png"/>

I'm not sure what's causing the artifacts at the bottom of the output - it might be that my preprocessing isn't quite correct, or I should be using a higher resolution input. And the preprocessing is very slow, so I'm going to try and fix that first, then see what the results are with even higher input images.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #5 - Posted 2008-04-13 23:56:13 »

I can't believe how good the results are from this:

<img src="http://members.gamedev.net/tang/Images/ImprovedAlphaScaleOutlined.png"/>

It takes only a single 32x32 sprite on a single quad and a simple (~25 line) shader to render that. Grin

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline ryanm

Senior Duke


Projects: 1
Exp: 15 years


Used to be bleb


« Reply #6 - Posted 2008-04-14 00:43:27 »

That is pretty sweet, bordering on witchcraft. Who'd have thought there's enough information in 32x32 pixels to recreate that fidelity? And in realtime? And with an easy fallback rendering path? And with easy outline/drop shadows?

Do I smell a nice little font library in the works?
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #7 - Posted 2008-04-14 05:54:13 »

How did you fix the artifacts at the bottom?

弾幕 ☆ @mahonnaiseblog
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #8 - Posted 2008-04-14 08:38:10 »

How did you fix the artifacts at the bottom?

I switched to using a higher resolution input image (1024x1024 instead of 300x300), with a slightly larger amount of black around the edges of the shape and it went away. Given that I'm using a black and white image to approximate a vector shape I'm not surprised it needs a high res input for consistant results.

Do I smell a nice little font library in the works?

A very good question. I'm currently agonising over whether to write a proper font rendering library with this, but it's something of a dilemma. The quality and flexibility for people with shader-capable cards is great, but for shader-less people theres no antialiasing, which means small fonts look a bit rubbish. Whereas my current font stuff using sprites for each character gives antialiased results which look good on shader-less cards but doesn't scale well.

What kind of hardware do other people aim for at the moment? Pretty much all my current stuff works on GL1.1 so will work on anything, but frankly it's getting to be an annoying restriction - especially since GLSL capable cards have been out for five years now (a long time in graphics hardware).

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Tobias

Junior Duke


Projects: 1



« Reply #9 - Posted 2008-04-21 08:19:38 »

Very interesting.
Would you mind posting a screenshot of smaller text rendered with this method?

Mad Skills Motocross
Turborilla - independent game developer
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (46 views)
2014-10-17 03:59:02

Norakomi (37 views)
2014-10-16 15:22:06

Norakomi (28 views)
2014-10-16 15:20:20

lcass (32 views)
2014-10-15 16:18:58

TehJavaDev (62 views)
2014-10-14 00:39:48

TehJavaDev (62 views)
2014-10-14 00:35:47

TehJavaDev (52 views)
2014-10-14 00:32:37

BurntPizza (70 views)
2014-10-11 23:24:42

BurntPizza (40 views)
2014-10-11 23:10:45

BurntPizza (82 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!