I must really love my job 
I was planning on spending a quiet evening tonight, just relaxing. Instead, I
got sucked into doing work. Go figure. I was just going to spend a little time
doing some research on the scorch marks, trying to figure out why they wouldn't
work. Turns out it was a one liner thingy in the texture stages and I was
scorching like a champ.

The one line fix was to pass the texture coordinates from the first stage on
to the second stage. That simple! It stumped me this afternoon
Anyways, after
mocking it up in EffectEdit (I love this program, I can't wait to dump it in
favor or RenderMonkey). I added it to our code. Here are the results:

Snazzy eh? Well, the scorches look cheap right now. Alex will
take care of that. Also, we can't selectively turn them on or off yet. I'm
trying to figure out the best way to do that. I know one method would be to
encode the different damage levels in the alpha channel. That way, we can turn
on certain marks at certain damage levels. That'll come later. If you're
interested, here are the render states I had to setup for the multitexture
effect.
// Setup the first texture
stage.
// Modulate the color between the diffuse and the texture.
// The diffuse already takes the lighting into account.
pDevice->SetTexture(0, pTexture);
pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
// Setup the second texture
stage.
// The D3DTSS_TCI_PASSTHRU is the important part here. Without it,
// DX9 gives all the vertices texture coords (0,0). That doesn't work
// That'll just flood the whole model with the color at the first
// texel. Ewww...
//
// The rest is pretty straight forward, blend the current values
// with the texture using the textures alpha channel to tell us
// where to draw.
pDevice->SetTexture(1, pDamageTexture);
pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU);
pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BLENDTEXTUREALPHA);
pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
pDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
pDevice->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
// For cleanliness, disable the next stage. Just in case.
// Some strange things can happen if you leave a texture or
// operations in a texture stage.
pDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE);
pDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
[ -------- Render the model
---------- ]
// Again, cleanup. Just in
case.
pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
pDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
pDevice->SetTexture(1, NULL);
If you read the code above, you'll notice that I mentioned
cleanup more than once. Here's what happens if you don't. Maybe this would be a
good candidate for some helper objects that would automatically clear the stage
states when you're done. Ugh, sunspots and cracks in the universe...

While I was at it, I decided to take a look into why our framerate was bad.
Guess what, I got it in one go. We had hardcoded the device to use software
vertex processing instead of hardware vertex processing. DOH! Quick change and
prestO changeO I was back up to 60 frames on my LAPTOP with 4 ships on screen
and a whole bunch of planets giving off light. Don't you love it when a hunch
pays off? I also decided to check out 32 bit color and it works fine too. I
imagine that we'll probably have to go back to 16 bit once we start doing some
Pear text. At least that's what got screwed up in Politcal Machine, but we
should enjoy it while it lasts.
Note to Cari: If we start getting strange bugs, remind me that I
converted to 32bit color. Ok?