Wednesday, May 26, 2010

Content aware

Adobe's (kind of) technology for content aware fixes and adjustments gave me an idea that I really would like to see implemented in Tivo's and Sky+ boxes.

I was watching someone else watch a tennis match a moment ago and thought: "if he pauses that, that is just going to go on forever and ever", thinking that watching TV at work actually makes it last about ten times as long as you're never really watching it and you're not often able to either.

But then the thought struck me, if it's live, you could compress the amount of video you have to watch to catch up. Not in some 1.5x speed playback, but by having an actual interest aware culling and squashing system. Like content aware resizing, but for time.

Then, I thought, wouldn't creators of TV shows love it if their shows got cut in the right places, and the right bits cut out to make space for adverts? Probably, so there you go. We need content aware like timeline adjustments but for a simpler input stream, the importance value stream.

I'd like to have this on many you tube videos that I try to watch, but fear that many of them would never have a non-zero value in their meta data.

Once upon a compile

Once upon a time, I wrote a font renderer for OpenGL, last night in fact.
I was happy and done.
I had checked in my changes, and wanted to install the latest version of Ubuntu, so I went about switching over hard disks to get some data off my windows partition before I finally killed it dead by installing Ubuntu over it.

But, an evil witch was near and she had blanked my memory.

When I formatted the hard drive to copy stuff off, I was not aware of the fate that awaited me.
A number of minutes later, my snazzy SSD (which will soon be up on ebay) was sitting there filled with just over 10gb of data, safely stored now. Stored over what was my old installation of Ubuntu.

Now, I had taken precautions and copied all my home directory that I thought mattered onto my 1.5tb drive, so I didn't care about the fate of the ubuntu partition.

This was my downfall, as the witch had cast her spell before I'd even shutdown the linux OS.

As I rebooted onto the live CD, I was happily unaware of the fate before me. I installed and installed until finally I had code::blocks up and running, and rapid svn was downloading my source that had merely minutes before been uploaded. I installed SDL and g++ and prepared to shout tada, when:
compilation failed.
Can't find file to make FontRenderer.o went the output.
Code::blocks could not find the FontRenderer i had just written
I checked SVN once
I checked it twice
I'd forgotten (cursed to forget) to add the new files to the checkin
weep I did not, for a time long gone a wise man once said to me:
"that what yuv coded once, is thrice as easy the second time"
remembering that it was me that said it, i thought, "Well, I'm always right, so it must be true."
and so, in my lunchtime today, a beautiful font renderer was born again. in about 8 minutes.
and they all rendered happily ever after.

the end

Wednesday, May 19, 2010


I was told by someone, not sure who, but I think that person told me they were told by someone who "manned the scanners", that the full nude image of lenna was a fake.

Now, for a person who knows photoshop quite well, I was very prepared to take this as fact, and that was fine until I stumbled across this article because a work-mate showed me the "fake" that wasn't. Photoshop is powerful, and there's no reason why I wouldn't beleive it was a fake if told it was. In the same way we all believed that people eat spiders in their sleep.

The full nude image, the one that was in playboy, the one that was scanned and used for years as one of the main continuous tone, face artefact, compression technology test images. Was the one I knew to be a fake. How come? Information, bad information, flows just as free as good.

I'm reminded of a quote from a film I recently watched:

"A woman was gossiping with her friend about a man whom they hardly knew - I know none of you have ever done this. That night, she had a dream: a great hand appeared over her and pointed down on her. She was immediately seized with an overwhelming sense of guilt. The next day she went to confession. She got the old parish priest, Father O' Rourke, and she told him the whole thing. 'Is gossiping a sin?' she asked the old man. 'Was that God All Mighty's hand pointing down at me? Should I ask for your absolution? Father, have I done something wrong?' 'Yes,' Father O' Rourke answered her. 'Yes, you ignorant, badly-brought-up female. You have blamed false witness on your neighbor. You played fast and loose with his reputation, and you should be heartily ashamed.' So, the woman said she was sorry, and asked for forgiveness. 'Not so fast,' says O' Rourke. 'I want you to go home, take a pillow upon your roof, cut it open with a knife, and return here to me.' So, the woman went home: took a pillow off her bed, a knife from the drawer, went up the fire escape to her roof, and stabbed the pillow. Then she went back to the old parish priest as instructed. 'Did you cut the pillow with a knife?' he says. 'Yes, Father.' 'And what were the results?' 'Feathers,' she said. 'Feathers?' he repeated. 'Feathers; everywhere, Father.' 'Now I want you to go back and gather up every last feather that flew out onto the wind,' 'Well,' she said, 'it can't be done. I don't know where they went. The wind took them all over.' 'And that,' said Father O' Rourke, 'is gossip!'" - from "Doubt"

