Server overloaded by moronic spammers

I got an email this morning noting that my blog was taking “forever” to load a single post.

A quick check, and I found that it was running 70x overloaded, due to a vast number of spammers trying (and, in every case, failing) to submit wordpress comment-spam.

No spams will get through, because wordpress is set to only allow comments from people who’ve commented before – that’s a chicken-egg scenario that spammers can’t escape. (I wonder. Would the scourge that is “wordpress comment-spam” be reduced easily, instantly if Automattic (the people that make WordPress) had this as the default?).

…but at 2,000+ spammers a day, it was bringing the virtual site down. Server was fine, but I had the site limited precisely so that *it* would die instead of the server, in cases like this.

Now we’re going to try something new, since Automattic’s Akismet is pretty much useless these days. Anti-Spam, let’s see how you do…

Book: Game Development Principles (Alan Thorn)

I’ve recently been working with a group of teenagers, helping them learn to program for themselves, and build their own iPhone/iPad/Android games. So, when Cengage offered me a review copy of this book, I thought it would be a good idea to have a look and see if it would be helpful to a similar audience.

This blog isn’t a review site, so I’m going to pull out just the key interesting bits worth mentioning.

What’s the book for?

The blurb on the back cover claims:

  1. “games that enchant players and stand the test of time [are only made by people who know the] principles of good game design”
  2. “[this book has] the core theoretical knowledge”
  3. “math, textures, … geometry, … lighting, sound”
  4. “all your questions will be answered”

This book has nothing on game-design. There are few filler sections on this, but you’d get more detail by typing “game design blog” into Google and picking a link at random.

“Core theoretical knowledge” of game development is a big topic. If most people tried to write it down, I’d expect a thick, heavy tome. Thankfully, this book doesn’t try that. I’d say it aims for approximately 25% of the core knowledge, which is a reasonable compromise. Better to do some of it well, than do all of it badly.

On those named details:

  • “math” can’t be covered in a book unless that’s 50% of your content. This book has basic vector-math (really basic: not enough for game development), and quickly moves on.
  • “textures” skips all the bits about implementing textures, and instead focusses on issues to do with authoring simple 2D textures.
  • “geometry” only talks about things that 3D artists need to know when making models, it misses out all the things at the engine level, at design time, etc.
  • “lighting” is covered well, with a good explanation of deferred lighting (which is one of the major modern issues in lighting and 3D engines). More on this later
  • “sound” has basic info on implementing and playing-back sounds in-game.

In conclusion: the blurb on the cover is about 30% accurate. The book covers both more and less than it claims. On the face of it, this looks bad – but I think the book has rather more important/better content than the marketing claims

Continue reading

SVGKit: Programmatic editing of SVG files on iOS

(this is a post mainly to document some new features and fixes I’ve added to SVGKit version 1.2 today – they are already on the main development branch (currently: 1.x), ready for use)

SVGKit overview, November 2013

While a group of us were cleaning up and improving SVGKit about 2 years ago, I did a quick-n-simple re-architect of the in-memory data structures to split it into three wholly independent sets of source code / classes:

  1. Parsing an SVG file
    1. Parsing a legal XML file, with a new conforming DOM parser I wrote from scratch (because SVG Spec requires you to use a DOM parser, and Apple won’t let you use/extend their one on iOS/OSX!)
    2. Parsing the core SVG spec where it differs from XML-DOM
    3. Adding a system for user-supplied custom-parsers so that you can parse your custom XML in-line with the SVG (this is a major feature of SVG, but difficult to parse!)
  2. Rendering an SVG file with pixels on-screen
    1. Converting in-memory SVG data into Apple’s CALayer rendering format (used on all Apple Operating Systems)
    2. Optionally converting Apple’s CALayer format into highly-optimized hybrid data that lets you render SVG’s *fast*
    3. Painstakingly implementing every feature of SVG, from radial gradients to rich text (we’re about 90% complete now, still features left to add – please help!)
  3. Outputting an SVG file back to disk
    1. …not supported … until now!

Continue reading

OpenGL dumb mistakes: the mysterious Perfect Circular Hole

I’ve got a long-running project around rendering 3D Earth in interesting ways. It’s being used in a game project, and some non-game stuff too. Here’s a recent screenshot:

I added a particle system that uses Vector Fields to move the particles based on arbitrary incoming data, and then wraps it round a globe. Yay!:

…and then I increased the size of each particle, and something very strange happened. I wanted to splurge them out to be huge, but

The mysterious Holes Of Doom

… these weird holes appeared in the middle:

WTF? I must have done something stupid. I double checked everything. I removed the textures. I switched from quads to basic tris, with vertex colours … but still, this perfect circle cut out of the center! My vertex and fragment shaders by this point were exactly one line of code!

…I spent ages looking at this, trying to understand what could possibly create “holes” in my geometry. They were obviously holes – you can see through them!

Eventually, tired, and with lots of more important work to do, I gave up, shelved it, went off to do other things. Then today I suddenly realised the problem. I’m sure it’s obvious to most of you, but it’s taken me ages to figure it out.

When a hole is not a hole

And this is what makes it worth posting: the hole is not a hole.

My particles are on a 2D plane, so that I can calculate simple x/y coords from a vector-field. Great. My shader wraps the corners to a sphere. I’m rendering quads / tris like this:

gl-perfect-circle-bug-1

Great. But GL doesn’t “bend” the edges – it draws straight lines between corners. So … when I made my tris larger … the corners were still slightly above the surface of the globe.

…and the EDGES were still slightly above

…but the centers … slightly interesected the globe. And so, of course, the depth-test cut them out. In the diagram below, it looks as if the quad moved closer to the center of the globe – but it hasn’t. The corners are all still the same height above the surface – only the middle has (implicitly) gone “inwards”.

gl-perfect-circle-bug-2

Lesson to self: sometimes, it’s not a triangle-with-a-hole-that-I-can-see-through … instead, it’s a triangle-that-has-a-sphere-poking-through-the-middle

#facepalm

What programming language should aspiring game developers learn in their free time?

I was asked this recently in private mail by someone heading off to University / College. For people choosing between a Computer Science/Software Engineering course vs. a Game Design / Game Development course, I’d said:

If you love games, you’ll do both anyway; one you’ll learn in lectures, the other you’ll self-teach. Which will you find easier to self-teach (given no-one is prodding you), and which will you need the extra benefit of having a formal course/teaching/teachers? (usually: people find it easier to self-teach “designing and making my own game experiments”. Usually, people find formal Computer Science / Maths is ‘hard’, and they need the help of a formal course)

Gross generalization: Most game-developers in the indie community are programmers; most of them are programmer-centric when looking at the world. I’m a programmer, but I’ve done approx 40% of my career in project-management and studio management (and even a tiny bit of publishing) over the years.

There’s one interesting point I want to clarify a little: By “indie community” I mean “focussing on the places filled with people who actually ship games”. Most game designers who want to make their own stuff have to learn programming, even if they’re 100% non-programmers, since it’s the only way to get “your” vision launched. Even the ones that started-off as pure artists often end up being highly technical (whether they admit that to themselves or not).

So … this is not a popular view, but I think it’s more accurate than most: by the time you finish a 3-4 year course starting “today” … C++ won’t be the game-dev language people care about. Already, for entry-level jobs most studios are more interested in “how good are you at Unity? How good’s your C#?”. That trend will only continue/increase.
Continue reading

iOS Open GL ES 2: Multiple objects at once

Recap:

  1. Part 1 – Overview of GLKit
  2. Part 2 – Drawcalls, and how OpenGL code is architected
  3. Part 3 – Vertices, Shaders and Geometry
  4. Part 4 – (additions to Part 3); preparing for Textures

…but looking back, I’m really unhappy with Part 4. Xcode5 invalidates almost 30% of it, and the remainder wasn’t practical – it was code-cleanup.

So, I’m going to try again, and do it better this time. This replaces my previous Part 4 – call it “4b”.

Drawing multiple 2D / 3D objects

A natural way to “draw things” is to maintain a list of what you want to draw, and then – when the OS / windowing library / whatever is ready to draw, you iterate over your “things” something like:
Continue reading

OpenGL ES 2 for iOS: glDebugging and cleaning-up our VBOs, VAOs, and Draw calls


UPDATE: This post sucks; it has some useful bits about setting up a breakpoint in the Xcode debugger – but apart from that: I recommend skipping it and going straight to Part 4b instead, which explains things much better.

