Saturday, June 2, 2007

First Entry

(Images of my current project, it was supposed to go down the bottom but the image editor for this blog is beyond my mortal skills )

And some cubemap based specular. Cubemaps pretty craptastic but it sure makes things look bumpy and wet. Programmer art ftw.

Comparison shot of No Bump Vs Bump, q3/urban terror 4.0 :)






Radiosity Lighting on its own.

Plain old bumpmapping * Diffuse

Frozen Sand and HL2

The team has been musing around the idea of starting another project, preferably something nice and commercial.
We prototyped out a fairly advanced (gameplay wise) FPS project in way back 2004.. but great code won't even raise an eyebrow if your game looks like its from the q3 era art wise...

It was easier for us to attract the coding and mapping talent we needed to put together a prototype then gathering the concept/chararacter/animators you need to make something particularly flashy... a fps project breaks down to roughly 20% code, 80% art so I don't really blame the publishers for wanting the art-talent there up front.
Gathering a group of artists capable of producing assets at the level required is nigh on impossible for a $0 team mostly known for modding q3... So looking on jealously at the art-talent the half-life 2 mod teams were able to attract, we decided that perhaps Hl2 wouldn't be a bad platform to work (and pimp) from. Start a mod, gather the artists who want to play with the shiney toys, eventually nudge a (much less ambitious, but much prettier) demo together.
Anyways.. the point of all that is that I spent about 4 days inside of the halflife 2 mod SDK.. (specifically hl2:dm) and I wasn't terribly impressed with what I found. I ported the urban terror player physics over to hl2:dm so we could all jump in and have a multiplayer game comparing things like the hit detection and lag compensation to what we have under q3.. and frankly q3 won. Hl2's renderer beats q3 silly, obviously, but theres alot to be said for q3's network model.
Hl2's entitys vibrate and shakes around like a washing machine at times, and not to be too blunt but it still feels like q1 with a boob job. The 30 minute full-recompile times for the sdk didn't turn me on too much either.
Hl2's map editor is still mostly brush based, too.

Frozen Sand and Quake 3

Anyways.. I've been unoffically maintaining q3map2 for about a year now (q3map2_fs, quake 3's map compiler), and have an entire sdk worth of code we've invented for urban terror and mx. So we decided it'd be worth our while to port most of the candy from hl2's renderer over to quake 3, and see about updating q3 to 2007 status.

After some research, the specific sore points for us with unmodified q3:
* Lack of scaling. After about 40,000 visible tris, performance starts dropping off nonlinearly.
* Mapping from 3dsmax/maya. We've attempted this a few times, but the hacks we do to get things colliding kill it (collision brushes generated from triangle soup).
* Pixel Shader Candy: No Bloom, No Bumpmaps, No Specular, No pretty water like hl2.
* Md3 Model Format's pretty poor compared to skeletal/ragdoll systems/ Entity Physics/Vehicles

So yeah.. to address each of those points in turn:

Quake 3 And T&L, Surface Merging

Quake3 maps don't scale nicely because it's mostly CPU bound. The hardware it was targeted for was pre T&L (think TNT2 and 3DFx) so good batching habits and rabidly avoiding state changes didn't really exist like it does now. So, I added a new "static" surface type whos geometry all sits inside a big fat Vertex Buffer Object allocated at load time. It hijacks its source data from the Lightmap lit surfaces in the map that arnt using any fancy shaders.. and collapses them together into single draw calls as much as possible.

Ut4_casa started with about 10,000 individual draw calls for the simple lightmapped surfaces, which was about 75% of the total geometry. After collapsing them, it was about 700 calls. Lightmaps are keeping the surface merging process from completely obliterating the Visiblity Culling - by stopping it merging the entire map into single big drawcalls. So it's still working but there's much less agressive culling going on.

It yeilded an average 25-50% increase in framerate anyway :)

We went from being able to throughput about 1.8 million tris per second on my modest 9800 pro/amd3000, to about 2.4-4.0 million depending on the existing urban terror 4.0 map. Special test maps built to be more batch friendly (denser closer packed geometry using fewer shaders, few fancy non-batchable surfaces) scale well into the 6mil+ range. Win.

Mapping from 3dsmax/maya

Hybrid brush/model build maps are just gross - the artists are pushing hard for single-modeling software package based mapping - but even after the updates I've made to q3map2 building an entire map in max for q3 is currently futile.
The lighting compiler is up to the job now (yay smoothing groups and various lighting fixes), but "Autoclip" generated brushes based on map triangles are just a bad idea, and doesn't scale well at all.
The fix will be to move over to some raw tri based collision in-engine, but it's still only a note on my todo list.
Pixel Shader Candy

I've implemented Hl2's radiosity bumpmap solution (courtesy the ati/valve papers on the subject) so now q3 has that.

* Updated q3map2_fs to output 3 basis-normal modifed sets of lightmaps via the -radbump switch
* Updated q3 to load those, various new openGl extensions, and normal maps for diffuse surfaces.
* Draw it with a GLSL compiled vertex/fragment shader, with radiosity bumpmapping and fresnel/cubemap specular.

Highsea (Mike) has been invaluable in getting this working, as this is techically my first ever experience with openGL/glsl - and talk about diving in the deep end. It's not that dissimilar to dx 8/9 which I've done shader work with before.. although I found the d3d documentation to be a good deal more centralized/organized, specifically with creation and setup lifecycle of these fancy new objects. My closet admiration for MS's dev products continues.
I have my crappy test-box rooms out with normalmap generated bumpy/specular goodness working in q3 now... still lots of things to go. Alpha cutouts, generated cubemaps for specular, water and bloom on my todo list next.
Thats it for now, the image uploader/editor for this blog is annoying me.

No comments: