Skip to main content.
October 24th, 2006

Subpixel of Hell

In 2000 the PC port of Final Fantasy VIII was released. I was in the team that ported it and I clearly remember an outstanding bug for which I damned myself. It was about artifacts coming out of inconsistent subpixel bias across different graphics cards with Direct3D
The game was shipped with that bug.. a couple of weeks later a guy from nVidia told us: “Oh that’s easy you just have to offset all pixels by 0.5″. Easy he said, but in fact when asked about the issue earlier he said something about some other developers doing a a simple test rendering and reading back the buffer to estimate the subpixel bias settings when starting the game.. yuck !!!

Six years later, I’m still struggling with subpixel bias. This time with DSharingu and OpenGL.
To render texture for 1:1 ration pixel display in OpenGL it’s suggested to offset rendering by 0.375 pixels. This looks good if bilinear filtering is disabled, otherwise textures come out blurred.
Also, on my ATI 9700 AIW Pro, to render properly a frame rect with a GL_LINE_LOOP I have to offset pixels by 0.5. If I don’t there is going to be a pixel missing from a corner. This changes with the 9200 SE that I have another computer, which still misses a pixel but on a different corner !
Things get even funnier when trying to draw a small X with a couple of lines. Pixels tend to be missing on either ned of the line depending on more than one variable, obviously including hardware and drivers..

..it’s a rasterization mess !

I’ve wasted a lot of time on this and I’m not sure how to settle it.
My main problem is about text rendering. I build my own texture for text at run-time. It’s fast and looks nice because I subsample myself Windows rendered text so that I can be sure that I have antialiased text. However this doesn’t support Japanese text. To do that I’d have to use a lot more texture memory and implement a Shift-JIS rendering routine.. which is not too hard, but not too funny either.

well well

Posted by Davide Pasca in Programming

This entry was posted on Tuesday, October 24th, 2006 at 1:23 am and is filed under Programming. You can follow any responses to this entry through the comments RSS 2.0 feed. You can leave a response, or trackback from your own site.