This is Part 4, and explains how to debug in OpenGL, as well as improving some of the reusable code we’ve been using (Part 1 has an index of all the parts, Part 3 covered Geometry).

Last time, I said we’d go straight to Textures – but I realised we need a quick TIME OUT! to cover some code-cleanup, and explain in detail some bits I glossed-over previously. This post will be a short one, I promise – but it’s the kind of stuff you’ll probably want to bookmark and come back to later, whenever you get stuck on other parts of your OpenGL code.

Cleanup: VAOs, VBOs, and Draw calls

In the previous part, I deliberately avoided going into detail on VAO (Vertex Array Objects) vs. VBO (Vertex Buffer Objects) – it’s a confusing topic, and (as I demonstrated) you only need 5 lines of code in total to use them correctly! Most of the tutorials I’ve read on GL ES 2 were simply … wrong … when it came to using VAO/VBO. Fortunately, I had enough experience of Desktop GL to skip around that – and I get the impression a lot of GL programmers do the same.

Let’s get this clear, and correct…
Continue reading

Why is a Fragment Shader named a Fragment Shader?

I’m writing some KISS tutorials on using OpenGL ES 2.0 in iOS/mobile, because I was frustrated that most of the tutorials on GL ES used incorrect or outdated approaches.

(I’m using the OpenGL ES 2.0 Programming Guide as my baseline, along with my own experiences of game-programming, and checking it all against Khronos Group / OpenGL.org’s docs as I go)

I use this stuff in iOS apps, but … I’m a relative novice with shader-pipelines. So I’ve been leaning on the guys at The Chaos Engine for proofreading and to help me avoid spreading misinformation. Most stuff people broadly agree on, but there’s been some interesting debate over a seemingly trivial question:

Why does OpenGL use the term “Fragment Shaders” to describe the shaders-that-generate-pixels? (where other API’s call the same thing “Pixel Shaders”, a much easier to understand/remember name)

Continue reading

Installing HMRC’s PAYE tools on OS X

The old PAYE tools was bad, really bad – I saw it generate the wrong figures once (i.e. actively costing UK small businesses real money for HMRC’s carelessness).

The new one is great – but it hasn’t been tested properly. The install instructions are wrong, it installs illegally on OS X, and it has a major bug in the configuration system. By accident, I discovered it’s all written in Python, which I find very interesting although currently it’s a bad advert for the language :(.

Here’s how I fixed it…
Continue reading

Fixing Firefox: removing the bad new-tab window (AGAIN!)

We already had to do this a year or so ago when Firefox developers tried to force a bad UI paradigm on us.

Now they’ve done it again, and added a new way to turn “new tab” from something that does what it says, into something that does stuff you don’t want.

Turn it off by pressing the magic button that exists nowhere else in Firefox and which you’d never guess was related to this broken feature.

OpenGL ES 2: Basic Drawing

UPDATED 24/09/13: Added some essential details to the class files at end of post, and corrected typos

UPDATED 24/09/13: Added Github project with full source from this article

This is Part 2. Part 1 was an overview of where Apple’s GLKit helps with OpenGL ES setup and rendering.

I’ve been using OpenGL ES 2 less than a year, so if you see anything odd here, I’m probably wrong. Might be a mix-up with desktop OpenGL, or just a typo. Comment/ask if you’re not sure.
Continue reading

GLKit to the max: OpenGL ES 2.0 for iOS – Part 1: Features

Apple uses OpenGL extensively – their 2D desktop libraries (Quartz, CoreAnimation) are OpenGL-based, and iOS has inherited that link (along with some funky tricks you can pull).

December 2013: I’ve converted the sample code from these articles into a standalone library on GitHub, with the article-code as a Demo app. It uses the ‘latest’ version of the code, so the early articles are quite different – but it’s an easy starting point

iOS developers often don’t have an OpenGL background, and most of the ones I work with like the idea of OpenGL, but feel they don’t have the time to learn and master it. However, the combination of “new API (OpenGL ES 2)” with “Apple’s helper classes (GLKit)” makes OpenGL development on mobile suprisingly fast and easy.

A few years ago, Jeff LaMarche wrote a series of simple, easy tutorials on getting started with OpenGL ES 1. In the same spirit, I’m going to write about GL ES 2. In the land of Khronos (the OpenGL standards group), version “2” is fundamentally different to version “1” (this is a good thing: ES 1 was outdated from the start, based on 1990s OpenGL. ES 2 is a modern API, based on 2000’s OpenGL)

I’ll be covering this from an iOS perspective. There are lots of GL ES tutorials out there, but for non-iOS platforms the challenges (and solutions) are different.

Quick links to all posts

iOS 5.0, iOS 6.0, and GLKit

With iOS 5.0, Apple introduced a new Framework: GLKit. GLKit’s apparent aim was to fix ES 2.0 to make it simpler and easier for non-OpenGL experts to use.

iOS 7.0…

It’s not live yet, and I’d hoped Apple might update GLKit to fix some of the holes below. I don’t know what will be in the final iOS 7 release, but I get the impression GLKit hasn’t changed yet. If so, everything that follows applies equally to iOS 7.

Summary of Apple’s GLKit and where it helps/hinders

Porting GL ES 1.x code
Full Apple provided a good, easy-to-use set of classes to make it trivial to port GL ES 1.x code. The documentation is very poor, though.

More importantly: it prevents you from using Shaders, which are one of the easiest and most powerful parts of OpenGL (once you get up and running). So, we’ll be ignoring GL ES 1.x

Classes: anything with the text “Effect” in the class name (GLKBaseEffect, GLKEffectProperty, GLKNamedEffect, etc)

Vector math
Full Every desktop OpenGL implementation assumes you have access to a good Vector Math library.

Until GLKit, Apple’s iOS was the exception: you had to make your own “vector” classes, you had to write all the Dot Product code, etc. (e.g. c.f. Jeff LaMarche’s first tutorial). Not any more :). Apple’s design here is good, and closely follows the conventions of their other frameworks (works the same way as CGRect, CGPoint etc from Quartz/CoreGraphics)

