• Advertisement
  • entries
  • comments
  • views

About this blog

Vulcan is now an enemy island!

Entries in this blog

Unity raytracer

Messing about with Unity, wrote a little raytracer - quite easy as Unity does all the hard work!

Have a bash... stick a few spheres, planes, lights in a scene then stick this script on an object:using UnityEngine;using System.Collections;public class Tracer : MonoBehaviour{ public Color AmbientLight; [Range(0.0f, 1.0f)] public float Reflectivity; private Texture2D Texture; private Light[] Lights; void Start() { float ratio = Screen.height / (float)Screen.width; Texture = new Texture2D(256, (int)(ratio*256)); Lights = GameObject.FindObjectsOfType(); } void OnGUI() { GUILayout.BeginArea(new Rect(16, 8, 256, 64)); if (GUILayout.Button("Trace")) { DoTrace(); Texture.Apply(); } GUILayout.EndArea(); GUI.DrawTexture(new Rect(16, 48, Texture.width, Texture.height), Texture); } private void DoTrace() { float dx = 1/(float)(Texture.width); float dy = 1/(float)(Texture.height); Vector3 vec = new Vector3(); for (int y=0 ; y 0.0f) { var refl = Vector3.Reflect(ray.direction, hit.normal); RaycastHit hit2; if (Physics.Raycast(hit.point, refl, out hit2)) { clr += ColorAtPoint(hit2.point, hit2.normal) * Reflectivity; } } } Texture.SetPixel(x, y, clr); } else { Texture.SetPixel(x, y, Color.black); } } } } private Color ColorAtPoint(Vector3 aPos, Vector3 aNormal) { Color clr = new Color(); foreach (var l in Lights) { if (!l.gameObject.activeInHierarchy) continue; var dirToLight = (l.transform.position - aPos).normalized; float NdotL = Vector3.Dot(aNormal, dirToLight); if (NdotL > 0) { if (!Physics.Raycast(aPos, dirToLight)) { float dist = Vector3.Distance(aPos, l.transform.position); float v = (dist/l.range)+1; float intensity = l.intensity / (v * v); clr += l.color * NdotL * intensity; } } } return clr; }}
Twice is coincidence, so Mr Fleming wrote.

I love Chaos. The game that is - that old Speccy turn-based peculiarity.

Mr Gollop is one of my programming heroes. His work probably influenced me more than any other to take up programming; games programming in particular. I used to dream up great new ideas that I'd add to Chaos when I became a programmer. One of the first 'proper' programs I wrote allowed you to hack into Chaos and change the names, graphics and attributes of the creatures and spells. 'Death to hackers' indeed ;) Speaking of which, the Rebelstar series wasn't too bad either - that game (along with Laser Squad and XCom after it) sealed my adoration of the TBS genre for good. I remember nearly killing myself racing round my paper round, desperate to get home and play it yet again.

So to the point. Whenever I get a new device nowadays, one of the first things I do is try and get Chaos running on it somehow. I've just installed a version on my Android phone in fact.
So a few months ago I came to thinking... there's nothing new been added to the game by the 'remakes', why don't I follow my dream of years ago and do a remake myself to take advantage of the new mobile revolution? It surely can't go as badly as my last attempt at a remake can it now? It's been almost 30 years since the original Chaos after all, surely Mr Gollop has moved on...


Somebody above is telling me to stop attempting remakes. I'll just leave this here...

The Carrier 2 remake is now dead. Gone. Buried.
With the intended release of an official Carrier Command game from the new IP holders, I can't really continue with my friendly remake.

I do intend to take what I have, hopefully get more people on it, bypass any IP issues and get something released. Eventually.
And with the planned modding ability, it's not beyond imagining that someone could come up with a mod that resembles a certain other Carrier commanding game ;)

Carrier2 has served me exceptionally well in it's original purpose: a way of learning 3d graphics and games-related programming in general. Looking back at the first screenshots I have to have a little chuckle :)
I think I opened it up publically far too early as you all know - it's taken quite some time, though as games programmers know all too well, once a game is 90% finished, you still have the other 90% to get done...
I've been astounded by the enthusiasm people still have for the game, and the support I've had from literally hundreds of people all over the world.

Old-timers check your inbox... old timers I may have forgotten, send me a mail!


Gratuitous C2 screenie that I quite liked, showing the enigmatic Walrus.

You can just see how the procedural placement of the structure foundations allows the terrain to poke through and look silly sometimes ;)
You may also notice how the framerate has halved due to the FBO stuff. Still investigating that one :( Suspect maybe the render buffer texture format...


OK so Carrier2 doesn't like ATi gfx cards. Or the other way round. Either way I'm in the process of rebuilding my spare PC with a rather ageing but still robust Radeon 9800 Pro :)

In other news, I picked up a little 'medieval' RPG-style game called 'Mount & Blade' on steam some weeks ago. This project started out as a man & wife team editing a 3D demo. Several years later (with a few more members added) this small team, unconstrained by publishers and commercial needs, has created something that IMO surpasses some commercial games in parts (the brilliant combat system being the main one).
At first I was disappointed that there was no continuous world 'map', but after a while this really didn't matter to me. It actually reminds me of Lords of Midnight mixed with Elite on horseback - simple on the surface but quite deep too.
I'm from the school that regards complex games like Total War etc as superior, and yet I've played this little gem for much longer than those already (hey, I need *some* time off C2 hackage). Helping that, it feels like you can dip in & out of the game for a short play and still make meaningful progress. I just hope I can emulate this kind of approachable gameplay in Carrier...
Anyway I recommend you give the demo a try if you value gameplay and want to support a small indie dev team.
So while I wait for a physics fix-up, I thought I'd take a look at that scary omnipresent todo-list item casting a dark shadow on my thoughts - erm... shadows. As is becoming usual with these game dev things, getting an initial implementation working wasn't nearly as hard as I thought it would be (umm standing on the shoulders of giants & all that). It's just that they're, well, ugly as sin really, with the requisite 'surface acne' and blocky low-res shimmery-ness close up. Using a huge shadow map texture (1024-2048 square!) close to the camera helps somewhat, though I've not done anything too clever with the light view and frustum yet (enter cascade shadow maps or similar).
Also, using glCopyYadder to capture the scene depth buffer was being limited by the app window size, so I've been forced to make the jump to using frame buffer objects too - delving into a rather arcane and temperamental part of OpenGL (boy is DirectX looking (slightly) more attractive nowadays, especially with the Longs Peak debacle. /me remembers back to my first blog comment...)
Getting the shadows integrated (I have to sample the shadow texture in each shader) also revealed errors in the ambient lighting calculations in the terrain and mesh shaders, which was nice.

Anyway, nuff yacking, here's how shadows change the look of the old gfx... (yep: could do with some textures about now I think). I'm now looking at overcoming the various idiosynchrasies as we speak. Ysaneya's journal has been quite helpful here describing his journey through the same territory.

Vegetative vagiaries

Argh - I is demoted! Lost my GDNet+ status due to my paypal details becoming obsolete. Was a shock to see a blue avatar icon next to my name and be unable to post here! Fixed now :)

Had a bit of a bad time with my chosen Lua binding lib LuaPlus recently - it seems I can't trap any meaningful error output when calling Lua functions from C++. This makes development a nightmare, and almost impossible for 3rd parties to write mods. Plus it looks like no-one uses LuaPlus any more as it's too old/unsupported, so I may have to migrate to a different solution there :(

Added level-of-detail facilities to the model & rendering system. Not essential at the moment, but will be once the world/model detail ramps up, and I want to increase the island mesh resolution and size too at some point (bigger, more detailed islands :)).
Model meshes tagged in Blender as a LOD level are auto-extracted and used when rendering at a distance.
Also added support for specifying mesh 'render flags' in the modeller: i.e. setting polygons to be two-sided, alpha-tested and unlit.
To test both of these new additions I added the first vegetation to the world - a nice fir tree in keeping with the original's unusual planting scheme.

Ah refactorisation. The structure hierarchy has had yet another revamp, and this time I'm happy with it at last! I'd strayed from the path a bit regarding the cells as a different class, so now it's back in the heirarchy deriving from a Structure and all is well. Now the basic objects/structures in the world are fully recursive, so I could build a cell base, build a structure on it, and build a defense turret on that, etc. The individual cells are like mini ACCB's and build their own supporting structures at the site. All these spawn/build instructions and the ACCB deployment have been moved over to lua so are fully customisable.
Work has been done on the structure placement process too, as it was simply some basic suitability checks on land height/slope. Now I need to evaluate a 'placement score' for a given position, maybe relaxing the score requirements after some searching so we can guarantee that essential structures always get placed somewhere. Might have to alter the island geometry in real-time to ensure gameplay requirements are met though - will have to see how it goes.

So yes, gameplay progression has been somewhat stalled, but hope to get back on track...
Bit overdue for one of those log update thingies - my SVN changelog is getting crowded.

It's amazing how much work it takes at this stage to do stuff, and how little the game seems to progress after doing a big hack session. I have to tread the fine line between rapidly chucking in more features and keeping the build working on all fronts (especially save game functionality - that's paramount to testing stuff efficiently). ...which is the reason for seeking help recently, before this thing turns into Duke Nukem Forever type neverware.

Still hoping to get some form of release at the end of this year (to a smaller group first), though that is approaching rapidly!!

Anyway, main things of note:

  • Integrated the new (beta) version of Newton Physics SDK - still a few problems left, but it's much faster & nicer & smootherer all round :)

  • Lots more basic structures added - hopefully got a few modellers on the case now to improve and texture em. Islands looks a lot more busy and varied, even without detail & skins.

  • Rehashed the terrain shader, which also now takes params for visual 'look & feel' - e.g. rockiness, rock type, vegetation etc - see recent screenies. Lots of variations of terrain look now possible.

  • Worked on balancing collisions, damage & effects to go with them.

  • Refactored quite a few code parts - onwards & upwards :o

  • Had to rewrite my object construction code to handle child object physics bodies & joints correctly. That was fun :(

  • Moved loads more stuff out to Lua for flexibility.

  • The Walrus finally has proper wheels and looks rather nice now :)

  • More work on the new island cells - still more to go though.

[ed] hmm interesting formatting there. Ah well.


Mmmmm... this isn't just *any* island... this is a Carrier Commander modified ridged perlin island with smooth shader topping, enrobed in jus de la mer!
Wouldn't you just *love* to make some models to inhabit this beautiful island?!

Thanks for the image layout idea, Mr HopeDagger ;)

Help wanted

Hmmm. Time to get this thing put to bed I think.

I need a good 3d skinner/modeller to help get this thing finished. Anyone out there interested in Carrier Command and can do better than my efforts? (it aint hard - It's programmer art FGS ;))


Just finished the mother-of-all-changes to the source code - a solid two weeks of hackage to some code that's been in there right from the beginning!

Basically, the old island structure class wasn't up to what I required, so it's been ripped out & replaced with the concept of a 'structure cell'. These replace the old single structure, providing a generic mounting point for a small complex of structures and objects all working towards a single purpose. Damaging any 'working object' in the cell will reduce the efficiency of the cell's work (e.g. object production / raw material extraction). Also makes the islands look better as well as being more flexible for procedural sub-structure and related object placement.

Structures with a view:

Manta employing the new bomblet pod:

Now I'm off for my summer hols after that hackage workout - cya in a few weeks :P
P.S. Hope you notice the todo list up there is actually shrinking... :)
To show I'm still here!

