Menu Home

Programming

Font rendering: stb oversampling vs NV path rendering

I told you I wanted to try stb oversampling in my last post, and I did! Here is the result (stb 2×2 oversampling on top, nanovg in middle (which is based on stb anyway, but no oversampling), and NV path rendering on bottom, screen size then 5x zoom):

So stb oversampling definitely looks the best, although it is still pretty fuzzy. And moving it around by subpixels looks very decent; it doesn’t get very much of the “shimmer” effect. (Still a bit, but not much to be bothersome.)

Here’s stb oversampling (top) vs NV path rendering (bottom) with a bigger font size (screen size then 2x zoom):

Here, I think NV path rendering looks better; it’s definitely less fuzzy. (The trade-off is that it does suffer from more “shimmer” when translated by subpixels, but it doesn’t bother me too much.)

You can also see that NV path rendering is able to utilize proper kerning: the ‘e’ is slightly below the capital ‘T’, as it should be. Each letter isn’t being drawn on a textured quad, so overlapping is trivial. (Well, for the end library user, at least.)

So, I think that completes my foray into font rendering for now. I’m too lazy to make bitmap fonts at the moment; stb oversampling will work for smaller fonts for now. Time to continue on to other GUI elements. I will try to design the GUI system in such a way that it will be able to utilize any font rendering system should I wish to create bitmap font support in the future.

More font fun and other random stuff

Font rendering in OpenGL

Haven’t done so much programming in the past week, but I did try rendering fonts with NanoVG (in lwjgl). Unfortunately it’s really not much better than just using OpenGL’s NV path rendering extension. Small fonts look slightly better, but not really good enough for me to want to use them. See the example below, a zoom-in of an 8-pixel high rendering of the font “Verdana”, NanoVG rendering it on top, NV path rendering below. NanoVG is better, but it’s still way too fuzzy to look any good.

So I might just use bitmap fonts for small text; I can’t see any alternative. (Bitmap fonts basically means loading in each letter as a pre-rendered picture and plopping it on the screen. The disadvantage is that they don’t look very good when resized or positioned between pixels, but they’ll at least be guaranteed to render small fonts clearly and crisply.) I’ll continue to use NV path rendering for larger fonts or fonts that need to be animated more dynamically or rendered with 3D perspective. I do want to try using oversampling with stb for small fonts before I move on from font rendering and further develop a GUI system; the demo doesn’t look too bad.


Kanopy film streaming service

I just realized our local library offers free access to the film streaming service Kanopy, and they’ve actually got a decent selection. Not the latest blockbusters, but some good foreign and classic cinema. (They’ve even got The Red Pill, the controversial anti-radical-feminist documentary which Netflix refuses to stream. (Though they did just recently finally add the DVD to their catalog.)) Since it’s free (for library card holders of participating library systems), we’re limited to 10 streams per month, but the streaming quality is decent. It’s not full HD (at least not on my PC), but it’s better than DVD quality. Interestingly they also allow you to embed videos. Here’s “Kumiko the Treasure Hunter”, which I really enjoyed (which I guess you won’t be able to see without an account, haha):

Interesting indeed!


Some metal music

Finally, I recently discovered the band Elvenking. I couldn’t quite get in to some of their older work, but their last album, released last year, is quite catchy. Disregarding the bizarre sense of fashion metal band members tend to share, this song is some power metal awesomeness:

I also came across the latest album from the symphonic metal band Leaves’ Eyes, and found it to be quite catchy as well. Love the use of choirs, the female lead’s operatic voice, and the cheesy fantasy lyrics. (I’m not a big fan of the growl singing, it sounds so gross and ugly and demonic, why is it so popular? It sounds so awful, so unmusical. Bah!)

OK, that’s all for now.

Font programming fun

So I’ve started working on GUI elements for my little engine that could. My quick list of things I’d like to include in a GUI system:

  • ability to create a menu bar
  • ability to create windows / panels with drop shadows
  • ability to create scroll bars for window content
  • ability to create buttons and button animations (hover, click)
  • ability to create text boxes and text fields