And yet we still tell lies. Lies for absolutely no reason at all (in the case of Lenna, I can see no reason at all). The feathers travel for miles and years. I'm glad that Google is here today to find the truth. All I need now is to start mistrusting everything that I've been told, and wear a citation needed hat.

Friday, May 14, 2010

Game Logic XII: Know your user

One of the neat things about Google Mail is that it uses a push architecture. The idea is simple really (the implementation isn't though) youn can infer that people are interested in updates as long as they have asked for data before.

Once you know someone has asked a question or submitted a query, like an html request for a page, you can provide them with up to date diffs or events that can affect the current state of their query. They can figure out what it would be, without actually doing a new query.

This is another form of compression. The assumption of prior knowledge, and assumption of interest.

In games development, when we set up how we're going to do network traffic for multiplayer, normally we initialise a game state, schedule a sync point, then keep each of the players / clients up to date with network events, or sync ups for positioning and other things that are less deterministic.

This same thing can be used in other ways too. Some resource managers remember who's had what off them, and if the resource is updated externally, it get propagated through the system.

There are quite a few other places where this technique works well, but boil it down to its basic component and you've got a query that is kept alive by the data source. The query is the user, and the data source knows about it, and wants to keep it happy and up to date.

This is quite simple, but how often to entities in games "poll" for some world states? Lots! And all of these every frame pollings (apart from the really esoteric ones) can be replaced with live queries. Queries that live past their call and response, get updated whenever anything matters, and can probably self optimise in many cases.
Difficult to syncronise queries like "what is near me" can be made live, by updating the parameters whenever the entity moves.

All this means that senses are more continuous. I'd speculate that it won't help with memory usage by much, but should save CPU time by not creating and destroying queries all the time.

GPHI, by Insomniac?!?

Ok, for those of you who worked with me at broadsword: doesn't this sound an awful lot like GPhi, circa 2005? It's got the "pools of components" (that would be gphi behaviour containers), "async update", that would be the behaviour container centric update, "implicit usage via existence", that would be the entity ID reference into behaviour container thing.

I'm reading it and I'm not seeing anything new apart from maybe the get component by interface implementation, but isn't that just as bad as dynamic casting in OO? Please correct me if I'm wrong, but surely you know what type of interface something has if you are updating its container in this system? If not, are you now doubly adding virtual overhead?

Also, in Dynamic Components (at least from this presentation) there's no mention of DLLs in conjunction with this stuff! That was one of the main selling points in GPHI, you don't need to know what a component/behaviour does, only that you could register a behaviour container and add the behaviour to your entity and let it get on with it.

But, and this is a big one, they implemented it. In a production game, they implemented the cool. GPHI never made it into any BS games, just an editor I used for animation adjustments and working with shaders, so they beat me there. The Ascendance project (which included the DB asset server framework, the crash proof editor, and game deployment tools) never got finished. Looking back, that was Jan 2005, just before first work on Snow Queen. That's a long time ago now.

One last thing too, at least mainstream thinking is catching up with what I've been doing. This should mean that when I've finished my tests and written my book on row oriented development, people's heads will be in the right place to fully appreciate it.

Wednesday, May 12, 2010

Game Logic XI: Current Concerns

All this clever stuff is mighty clever, and though implementing some of it was easy, actually implementing it all as some form of framework has turned out to abuse C++ too much for my way of thinking.

I don't like clever code, it's often the start of a deeper relationship with a debugger than I want to dedicate myself to. I have a wife and kids, they're my dependants, not some crazy meta-coding template macro system.

So, looking at how things have progressed so far, I can say that clever type safe templated table heading things are probably not the way to go to make this stuff fly, no, oddly, I think that going back to how sql does things might be a way forward. I'm thinking that the base command of an SQL query (select/insert/modify etc) is my basic object for the table control, and any arguments that would have come after that in SQL can be written out as a text string constructor argument.

Welcome back printf style arguments? I'm not sure I need to go this far, but we'll see. Again, it all depends on actual implementation experience. If I can get one game out written in this stuff, then I'll at least have a good basis for building a better way of working. Right?