Looking at ways to individualise the islands so the scenery doesn't get boring.
Should be able to integrate it with the random island generation and just pass in a few params to the shader :)

One of the younger islands - just a lump of rock:

Piebald island:


Kinda side-stepping recently...

Moving a lot of data over to Lua, making it easier to organise, load & mod.

Added new weapon: clusterbomb thingies :) Nice area destruction now possible, if you find it hard aiming Mr Quaker.

Making all weapons available to the island defense drones & turrets, and making their attack patterns dependent on their current weapon. Lots more variety now, and easier to get your ass destroyed :P


Back from hols last week - always strange getting back into things after a relaxing break. Normal service will resume shortly...

Found a nice article on indie game dev on my travels, brought to us by 'the escapist', home of the fabulous . :)


List above updated... very good progress over the last few weeks.
Got loads of little things done, unfortunately a lot of them too small/unplanned to show on the list... :-/

Surface vehicle autopilot basically done & working nicely, just need some code to avoid island structures intelligently.

Was also thinking of making the supply drone a user-pilotable Osprey-like vehicle rather than the surface-based 'box' of the original.

Also thinking I should include an 'easy' Manta control method like the original, with the on-screen cursor simulating joystick deflection. It's currently probably a bit too sim-like for a lot of original CC fans.


More stuffage being done:

- Shaders simplified and unified to use global lighting properly.

- Lots more scripting and debug stuff - I can now execute Lua commands, show results and query data in a console-like debug interface. Had some fun trying to intercept stdout where Lua outputs its stuff, but in the end I just redefined the Lua print function to send me the string instead :P

- Experimented with the POWAH of scripting - in several lines of Lua I can set up a day lighting cycle, with the sun moving across the sky (currently excluding the fixed skybox textures. I'd like to try a procedural skybox render, but that can wait...) All this power will be available for mods (and allow me to develop things faster too.)

Manta mkIII

In full shader-vision :)

Amazing how a nice shader covers up the rather basic skin ;) Unfortunately the carrier is using the same shader so it's a bit bright on the later pics.
Just need some nice shadows now...


Vista annoyance number 52 in a series of 500:
Carrier2 app hangs with a black screen roughly 50% of the time it's run. Having an explorer window open seems to help (wtf?!)
Single-stepping in the debugger always runs fine, so can't narrow the problem down that way.
It's probably something Microshaft put in to hinder OpenGL app dev.

This pathetic excuse for an OS is pissing me right off at the moment :(
The only thing saving it's sorry ass is the amount of work needed to reformat and install XP and set everything up again.

/vent off

plus de stuff

Integrated the rather nice DevIL image loading lib today - I was using some of my old code to load bmps and now I'm starting to need extra stuff like alpha layers (i.e. tga loading)
Speaking of which I made a per-pixel lighting shader for the vehicles and structures too, looks quite a bit nicer than the fixed pipe per-vertex stuff.
The alpha loading gained by DevIL gives me more scope to allow nice effects in the shader like encoding shininess (specular), reflectance etc. into different parts of a texture to be processed by the shader.
I'd take a pic but prtScrn has stopped working recently for some reason so I'll have to install Fraps or something...
Nope, not an April fool... I have actually done something! ;)

Ok, Surface vehicle basic waypoints mostly working again. Walrus now seems to skid like mad on land for some reason now - still investigating... probably that damping issue again :(
Hacked in manual Walrus docking too for now - just drive up the Carrier rear entry and you'll get docked when inside. oo-er.

Manta autopilot somewhat serviceable again... lots more work needed there though.
Modified the model import stuff (now I've got more to grips with the Collada format) to apply the modelled transform for each object exported from Blender. Was having to 'apply transform' to each object in Blender before export and ended up with intermediate files and other bad stuff. Should be faster and more flexible getting stuff from Blender into the game now. Win :)
  • Advertisement