I started working on text today, i.e., font rendering. The NV path rendering extension actually does a pretty good job with larger text:

It’s not so good with smaller text:

Look at that ugly subpixel rendering:

Bleh! So I’ll have to figure out something else for smaller fonts. I’ll probably look into the Java AWT package, or perhaps look into NanoVG, especially since it looks like lwjgl already has bindings for it. (Maybe it already has everything I want?)

MIDI animator version 2 wishlist…

As I blogged a couple months ago, one of my goals for 2018 is to program a very simple 3D engine. I’ve been wanting to program a simple adventure game for a few years now, but the 3D and 2D engines I’ve played around with just don’t have quite the features I want, so I’m attempting to create my own little game engine with the Lightweight Java Game Library (lwjgl).

Here’s what I’ve got so far: I can render a textured box and some resolution independent vector graphics including true-type fonts, which can intersect with the box!

OK, so nothing special yet.

Anyway, another thing I’d like to create with lwjgl is a new version of my MIDI animator, using vector graphics (instead of custom shaders) to represent the MIDI notes. (On a side note, I’m using the OpenGL “NV path rendering” extension for vector graphics support, which was created by Nvidia. Does that mean it’ll only work on their GPUs? I don’t know.) This should easily allow many more possible note shapes to be created.

Here’s my current wishlist for “MIDI animator 2.0” (I should also come up with a more interesting name):

  • Should be able to run standalone (that is, users shouldn’t have to download and compile the code to use it)
  • A graphical user interface (GUI) that makes it easy to:
    • load MIDI files
    • change note styles / shapes / colors / animations
    • a scroll bar to make it easier to scroll through the MIDI
    • save files
  • Ability to add title / text animations (instead of having to do this in post)
  • Ability to change / animate background
  • Ability to load in an MP3 to sync with the visualization
  • Ability to add an MP3 visualization, such as one of those pulsing frequency bars or something
  • Ability to export a movie file automatically (if I can figure out how; I’ll save this for last)

Anything else I should include or look into?

So, yeah, this is probably what I’ll be working on in my free time for now. I’ll probably start working on a GUI system next as I’d need to do this for a future game anyway.

Hopefully I’ll get back to actually writing some new music afterwards.

Game programming…

Last year I learned the basics of jMonkeyEngine, and though I intended to create a 2D game with it, I only ended up creating the MIDI animator mentioned in my last post. But for a tile-based 2D game, it’s really not ideal. It’s certainly capable of producing such a game, but as an engine, it’s not really designed for it, and I realized I’d have to spend a considerable amount of time just programming a custom framework for such a project.

So last month I began learning LibGDX, which is certainly better suited for the sort of tile-based 2D adventure game I’d like to create.

So here’s what I’ve got so far (the art is temporary, simply a free tile set I found out there, though I think I’ll be aiming for tiles that are 16×16 pixels as well, so this represents the size I’m hoping for):

screenshot

Doesn’t look like much, but I’m still learning and programming the basics I’ll need before I actually start programming the actual game play. What I’ve learned and/or programmed so far includes:

  • loading and displaying a tilemap (a .tmx file from Tiled)
  • dynamic window resizing (or resolution changing) without completely screwing up the aspect ratio (trickier than it may sound)
    • basically it will always render with a resolution of 1280×720, which is then rendered as a texture to whatever resolution the user sets; handy for Android devices which may feature differing resolutions which cannot be changed
  • using Ashley as an entity framework
  • using Box2D for character movement and collision detection
  • animating the character as he walks (much easier with LibGDX; I had to program a custom shader with jMonkeyEngine)
  • real-time A* pathfinding (hope to use it with NPCs)
  • text (as you can see at the bottom there) to be used with menus, dialog, etc. (nice little font called Munro) (this is also much easier with LibGDX)
  • custom shader to make object tiles “light up”

