Parallel-split Shadow Maps are cool

Development, OGRE, OS X, Uncategorized 2 Comments

OgreSpeedTree with PSSMWe’re on the final home straight for Ogre 1.6 (aka Shoggoth), which should hit RC1 next week. One of the final features I wanted to squeeze in was support for Parallel-split Shadow Maps (PSSM), which uses multiple shadow maps per light in a hierarchical fashion to improve the quality while keeping the size down, particularly in outdoor scenes using global directional light. If you’ve played Assassin’s Creed, you will have seen this technique in action already.

For example, the screenshot on the right there is using 3 shadow maps for the single directional light, the closest one being 1024×1024, and the other two being 512×512 - together they are 38% of the size of a single 2048×2048 shadow map and yet provide greater detail. The 3 shadow textures are displayed for debug purposes on the right - notice that all 3 are using LiSPSM projection to bias the texture precision toward the camera which also helps. If you look really closely on the full resolution shot, you can see the transition from the highest resolution shadow map to the second shadow map about halfway up the screen, it changes near the top of the closest tree shadow. It’s quite hard to see though, which is kinda the point :)

One of the challenges with supporting PSSM is that Ogre had previously assumed that there is a 1:1 mapping between lights and shadow maps, which clearly had to be overcome - this limitation also prevented easy use of dual parabaloid and full cubic shadow maps for point lights of course. It was one of those things that had been languishing on my TODO for a while, begging me to find some time for it, and that’s where it still was until Pang Lih-Hern (aka lf3thn4d) from Malaysia came along and did it for me :) What a star! His initial patch allowed multiple shadow textures per light in a very sensible way, and he then implemented a PSSM facility on top of that, via our pluggable ShadowCameraSetup system (which he also extended in the patch to be aware of shadow map iteration). I adapted the PSSM code from his demo to be a little more flexible (it now handles any number of splits, and a more flexible split configuration) , so that setting it up goes something like this (simple projected shadows here, depth shadowmaps are also possible of course but let’s not overcomplicate it):


float shadowFarDistance = 3000;
mSceneMgr->setShadowTechnique(SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED);
mSceneMgr->setShadowTextureCountPerLightType(Light::LT_DIRECTIONAL, 3);
mSceneMgr->setShadowTextureCount(3);
mSceneMgr->setShadowTextureConfig(0, 1024, 1024, PF_X8R8G8B8);
mSceneMgr->setShadowTextureConfig(1, 512, 512, PF_X8R8G8B8);
mSceneMgr->setShadowTextureConfig(2, 512, 512, PF_X8R8G8B8);
PSSMShadowCameraSetup* pssm = new PSSMShadowCameraSetup();
pssm->calculateSplitPoints(3, mCamera->getNearClipDistance(), shadowFarDistance);
pssm->setSplitPadding(mCamera->getNearClipDistance());
pssm->setOptimalAdjustFactor(0, 2);
pssm->setOptimalAdjustFactor(1, 1);
pssm->setOptimalAdjustFactor(2, 0.5);
mSceneMgr->setShadowCameraSetup(ShadowCameraSetupPtr(pssm));
mSceneMgr->setShadowFarDistance(shadowFarDistance);

Notice that I used Integrated Shadows, this is a requirement of PSSM since only shaders with integrated shadow support can decide on the fly which shadowmap to sample from.

My sincere thanks to lf3thn4d for helping us get this feature in to Ogre 1.6 (and to all those who send us patches in fact). If you want to see it and OgreSpeedTree in motion, there is a video available; that’s the low-quality streamed version but you can also download the higher resolution version if you want.

Sleepless in … LA

Business, OGRE, Travel, Uncategorized 4 Comments

I arrived in LA either Saturday night or Sunday morning depending on whose watch you believe, and am coping with the inevitable jet lag. Working helps to some degree, since it keeps you active, until you hit that ‘wall’ where suddenly your brain holds up it’s hands and says “I don’t care what the clock says, it’s 3am”, before grabbing its hat and coat and sodding off, leaving you a hollow shell looking at a screen full of C++ going ‘buh?’.

I’m staying in Torrance since that’s close to my client’s offices, but we’ll be heading downtown to get registered for Siggraph today I’m sure. I have a fair few things in my diary for the next few days so hopefully I’ll be lucid enough.

If you’re at Siggraph too and want to say hi, drop me an email (sinbad at ogre3d dot org or steve at torusknot dot com), I’ll check my email as often as I can. Alternatively you may find me on the ‘Works Zebra’ stand on the AMD booth (#323) where I’ll probably be from 3:30pm Tuesday, 12:30pm Wednesday and 1pm Thursday. The company will also have a presence on the Vicon booth (#1101) at times although I don’t think I’ll be needed for that. Bear in mind I’m there for my clients while on booth duty though, so if you want to yak about Ogre & unrelated TorusKnot stuff we’ll have to arrange to meet again later on.

LinkedIn OGRE Group

OGRE, Uncategorized, Web No Comments

I consider LinkedIn to be one of the few genuinely useful things to come out of the whole Web 2.0 gold rush, since it’s a business-oriented, generally ‘fluffless’ site (if I see one more virtual gift or stupid time-wasting Facebook application, I’ll lose all will to live) - as such I actually do use it fairly regularly. I finally got around to creating an OGRE Group - feel free to join if you’re a professional OGRE user / contributor. I use LinkedIn to remind me who I can refer OGRE-related jobs to, so it might be worth your while :)

Memory, Man

OGRE, Uncategorized 7 Comments

We’ve had ‘custom memory allocators’ on our upcoming features list for a while. Last year a student did some work on this during the Summer of Code, but the system ended up being a little too ambitious with its use of templates and got a bit too costly in terms of the template instantiation requirements. Unfortunately the student never returned, so I picked up the baton recently, and I felt it was worth writing about some of the things I’ve done, since most of the C++ allocator discussions on the net are pretty shallow and only deal with the simple cases. This is quite a big and fairly technical discussion, so I’ve placed the bulk of it after the jump to spare those who don’t care about this sort of thing! :)

Read the rest of this entry »

Pimp my Drums

Business, Games, Music, Political, Uncategorized 7 Comments

My Rock Band drum mods arrived today, they took a week to arrive which isn’t bad considering they had to meander their way from the Land of the Free (ish) via regular US letter post.

Drum Pads
I decided to go for drum pads from RocPadz, which are basically just circular cut mouse mats with a rigid back. I went with these for a number of reasons, such as that the neoprene rubber is hard wearing and long lasting (unlike foam pads which quickly lose their effect). These pads also scored highly in reviews for ‘bounce’ which can make playing easier, and they were also rated highly for the QM drum set which I have. The other main contender was DrumSoft, but while their pads are nice looking, they seemed a little too delicate for my liking - reviews were very keen to point out that you could rip the top surface if you weren’t careful during installation, which made me think they might not stand up to long-term abuse as well. The only downside to the RocPadz is that they’re a little expensive for 4 modified mouse mats - you could actually just buy yourself some regular office mouse mats, cut them to size and get some rubber glue to apply them with, but a combination of laziness and the fact that the dollar is weak meant I decided to just go with the prefabs.

Installation was very easy, they even supply you with a little alcohol swab to clean the pads with first which I thought was a nice touch. The result seems very good - the noise from the pads is definitely reduced, and the fact that the drum sticks bounce more really does feel better when playing. The only downside is that it seems to very slightly exacerbate the lack of sensitivity around the edge of the drum pads, which was already there anyway but seems slightly worse. However the middle area of the pads, where you had to play anyway to avoid missing notes, are not affected at all, they’ve still highly sensitive and a very light tap will trigger them. I hope to play more over the coming days.