Structs: GLKVector2, GLKVector3, GLKVector4

Quaternions
Full Quaternions have a bad rep. Many people find them incomprehensibly hard to understand/code, and yet … they are essential once you start “rotating 3D objects”.

Apple’s implementation of Quaternions is excellent: you don’t need to understand the mathematics, just use the pre-built methods

Matrix math
Full Like Vector-math, Matrix math is tricky and time consuming to build for yourself and debug.
Apple’s done all of it, with an good set of methods.

Structs: GLKMatrix4, GLKMatrix3

OpenGL Projection
Partial (almost full) OpenGL uses 4-dimensions to deal with 3-dimensional rendering. That could get difficult, fast. Skipping the reasons for it, OpenGL used to be hardcoded to a set of special matries (M, V, and P – model, view, and projection).

GL ES 2 threw away the hard-coded matrices, and says “do it all yourself” (which, as we’ll see later, actually makes things easier in the long run). This is a pain … except Apple’s done it for us. Don’t go writing your own MVP stack code – use Apple’s.

Structs: GLKMatrixStack

Texture loading
Partial (poor) See post: “Part 6″

Before GLKit, you had to write long and complex methods, using CoreAnimation and Quartz, to convert “file.png” and upload it to the graphics chip as an “OpenGL texture”.

That code was hard to debug, and most iOS programmers aren’t familiar with CA/Quartz. Apple wrote a proper Objective-C texturing system that does the work of Quartz and y-flipping for you. For most “simple” code, this is perfect.

…but: they screwed up in a few places, some major bugs. When it works, it’s fine – and it only needs two lines of code! – so we’ll use it in the early articles, but we’ll throw it away and write a “fixed” version for the later articles.

Classes: GLKTextureInfo, GLKTextureLoader

Mixing UIKit with OpenGL
Partial (OK) See post: “Part 2″

There’s a lot of FUD on the web that says this is “impossible” or “slow” or … etc.

Don’t believe it. There are bugs in Apple’s CALayer / Quartz / CoreAnimation classes that make them slow *independent* of whether you’re running OpenGL. It’s just that the things people want to do when using UIKit with OpenGL are usually the ones that show up the bugs in UIKit/Quartz.

We’ll cover the main gotchas, and look at how to avoid or improve them. But for the most part: it works automagically. (there’s a reason for this: UIKit is implemented on top of OpenGL, so it’s already integrated to a high standard. It’s just that Apple hid the integration points)