Still lots to program, but I reckon that’s an OK start. The to-do list before I can actually begin programming the actual game-play logic includes:

  • have interactable objects “light up” as the player nears them, along with a small pop up menu with available actions (pick up, talk, examine, activate, etc.)
  • design and implement a menu panel / status bar (along the black panel along the bottom)
    • this menu will switch to a “dialog mode” when the character is talking with someone (as in The Secret of Monkey Island, for example)
  • pause menu with save, load, quit, settings, etc.
  • camera movement for when the player walks off the screen
  • loading another tilemap for when the character leaves a village or enters a house, for example
  • I need to try sticking an NPC in there and having it play through some scripted material, utilizing the aforementioned A* algorithm as necessary
  • real-time combat system
    • cast a spell or swing a sword to injure attacking enemies (the combat will be simple in this game, nothing fancy)

That’s all I can think of at the moment, but that’s plenty, isn’t it?

The game itself will be pretty short; I’ve tried to keep it short on purpose since even a short game is a lot of work, especially when you’ve never done it before and don’t have a pre-existing framework your familiar with to use. If I manage to actually succeed in this endeavor, I hope it will be easier to create new adventure games and/or RPGs in a similar style without having to reprogram these basics again, at least not from scratch.

The tentative title for the game is Memory of a Thousand Kings, which began as a half-plotted fantasy novel, but I think it will work better as an adventure game.

Source code for my MIDI animator

I recently uploaded the source code to the MIDI animator I programmed with jMonkeyEngine to github: midi-animator.

To use it, see the Readme there. You’ll need jMonkeyEngine, and understanding Java would probably help. (I’m not really interested in making a standalone user-friendly app at the moment; Stephen Malinowski’s “Music Animation Machine” is still available if you want that. I’m more interested in having something I can continually customize and play around with.)

In addition to perhaps being sloppy (as I never intended to share it), the source code is a bit bloated as it’s actually part of a larger project to create a MIDI editor that will feature my melody generator. But that’s a long way off; I’m not actively working on that at the moment, and probably won’t anytime soon.

So… there it is if anyone else wants to play around with it, or contribute their own improvements to it… feel free!

Also, it’s my first time uploading something to github, so I’m not very familiar with the platform yet… I hope I did it right.

Still programming…

Haven’t posted in a while, so here’s a little update on what I’ve been up to lately.

Basically, I’ve abandoned Unity for now, though I’d like to get back to learning it at some point. But I’m much more familiar with Java, so I looked around and found jMonkeyEngine, an open-source Java-based 3D engine, so I’ve been learning that. I’m currently working on a small 2D mystery game for PC and Android platforms. (Like a small adventure game, where you go around talking to suspects, searching for clues, collecting inventory and using it, etc.) It will use pixel art, since I can actually create pixel art with a bit of clicking around. Currently I’m using Pyxel Edit to create the pixel art, which is small and elegant and quite affordable (only $9 at the time of this writing). Pixel art actually isn’t too difficult for a non-artist like me. Well, OK, it’s still possible to create really crappy pixel art. What I mean is that it’s much more approachable for a non-artist; you can create an effective passable character (and walk-cycle for that matter) much more easily than, say, trying to draw something with pencil and paper or trying to actually model and texture something in 3D. And it’s not difficult to search for references online to see how other artists did things; everything is made of pixels anyway. So I’m confident I can create the sort of graphics I think this game will need. Still, if I had the money, I’d rather hire a free-lancer. After all, it’s still a time-consuming process, especially the animation.

Anyway, while I’m more familiar with Java programming, jMonkeyEngine has far far less online support than Unity (and their forums are difficult to navigate and contain many broken links). The engine also has far less features. For example, to achieve the animated textures I need for my 2D game, I had to program my own shader. Granted, that’s not too difficult to program once you know how to do it, but I spent over a week just focusing on how shaders work (and only scratched the surface, I’m sure).

Still, the advantage is that I’m working in a programming language I’m much more familiar with, and I’m not obligated to pay any license fees or anything when my game is released. So, while I’m sure I’ll switch back to Unity (or GameMaker) at some point, I do very much appreciate the option of jMonkeyEngine.

So that’s what I’m up to at the moment. I have no idea how long it will take to finish this game, assuming I don’t abandon it. Guess we’ll see. I’m crossing my fingers that it doesn’t take longer than March 2016. (Which means it will probably take until March 2017.)

