Game Development Community

dev|Pro Game Development Curriculum

Plan for James Lupiani

by James Lupiani · 10/26/2002 (5:49 pm) · 6 comments

I've been playing on and off with a multipass/multitexture material system for Torque. I'm testing it using Melv May's fxRenderObject framework, and once I'm satisfied with it I intend to expand it for use in interiors and shapes.

I had a sudden inspiration while playing with the in-game tools one day that it'd be possible to use datablocks to define texture stages. So my class is actually a datablock, and optimized for network transmission. This could allow a server to specify special materials (team colors or logos perhaps?) and clients will receive them upon connection. Well, it was just a hunch. The nice thing is it fits right into the conventions that Torque uses already, and you can mess with them on the fly while the game's running. Plus, you can group a bunch of datablocks together in a script file and use them as a library or theme.

It's been a good exercise in learning the nitty gritty of multitexturing, which I've never had a chance to play with before. First I planned out what I wanted to do--which basically boiled down to something like Q3A shaders. After talking with some community members, I decided to leave out animation features, at least for my first attempt. The idea is to supplement the existing rendering without getting totally replaced whenever someone comes up with vertex and fragment shader stuff for Torque.

It actually has two implementations. First I got it working with multipass and limited blending modes, then earlier this week I got multitexturing working...at least, partially. Something's weird with it, and it won't blend more than two stages (I have a Radeon, 3 TUs). But enough tell, here's the show:

static.flyingtemple.com/materials.jpgHere I've blended a little glow texture with a larger background texture using simple blend functions.

static.flyingtemple.com/material.jpgAnd here I've used that same larger texture as a detail map on the grass texture that comes with torque.

The way it's defined is a little messy, it's very much programmatic. I hope to come up with a more elegant solution for doing it at some point. Here's the datablock used for that second screenshot:

// Example Staged Material
datablock MaterialData( MyTestMaterial )
{
    // STAGE 0 ------------------------
    // Main texture
    texture[0]      = "~/data/terrains/grassland/grass";

    // STAGE 1 ------------------------
    // Detail map
    texture[1]      = "~/data/terrains/metal/metal2";
    texMode[1]      = combine;
    colorMode[1]    = modulate;
    colorArgA[1]    = previous;
    colorOpA[1]     = src_color;
    colorArgB[1]    = texture;
    colorOpB[1]     = src_color;
    colorScale[1]   = 2.0;
    alphaMode[1]    = replace;
    alphaArgA[1]    = previous;
    alphaOpA[1]     = src_alpha;
};

So yeah, a little messy. But it's a lot of fun to mess with so far. ;-)

#1
10/26/2002 (11:17 pm)
Pretty darn cool... Good luck getting it hammered out, those are drool worthy screenshots ;) I like the integration with Torque and the programmatic bits, too... Then again, I'm a programmer, so... ;) At least that way, it's not too hard to write an editor, like people did for Q3A shaders.

Incidentally, I noticed that your GUI stuff has a neat rounded blue theme... I want to redo the default theme stuff but am not really sure where to start. Did you do that yourself? Any wisdom for a programmer who wants to put his meagre art skills to work?
#2
10/27/2002 (12:13 am)
One word James: Rock! Look forward ta' seeing this in the engine - could be really slick!
#3
10/27/2002 (12:49 am)
I'll say it again, good stuff Defiant :o)
#4
10/27/2002 (1:27 am)
Deffy!! :) That looks great!! Looking forward to see that in the resources! ;)
Keep it up!
- beffy
#5
10/27/2002 (5:03 am)
Great work Defiant, the new datablock type to make the materials is a great idea!
Expecting to play with it soon :)
#6
10/27/2002 (3:42 pm)
Thanks guys! =) I'll try to get all the kinks worked out in a timely fashion.

Ben: Actually, that was kind of an in-between stage for my GUI. I've redone the title bar and buttons now, too. I'm trying to get a darker look to it overall. Unfortunately I'm having trouble getting some of the GUI components to listen to their profiles. I fear I'll have to dig in deep or rewrite all the profiles before I figure out what's wrong. My philosophy for my skin: keep it simple and do it a pixel at a time so it's not sloppy. And a tip that will save you time: always be consistent with the size of your bitmap arrays. Otherwise it'll probably blow up on you.