Shaders (vertex, fragment)
None See post: Part 3
See post: “Part 6″

GLKit pretends that shaders don’t exist. The most important feature of OpenGL ES 2.0 – and Apple ignored it. Sad, but true. We’ll fix that.

Multithreading, context-switching
Full OpenGL supports multi-threading, background loading, all sorts of funky stuff.

Although it’s not strictly part of GLKit, Apple has re-used their old EAGLContext class to provide access to all of this. This is probably because it worked fine in the first place. However, to be clear: if you’re used to EAGLContext, it’s still used EVERYWHERE by GLKit.

Classes: EAGLContext

Multi-pass rendering
None See post: “Part 2″

You can make a cube appear on screen, textured, using single-pass rendering.

Just about everything else you ever want to do … needs more than one pass.

Apple provides no support for this, so you have to write it yourself (and there’s a surprisingly large amount of boilerplate you need to write here).

3D models, animation, data formats
Partial (very little) See post: Part 3
See post: Part 4b

GLKit does one great thing with 3D data formats: it provides a Vector class that all iOS apps/libraries/source can use, and be fully compatible with each other.

But it provides zero support for the rest: meshes, 3D models, VAOs, VBOs, etc.

Error handling and state management
None See post: Part 4

When you have a bug in your code, GL does nothing. Nor does Apple. Sooner or later you’ll find yourself weeping in frustration.

Performance analysis
Partial (some) Apple makes a lot of noise about how good Instruments is with OpenGL.

This is true, it’s good. But Apple also blocks you from accessing the hardware-manufacturers own performance tools, which may be better.

If you already know Instruments inside-out (e.g. you know about the invisible RHS-panel…), you’ll be right at home.

Next steps

If you know nothing at all about OpenGL, I recommend skim-reading the first 8 of Jeff LaMarche’s posts on GL ES 1.

NOTE: a *lot* of the detail in Jeffs’ posts is now unnecessary (or superceded). But it all helps with understanding the newer/cleaner GL ES 2 (and GLKit) versions. If you get stuck or struggle, skim that post and move on to the next. Each of his posts works well standalone.

Then head on to Part 2 – Drawing and Draw calls.

Also posted to #AltDevBlog at www.altdevblogaday.com/2013/08/29/glkit-to-the-max-opengl-es-2-0-for-ios-part-1-glkit-features/

Off-peak tickets valid in 2013 on Southern trains

UK train companies have an expensive fare (“Peak”) for early morning commuters, and a normal fare for everyone else. Each company has unique rules on time/validity. Southern Rail’s section on fares on their website recognizes this, but refuses to say when their normal (“Off Peak”) fares are valid. (see below for official times as of August 2013)
Continue reading

A 1st-hand description of doing Scrum/Agile correctly (in games industry)

Let’s be honest: many games-industry teams/studios abuse Scrum. Then, after months of pain and suffering (and poor project-progress), the team members go to other teams or companies, and take a hatred of Scrum/Agile with them.

So it’s interesting to hear from people who’ve made the transition from “Agile/Scrum done wrong” to “Agile/Scrum done right”.

