Game Development

Blog 848: Fragment v0.04

I’ve done it. I’ve committed to the orthographic camera. There might still be teething issues I’ve missed, but I think it makes the game look a thousand times better so it’s worth the pain. (Feel free to make me eat those words in a year or two if/when I give up and switch back.)

Which means, of course, now is probably a good time to let some real people test the water. I’ve also done a whole heap of other stuff, including rain and bug fixes, so please head on over to itch and give it a go!

Fragment v0.04

True to my word, I have extended the demo very slightly — if you attempt to travel to the Friendly Arm Waystation, you are now guaranteed to be waylaid by enemies. It’s only when you try to complete your journey that you’ll see the Insert Disc 2 warning. Enjoy your first taste of flipping back and forth between maps, I guess! Griiiind that save/load system!

The bulk of the work I have otherwise been doing since the last version has been on the levels that come later, which are still locked off. So, uh, massive perspective shift aside, this version doesn’t actually include much new stuff. I apologise for this flagrant lack of value for money and promise to do better next time. Maybe 0.05 will bring the Rest of the Prologue? … depends how many orthographic bugs I’ve missed, I guess.

The orthographic camera makes even mundane shit like “going up a lift” look so much better.

There is, however, one last-minute change included that is of particular delight to me. A few days ago, I finally discovered the true algorithm for how Milkshape does its spheremapping — the technique I have coveted for literal decades that makes surfaces look like shiny metal. (Yes, I spent all 10 of my years modding WC3 pining for it, and I was even more mad when I discovered that there is a keyword for it in the MDX model format, but it is unimplemented!)

I was getting frustrated as my utterly gubbed approximation from the last eight years of flailing at Exon wasn’t handling the transition to orthographic camera mode very well (it was all based on view directions and stuff so I kinda understand why). Then I remembered that I have the source code for a stand-alone Milkshape 3D model viewer — this is how I learned about the file format so I could implement my own direct Unity importer. I stumbled over to the renderer class to look for clues, but all I could find were some calls through to OpenGL, and the keyword GL_SPHERE_MAP.

It’s amazing how much you can unlock once you know the terminology. I searched the internet and tracked down some pseudocode of how GL_SPHERE_MAP calculates texture coordinates, then set about rebuilding it in Amplify Shader Editor. I am delighted to announce that (after a few hours of frustration and confusion) I finally got it working. Shiny materials are now shiny in exactly the way I want them to be.

No, I don’t have the faintest idea how it works. It’s got matrices in it, I don’t want to know!

That’s not even a real reflection sphere map! It’s just a smooshy wibble texture and yet it looks amazing!

The one loss from the change to orthographic mode is water that becomes more opaque with depth. It turns out that the depth texture for an orthographic camera is completely different and/or meaningless compared to one for a traditional perspective camera, and try as I might, I never managed to work out the maths required to get it doing anything remotely sensible. Since this was only ever a “nice to have” effect I have elected to turn it off for now, so you’ll just have to suck up water having… consistent transparency. (It’s quite possible that you literally never noticed it anyway.)

A few systems have also been rejigged to suit the upgraded camera system. The Mech Bay, for example, no longer has a camera “track”, and instead directly sets the rotation and zoom parameters to frame your hero. I’m beginning to wonder if I need to roll something like this out to the rest of my cinematic system, as just pointing the Unity scene view camera in the right direction and plonking down a transform is no longer a meaningful way to build camera tracks — I’ve fudged the clipping planes enough that my existing tracks still work, but since “zoom” is now “orthographic size” rather than “actual distance to stuff” it may need proper support going forward. Sounds like I need to write some more editor tools, huzzah!

But until then… please play the new version and reassure me that I’ve done the right thing!

Why thank you, Warren.

And you tell me...

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.