Kick Pedal
The kick pedal mod should be a familiar one by now, an aluminium plate from Pedal Metal. I went with the billeted metal version because it looked nicer than the regular diamond-plate - yeah, I’m a sucker for aesthetics. I also paid a little more to get the hinge replacement bit too - I don’t need it yet, and haven’t installed it because it’s more fiddly - I figure I’ll keep it as an emergency reserve in case my hinge does break, so I don’t have to wait for a replacement.

Installation was easy, once you get over the fact that you’re invalidating your warranty by screwing stuff into your plastic pedal. But I figure the warranty on the pedal is pretty useless anyway, since it’s the one thing that is highly likely to keep breaking in it’s original form under any long period of stress (given the cost of the kit, it’s scandalous that it isn’t already reinforced with metal), so I might as well make it more robust myself. Once it’s on, while it doesn’t make any difference to the play experience itself, it’s nice not to have to worry so much about how hard you’re stomping it, particularly as I’m starting to play on Hard now which is bringing in some rapid-fire kick pedal action in places. The main thing is that it totally eliminates the rather disconcerting ‘flex’ in the pedal if you pressed it between the hinge and the spring - this pedal ain’t for bending now.

So, I’m very happy with these mods - it’s yet more money down the throat of the ravenous Rock Band monster, but it’s so much gosh darned fun I really can’t hate it for it :)

Great assistance from NVIDIA & Graphic Remedy

Business, Development, OGRE, Uncategorized 1 Comment

I posted recently that we were having some mipmapping issues with NVIDIA’s newest drivers, the 175.x series, on both Windows and Linux when using GL. Thanks to help from the nice chaps at NVIDIA these issues are now resolved for the moment - there does indeed appear to be a bug in some aspects of the hardware mipmap generation implementation in these drivers, but the workarounds exposed a couple of bugs of our own in software mipmap generation code - which hasn’t been used by Ogre on most modern hardware for several years, since we’ve opted for hardware mipmap generation for a long time.

One was that we had been retrieving the internal format of a GL texture after construction using glGetTexLevelParameteriv with GL_INTERNAL_FORMAT, in accordance with recommendations. However we made a mistake in that for cubic textures we were passing the type enum GL_TEXTURE_CUBE_MAP instead of the target enum GL_TEXTURE_CUBE_MAP_POSITIVE_X et al. Subtle, and for whatever reason it must have worked fine on older drivers, but the 175.x drivers became more strict and were throwing an error. Unfortunately our other sin was that we weren’t checking the error code after that call (after all, what could go wrong with something that simple? :) ) so we completely missed it, and the internal format, which we then used later on to generate software mipmaps, was nonsense.

As it happens, I’ve been trying out Graphic Remedy’s gDEBugger again recently - I’d previously tried it a couple of years ago and couldn’t get it to work properly with Ogre for some reason, and my post in their forum about it had gone without a resolution, so I let it expire without buying it. However, I really have come to miss having some way to easily diagnose GL issues, like you do with the D3D debug runtime (and various GL intercept / dump tools are ok, but generate so much data it’s hard to sift through it), and it’s clear to me that the error above may well have been highlighted by a tool such as this before the driver started to bork on it. So, I emailed GR to see if they’d be willing to give me an extended trial license and some assistance with resolving the problems I was having. They got back to me really quickly, and via our correspondence identified an issue that they will resolve in the next version of gDEBugger, but which I could also work around in Ogre for now. I haven’t had a lot of time with it yet but I intend to give it a workout over the next couple of weeks, and buy a permanent license if it turns out to be as useful as I expect.

I really appreciate being able to get help like this when I need it, I’m in debt to the people at NVIDIA (especially Kevin) and Graphic Remedy for the assistance. Thanks chaps!

My thoughts on software design

OGRE, Uncategorized 12 Comments