20 Responses to “Subpixel of Hell”

  1. Ragin' Lion says:

    KazGL, I’m not sure if this is the best way or not, but rather than using GL_LINE_LOOP to draw a quad, why not use GL_QUADS with glPolygonMode( GL_FRONT, GL_LINE ) set? I haven’t tried it myself, but maybe that might work better.

    A few years ago, for fun, I tried to make a menu system like that of Front Mission: Alternative and ran into that same (annoying) missing pixel nonsense. It’s wierd how one can get the accuracy one needs on consoles, but on the mighty PC …

    There’s probably ways to fix this problem … Afterall, OS X and other GUIs use OpenGL …

  2. Davide Pasca says:

    glPolygonMode( GL_FRONT, GL_LINE ) works ! I forgot to mention it 8)
    I found that by searching around the web.
    Seems to be the only reliable solution although not the cleanest one, because it brings quite a few state changes. Unless one draws all items in 2 passes.
    Another problem it doesn’t solve is when drawing plain lines. As for a cross mark used to symbolize the closure of a window.

    As for OS X.. I think in that case, because the OS relies on OpenGL, everything is forced to be consistent. I think Microsoft eventually did the same with subpixel in Direct3D, and it’s surely forcing things with Direct3D 10.

    OpenGL was supposed to be a very strict API, but something got lost as it feared Direct3D taking over.

    mumble

  3. Ragin' Lion says:

    As for a cross mark used to symbolize the closure of a window.

    Eh?! Come one, get some texturing into that program man! But I suppose lines scale up better at different resolutions. 8P

    I think there will (hopefully) start to be some faster movement in OpenGL since The Khronos Group took over the main control of the standards a few months back.

    At some point (i.e. when Vista finally ships and is safe to use), I do want to try out DirectX 10 because of the unified shader architecture, but OpenGL is really the only API that’s available on most non-Microsoft platforms.

  4. Davide Pasca says:

    Every time I hear Khronos Group I think about the cheesy password used in the movie The Incredibles.

    It’s a pretty cheesy name.. I just hope it does make a difference !

    I see that you are concerned as usual about being multiplatform.
    Honestly, with the prospect of working for MS that I had recently, I was ready to drop OpenGL for a while. But, it seems that MS let its chance to hire me slip and that’s +1 for OpenGL ;)

    woooooo

  5. Ragin' Lion says:

    Yeah, I’m still cross-platform minded since I’m hoping to (eventually) say goodbye to Windows if things don’t shape up. Besides, it’s a nice feeling to see one’s software running on a different machine! 8P

    I still need to spend some time and learn how to use wxWidgets, but it’s a bit too busy at the moment. So maybe after the project has ended I can spend time learning it.

    One of my (still) biggest problems is that unless I can find a compelling reason program to write in a new/different language or a new GUI API, there’s little motivation to learn. I had been thinking about learning Python so I can play around with scripting in Blender, but (so far) no real thing I want to create inside Blender aside from dumping 3D data …

    I was ready to drop OpenGL for a while
    Ready to sell your programming soul? ha ha ha! Welcome back to the OpenGL camp … at least until M$ takes you away … ;-)

  6. Lara Croft says:

    Davide, I guess you’re too busy to answer
    e-mails now. Wow, you must be “big shot” now 8)

  7. Davide Pasca says:

    Mr. Ragin
    wxWidgets from Hell ?! Good luck with that 8)
    I think you’d be better off with GTK. There aren’t many examples out there for wxWidgets, and frankly, it’s an inheritance and overloading mess, and also a #define mess !
    I personally go the Windows GUI way because I want to realistically release something rather than chase the portability dream 8P
    As fro Blender, I’d suggest working on a free version of Maya or Max.
    I tried Blender before, and learning how to make a circle with it was a real pain in the ass, not worth the trouble considering that is a software that is practically non-existent in the game business.

    Lara Croft
    Try check your inbox.. you may be lucky and get a reply from “Mr.Big Shot” ;)
    Actually I’m not working yet, so Mr.Big Bum is more like it 8P

  8. Lara Croft says:

    Hmm……might get lucky and get a reply???
    What is that supposed to mean? LOL
    Just asking!! Not working but no time to answer e-mails 8)
    Too busy!!! Okay,let’s leave it that way then. I guess don’t waste time sending you e-mail 8)
    No problem!!! :)

  9. Ragin' Lion says:

    *Ow!* KazStrongOpinion! 8P Sounds like the pre-work stress is building up! he he he … As far as using Blender, it’s because it’s free and not crippled like the free versions Maya or Max … besides those are generally “free” for folks who want to learn how to model in the program … not actually export data for usage. Besides, Blender’s changed quite a bit since you last used it. ;-)

    Why wxWidgets? Why not? 8P It’s not as bad as you make it sound though … then again, didn’t we have some same argument about C vs C++ years ago? 8P

    I guess I have the “luxury” of not having to release anything for anyone (but myself) so that affords me the time to try out different things. I already work on non-portable projects at work! 8P

  10. Davide Pasca says:

    Lara
    Try look better in your Inbox.. are you sure you aren’t missing any emails ?
    Maybe you set my address as spammer ? 8P

    Mr.Ragin
    C’mon.. if Blender and wxWidgets are soo good, why doesn’t everyone use them ?
    I invested time in trying to get something out of them and I realized that it was a waste of my time.
    You claim that you want to use them because of apparent good points they have, but you can’t tell for sure unless you actually try to make something useful out of them.

    Regarding C++ and wxWidgets.. well in a sense wxWidgets is a reminder of why C++ sucks (as it sucks because it can suck).
    The truth is that when dealing with pretty large API, either the API is overly documented with tons of samples, tutorials, etc. Or one is better off writing his own stuff at a lower level.
    The idea that you get the portability for free is a tricky thing. If and when you get your Mac, you’ll be probably better off learning Mac GUI programming and do your own porting.

    If you are writing a simple software, it’s easy to write a simple wrapper for 2-3 platforms. If you are writing a nice looking, platform-consistent software, then the differences are just too big.

    I suggest you to finally buy this Mac and get your hands on Mac programming before getting too wet with your multi-platform dream ;)

  11. Sexy Lara says:

    Hmm…whatever, Davide!!
    I’ve never received any e-mails from you because
    you’ve never sent me anything 8)
    No need to be a rocket scientist to figure that out . Just to let you know, I’ve never missed any e-mails from anybody!

    Enjoy your vacation then :)

  12. Davide Pasca says:

    Sexy Lara
    I have a spam filter, but that prevents certain mails from coming, not from outgoing. So I doubt there is much wrong on my side.
    Considering that I’m more or less infinitely more knowledgeable of computers than you (a woman, nonetheless !).. allow me to cast doubt on the situation you have on your side.
    Perhaps you could try get a GMail account and email me from there.

    baubau !

  13. Ragin' Lion says:

    I never said Blender and wxWidgets were industry standard pieces of software! I’m using them because I want to and also out of curiosity. I don’t use either at work. I just believe that it’s wise (if possible) to every now and then look at what’s out there.

    My guess is that you’ve probably not done any in-depth MFC programming else you’d notice the similarities between MFC and wxWidgets. MFC’s not all that great either … Since wxWidgets doesn’t meet your needs, don’t use it … it’s that simple. 8P

    As for GUI software, a lot of the time it’s just better to write your own API and interfaces that wrap the platform’s API … or not bother at all and make your GUI use OpenGL or something of that nature. Blender (for example) does this … it’s cross-platform by the way … 8P

    If you are writing a simple software, it’s easy to write a simple wrapper for 2-3 platforms. If you are writing a nice looking, platform-consistent software, then the differences are just too big.

    Qt is actually a good cross-platform API (and I’ve used this for 4 years!), but (at least the last time I checked) the Open Source version was crippled on Microsoft compilers. Hence looking into wxWidgets.

    The idea that you get the portability for free is a tricky thing.

    Yeah, portability isn’t free and it’s not easy … but I’ve done this kind of work (professionally) for the last 7 years so it’s not just some recent interest of mine. Write Portable Code is a really good book that talks about some of the basics. There are times where you simply can’t port or make things cross-platform.

    While we’re talking about all this, if you have time (and the interest), I recommend trying out C#. I was initially resistant to the idea, but when I tried it, it was actually not bad at all … of course, I’m expecting some kind of protesting response from you! 8P At least for writing tools, it seems like it’s a nice (and faster) alternative to C/C++ +some GUI thing …

    By the way, I have done some Mac programming! I think the Carbon API is worse that pure Windows programming (and MFC); it’s too tied into OS 9’s legacy and other odd things. Of course, for Mac programming Apple recommends using Cocoa which is essentially programming using Objective C programming (carried over from the NeXT platform). I do (eventually) plan on buying a Mac … but I’m debating whether it should be a desktop PC or a notebook …

  14. Ragin' Lion says:

    I forgot to mention that the best GUI API I’ve used so far was BeOS’ API … It was so nice to use … but hey, BeOS is dead … Or is it? ;-)

  15. Sexy Lara says:

    Oh yeah,…. women are supposed to be inferior when it comes to computers 8)
    Is that a fact??? or just DPasca’s theory??? But the truth is….in general women are smarter than men and that was proven. Anyway, can you tell me why has to be GMail account? Is it better?

  16. Sexy Lara says:

    Davide, why don’t you invite me to get a GMail account? or I have to find someone who already
    has one or……maybe………………….
    … just sign up on my own :’(

  17. Davide Pasca says:

    Mr.Ragin

    I never said Blender and wxWidgets were industry standard pieces of software! I’m using them because I want to and also out of curiosity. I don’t use either at work. I just believe that it’s wise (if possible) to every now and then look at what’s out there.

    Well wxWidgets was a waste of my time and I wouldn’t recomend it to anyone.
    I realize that it’s free, but my time is not free. I account my waste of time partially to those that that indirectly made me believe that wxWidgets and Blender are great.

    You said you need to learn wxWidgets but now you said you used it.. so I assume you have had time to see how it works. To me it was pretty ugly, especially considering that there is no decent free dialog editor for it.

  18. Ragin' Lion says:

    Sorry to waste your time Kaz! I guess I shouldn’t recommend anything to you any more since it has the potential to waste your time.

    I do need to learn wxWidgets, but (from the little I’ve seen and played around with) it’s very similar to MFC … I’ve yet to write any full blow application with it. I don’t consider these small test programs anything serious.

    Unfortunately, that’s the nature of “free” nature of OpenSource software. It may meet your needs, it may not meet your needs. There maybe free utilities available, there may not be … I guess you’ve written a dialog editor for your custom GUI stuff. Good for you I think.

  19. Sexy Lara says:

    Thanks Davide :)

  20. Davide Pasca says:

    Mr.Ragin
    I didn’t mean to say that you personally wasted my time 8)
    I was referring to the creators mostly.. which make a big deal of wxWidgets and spill all that propaganda on their site. I suppose cause they like to go to conventions and sell books or tools like the dialog editor.
    The real nature of open source is that there is a lot of crap out there. Open source is great but not all code in OS is great.

    I haven’t written a dialog editor for the custom GUI. I use the standard GUI for the dialogs and the custom GUI (which is really just buttons) for the application window.

    ole’

    Sexy Lara
    You’re welcome !

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>