Quotes I’ve heard repeatedly:

  • “It doesn’t work”
  • “It’s a load of corporate-trainer bullsh*t”
  • “It works for industries that have no uncertainty in their design; but in games, you don’t have a spec to start with”
    • [this is depressing; it's where Scrum shines - but people have mis-applied it so much that they're getting the opposite result]
  • “Have you seen how easy it is to become a Certified Scrum Trainer? And how much they get paid? It’s just a big con”
    • [IMHO the ScrumAlliance has a lot to answer for, in how they've allowed this problem over the past 5-10 years. It seems to have been a strategy of short-term gain (more practitioners) for a long-term loss (reputation and quality of practice)]
  • “In Scrum, you have to do a 2-3 hour meeting every day, where everyone on the project gives a full status update, so we never got any work done”
    • [I've heard this worryingly often. It's stunning that anyone could allow their Daily Scrum meetings to go so wrong]
  • “Scrum is all about equal authority and shared responsibility, but some (our manager) are more equal than others, and never responsible for the failures”
  • “Agile is where you can do anything you want and when someone on your team is lazy and claims everything will take 10x the actual time, so they can do no work all day … you’re not allowed to disagree. Because Agile/Scrum says you can’t disagree with each other”
    • [Again, I've heard this often. Did these teams accidentally read the Black Bible of Scrum? The one where everything is inverted?]

This came up on a forum today, and one of the posters chimed-in with their own experiences. The forum’s private, so I can’t link to it, but I’m reposting their summary (with permission):

“I’ve done scrum/agile 4 times in games.

Work does 3 week sprints and is now split into 2 teams so we have 2 scrums a day. Time of this is strict, on-time and 15 mins long*.

Our Producer/Product Manager only sees the program in the Sprint meeting. The entire team is in the Sprint meeting also, which is now pretty good. The Sprint meeting lasts the whole day. So that’s 6-8 hours every 3 weeks*.

The morning is broken into what we did in the previous Sprint. We demonstrate each story and if we tick all the requirements defined in the story it gets marked as complete. If we don’t complete it, we say why and a new story gets made with what’s left. This is only if it is still required and may be put into the Backlog and done several Sprints later.

The afternoon is spent deciding on the next stories. These have been defined by: the Customer Requirements/Publisher/Whatever, the Producer and the Leads. The 2 teams break off and the whole of that team decides the requirements AND the time it will take. This prevents the wasters on the team getting away with poorly defined requirements and giving a time that is clearly taking the piss*. It also covers people underestimating. The peer-pressure means people work because next Sprint people have to explain why it wasn’t finished when everyone decided on it. If no one can decide on the time then it clearly hasn’t been defined well enough*. It helps because the team works closely together and they all understand those parts.

We can ask the Product Manager questions at any time etc, but like I said: he never sees the work in progress for 3 weeks. He also never comes in and changes things*. Because it’s the whole team plus the Producer/Product Manager agreeing on things, features gets dropped when needed, priorities get sorted, and blame can be removed from the development cycle*.

There are various other small details but that’s the main bit of it.

If you aren’t doing these things in scrum/agile then really you’re just wasting people’s time and giving waterfall development the wrong name.

* All stuff Game Development scrum failed to do in my experience.”

GamesThatTeach: Papers, Please

An interesting review here of “Papers, Please”. I haven’t played this one yet, but I’ve been following progress via the promo screenshots they released earlier, and this (p)review sounds great:

“At a certain point, the transit papers will get so complex that you will, inevitably, start making a lot of mistakes. This can become a serious problem as every incorrectly reviewed passport will deduct more and more cash from your pay at the end of the day. With your family’s lives on the line and the job getting tougher and tougher, the game asks you — like actually asks you, through gameplay — what are you willing to do to get the money you need? Will you take a bribe from a shady character? Will you start throwing more people in jail so you can get a cut of the prison guard’s bonus? Will you do knowingly dishonest or immoral things just so you can get that extra ten bucks that might allow your family to eat tonight? There are no right or wrong answers.”

JumpTest v0.2 (different jumping algorithms in Unity)

New version up on the webplayer link:

Screen Shot 2013-08-14 at 18.46.23

http://t-machine.org/web/WebPlayer-jumptest/WebPlayer.html

Test jumps

Proving quite fun just playing around with it and testing different jumps:

Screen Shot 2013-08-14 at 18.56.00

Screen Shot 2013-08-14 at 18.54.41

User-aimed jumping

Two jumps in a row using the same algorithm, but it aims your jump based on where you’re looking when you hit the spacebar. In this case, second jump I flicked the mouse up at last moment before jumping, giving a higher/longer arc:

Screen Shot 2013-08-14 at 18.53.35

The perfect jump: testing techniques for Jumping in Unity3D

In a physics-based engine, there’s many ways to make a character “jump”. For my 7-day FPS entry, I’m trying to work out the perfect jump for my gameplay. Easier said than done. I’m struggling…

Before I go looking for feedback and suggestions, I thought it would help to make a demo showing the things I’ve been trying-out.

Unity webplayer link to try the examples below

Instructions: wait till you land on skyscraper, then hit a number key to select a jump type, and get jumping (spacebar).

Note: if you fall, no problem, it’ll auto-respawn you after a couple of seconds of falling

Continue reading