I don’t claim to be an expert in software design, but I think I’ve learned a few things over the years. As I’ve wrestled with a few problems recently, I began to think about the approach that I generally take to the process of design. It’s influenced by books I’ve read, multiple projects that I’ve been involved in, and some of my gut feelings. You may agree or disagree, but I felt it would be good, even just for myself, to write down the tenets that I’ve come to regard as core to my design approach.
Read the rest of this entry »

What time is it? Tooth hurty.

Personal, Uncategorized 4 Comments

It was eleven o’clock last night and I’d just had a cup of tea. Pretty uneventful you’d think, Englishman has tea, perhaps had I been even more traditional there might have been some checkered pygamas and/or smoking jacket and a copy of The Times involved too, but no, just a good old steaming mug of the brown nectar.

Until my tooth starting yelling blue murder - loudly. You wouldn’t have thought that a tooth had a good pair of lungs on it, but this one did. I have sensitive teeth anyway, so I assumed it was a cold day / hot drink thing at first, but this little blighter just wouldn’t shut up. Not being able to concentrate, I left the computer and had a bash at Mario Kart for half an hour or so to take my mind off it. Still hurt. So, I made an attempt to dull it with pain killers and hit the sack.

This morning it had mercifully calmed down, but I went to the dentist to get it checked out. The news is that the oldest hunk of metal in my head (yes, this filling dates from the time when you had to go to a blacksmith to get yer teeth sorted, so yer did) has started to become defective, and hence has a habit of leaking ostensibly harmless tea into rather sensitive nerve ending cluttered cavities. Damn.

So, tomorrow I have to return to have the thing refitted with a new and improved ‘Filling 2.0′, which I can only imagine these days includes a toungue-activated, flash-based MP3 player built in. Well, for the price they charge, it has to have something good, right?

Delays, delays

Personal, Uncategorized 4 Comments

I just got word from my supplier that Visual Studio 2005 Pro won’t be dispatched until 10 December now, which allegedly is due to shipping delays at Microsoft and as such will affect all suppliers in the UK. Darn.

I have Express already obviously, but I’m still doing most of my work in 2002 since I can’t bear to be without my favorite plugins for too long. Let’s hope it arrives before Xmas, think of all those sad little faces on Christmas morning if Visual Studio 2005 doesn’t make it into their stockings. Santa just might end up on the business end of little Johnny’s next DDOS attack. Bless.

Another release out the door…

OGRE, Uncategorized 2 Comments

Well, that’s another OGRE release out the door, this time it’s 1.0.6, another maintenance release for Azathoth. Once again it’s packed full of bugfixes, which always gives me pause for thought - every time we do a maintenance release I think ‘right, there’s no way we’re going to build up that many fixes again in another 6 weeks’, but still we manage to. It sort of makes me uncomfortable that this many things still turn up, but it’s fair to say that the majority of the fixes this time were the less serious ones, such as safer behaviour when the user screws up, or memory leak removal in more unusual circumstances. OGRE has actually been extremely stable for some time, but each maintenance release makes it even more robust. This time we added support for VC++ 2005 and XSI v5 too.

Dagon is still waiting in the wings, targetted at the end of the year now although, as always, it’ll be done when it’s done - something that’s especially applicable when doing things in your spare time. My main goals are to implement shape exporting in XSI, for morph animation and facial animation, but it requires that I learn more about modelling those things in XSI first. I’ve already started making my way through the training DVD and it’s really quite fun. I wish I had more time to play around with XSI, it’s a really nice tool.

Given _mental_’s absence lately I’m may also going to need to pick up the point sprite work he was going to do, unless :wumpus: gets there first. People’s time is very unpredictable so we’ll see how it goes. I’d also like to do a HDR demo of some sort sometime since I messed about with HDR in OGRE for a client a little while back and would like to show it in action.

Of course along with all this I have Kadath in the background, which I really must get on with. I lost a fair amount of time due to some personal issues over the last couple of months, and pretty soon it’s going to be early 2006 which was my target for the first version. So, time to crack the whip some more.