Back to Unity 3D

So my Kickstarter quietly (but I suppose not unexpectedly) failed yesterday, though backers did pledge to contribute $785 of the requested $9,000. Which isn’t completely horrible for spending no time building an audience. But it wasn’t nearly enough, so unfortunately there won’t be a book on melody from me in 2016. Not sure yet if I’ll try to build an audience and try another Kickstarter later, or if I’ll find some other way to find the time. But it’s back to being on the back-burner for now.

Other than that, I’m still learning the ins and outs of Unity3D. I’m confident I can learn the programming side with more practice and experience; Unity is so much more convenient and intuitive than the engines I fooled around with a bit more than a decade ago in high school. (I could swear I used to understand quaternions when I was in high school. Not that I really need to understand them now, as Unity takes care of them, but I still want to understand them again, if I ever really did.)

I’m also not worried about game design. Though I don’t really have much practical experience with it (beyond daydreaming), it is the fun part of game development. Writing, designing puzzles, storytelling, etc… Those are what excite me about game development in the first place. I would never have bothered to learn GW-BASIC when I was in elementary school if storytelling through video games didn’t excite me.

What I don’t have any experience with is creating art for games. Modeling, texturing, or drawing in general. And since I can’t afford to hire freelancers, that’s something I’m going to have to learn, and a skill I’d love to have anyway. Though I may try programming a game that features purely abstract shapes to circumvent the need for art, I still want to create adventure games at some point, and those will require some modeling and texturing skills.

So there’s that fun stuff, and of course I’ve still got some novels I’m working on…

Unity and games and stuff

Learning Unity!

This week, at the expense of working on my next novel*, I’ve been getting back to studying Unity, the game development platform. My new computer handles it beautifully, nice and fast. And I found some great introductory tutorials to start with from a “gamesplusjames” from Ireland, land of me forefathers:

It’s still a lot to take in; I don’t know if it’s just my aging brain or that I haven’t been programming regularly for a long time now, but I’m definitely slower at learning this sort of stuff than I used to be. Anyway, Unity makes a lot of stuff pretty easy; wish something like this was out when I was in high school.

(* On a side note, my writing blog is down for the moment. It was getting inundated with bots, and just pointing the domain back to the registrar was my lazy way to try to get them to go away. It’ll be back at some point.)

Let’s Plays!

With my powerful new computer, I’ve been able to record some “Let’s Plays” on my new YouTube gaming channel, SirDragonWizardMasterLord, the dorkiest name I could come up with.

Probably won’t make them regularly, but it was fun to try, and I was very impressed with how well my computer could handle them; capturing video didn’t slow the games down at all, even with the games’ graphics settings at their highest. Nvidia’s GeForce GTX 970 is just awesome.

Inside Out’s blatant plagiarism!

I saw Pixar’s latest, Inside Out, earlier this week. It was a great film, but as I mentioned on Twitter:

In Search of Strong AI

While trying to work on my novel, my mind sometimes turns to mush and I can’t think creatively, at least not in the way that novel-writing calls for. So I began a journal with which to chronicle my thoughts and explorations as I search for Strong AI. I would love to live to see Strong AI achieved; who wouldn’t?

My short term goal, however, is to create a computer program that can teach itself to play chess (or any rule-based game) in such a way that we can observe the rules that it learns. As far as I know, no one has achieved this. Chess engines focus on number-crunching algorithms, using the computer’s ability to calculate quickly to its advantage rather than trying to simulate how a human would learn things. But if we can figure out how a human learns the game, I think the algorithms involved would be far more useful to advancing human knowledge than number-crunching algorithms created specifically for the game. I want an algorithm that creates algorithms.

Anyway, I have written up my explorations so far in my new little journal. You can download a PDF of the journal here. It’s a bit too long and clunky to post as a blog entry. I hope that as I continue to explore the subject, I will write and upload more journal entries.

Not sure anybody else out there is interested in the subject, but I’ll put it out there in case anyone is curious. Join me, and together we will rule the world.

InSearchOfStrongAI-Part01.pdf