Author Topic: HowTo Display a TGA & PLT on the same body part at the same time using TXI's "bumpreplacementtexture" command  (Read 1287 times)

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0


               Last month's Custom Content Challenge had me drawing a blank so I punted.  Twice, heh heh.  A few weeks after I'd created my submissions, I had some free time to try again, hopefully to make something a little more like what was actually requested.  About the same time I came across a thread about necklaces and in there TheSpiritedLass was talking about retexturing some of Estelindis' beautiful necklace neck pieces.  JediJax suggested it would be cool to get some Forgotten Realms diety symbols on them and it sounded like a great idea to me.  With all these beautiful images to choose from, it was a slam dunk and I could finally make something which fit the bill for the challenge!

Except...texturing body parts doesn't work like that.  Each body part has one texture, which is a PLT which has the same name as the model.  If you add geometry to the model and give it a different texture, in-game it will override your choice and use the PLT instead.

'<img'>

So what looks like this in G/Max:
'Posted

Winds up looking like this, in-game:
'Posted

And that is a big sloshing bucket of No Fun.  In fact, if you want to add a bit of geometry like that not only do you have to edit the PLT for the body part and add the texture, but you have to PLT-ize the texture.  Looking at some of those Forgotten Realms holy symbols I link to at the top of this message, it probably would have taken hours to convert just one of those images to PLT and squeeze it into the bodypart's PLT, shifting around the UVW's to make space for it.  And even then, the color range available with PLT is so much more limited than 24-bit color that it probably wasn't even going to be worth my time to make a proof of concept piece.

So, what had started out as a "slam dunk" idea quickly took a high-dive into the crapper as "impossible".  Ugh.

However, as luck would have it, I have been spending a lot of time exploring a set of undocumented TXI commands which I culled from careful study of the strings contained in NWMain.exe and trying my best to find out what they actually did.  Surrounded by a crackling aura of TXI magic and knowledge of the Aurora engine, I was able to come up with a solution which is very simple and which allows you to add additional geometry to your body part model and use TGA or DDS textures for it.  So you can have both PLT and TGA/DDS textures present on the same model (though obviously on different meshes) at the same time.

Here is how the solution works:
If you've watched my animated texture tutorial on YouTube you'll recall that we look at both virtual emitter planes and regular geometry as a target for our animated textures.  And that during the tutorial, virtual emitter planes come out ahead until the last installment where we see how deeply the TXI system hooks into the NWN graphics subsystem and how it can override any texture if we slip in a TXI file of the same name.

Even though we see in the above pictures that NWN overrides our choice of textures and uses the PLT texture with the same name as the body part, it turns out that deep-down NWN remembers the name of the texture we wanted it to use.  If we supply a TXI with the same name was the texture we applied in G/Max, NWN will read it in and execute any commands in it.  This is our "in".  And by putting the following command into a TXI file, we can make NWN override itself and use the texture we specify:
bumpreplacementtexture (name of texture, TGA or DDS without the extension)

In other words, let's say we want to display texture B on our mesh.  We apply texture A to our mesh in G/Max and create a TXI file with the same name as texture A which points to texture B.  NWN loads up the body part model, paints the regular bodypart with the PLT, comes to our mesh, sees texture A's name, looks up the TXI for texture A and is redirected to use texture B.  Clever, eh?

So here's my model in G/Max with the sacrificial texture applied:
'Posted

And with the TXI pointing to the real texture, this is what you get in-game:
'Posted

This is the workflow I use:
1. In G/Max with my bodypart loaded, I introduce whatever new geometry I want.
2. I apply the texture I'm going to want displayed in-game to that new geometry and make sure the UVW mapping on the mesh is to my liking.
3. I then apply a "sacrificial" texture to the same mesh, overwriting the texture I want to be displayed in-game.  I use a very small (32 x 32) TGA texture which only takes up about 5k.  The sacrificial texture is so-called because it is never displayed, only used to trigger the TXI-lookup functionality. Then I export the model.
4. I make a TXI with the same name as the sacrificial texture and use the bumpreplacementtexture command followed by the name of the texture I want to display in-game.

That's it!

And what about that necklace idea that spawned all this? In Max, I enlarged Estelindis' necklaces, sliced out the amulet face into a separate mesh to which I applied the above system and presto:
'Posted
Metal rim, cording, skin, etc. on her necks are still PLT but the actual medallion face is TGA and so I get the full benefit of 24-bit color without the hassles of the past.

But why stop there?

What if, for instance, the texture I want displayed in-game also came with a TXI of its own?

Would NWN load that TXI and act on it as well?

Yep.  You can keep chaining textures out via TXI as far as you need.  Which indicates that all other TXI functionality can be used with this system, including proceduretype cycle.  Which means you can have animated textures on your bodyparts as well!

Like this:
'Posted

There are other ways, like VFX, to get models onto a player.  This system works best for jewelry like Estelindis' necklaces and how much more useful it is than say, VFX, depends on what you want to do.

These are some Fallout 3 helmets straight-up converted to NWN.  They took about 3-4 minutes each (max) for the raw modeling changes.  Though they could have just as easily been a resized Gnoll or Fire Giant helm.  Or a helmet from Dragon Age or Oblivion.  Or BioShock 2.  If you can load up a model into G/Max, and it has a diffuse texture, then there's nothing really stopping you.  And that brings the FacePunch candy store one step closer to NWN.
'Posted'Posted
'Posted'Posted

OldTimeRadio
               
               

               


                     Modifié par OldTimeRadio, 13 mai 2011 - 07:48 .
                     
                  


            

Legacy_Zwerkules

  • Hero Member
  • *****
  • Posts: 1997
  • Karma: +0/-0


               Thank you so much for this information OldTimeRadio!
I never worked with body parts because I don't like plts and there was no obvious way to use tgas for them. Your method of adding parts that use tgas adds so many new possibilities to making body parts. Finally we can have leather that actually looks like leather!
               
               

               
            

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0


               You're welcome!  Hopefully the system will wind up being as solid as it seems to be so far.  I should also add that the same system works fine for forcing a bodypart model to use a TGA/DDS instead of a PLT.  No need to create a sacrificial texture in that case, just make a TXI with the same name as the model/PLT and point it to the texture you'd rather it use.
               
               

               


                     Modifié par OldTimeRadio, 13 mai 2011 - 08:51 .
                     
                  


            

Legacy_Frith5

  • Hero Member
  • *****
  • Posts: 595
  • Karma: +0/-0


               Holy WOW, as they say in da U.P., eh!
               
               

               
            

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0


               Hmmm this could be interesting, I'll look at it in more detail when I have some time.
               
               

               
            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0


               And thus, OldTimeRadio opens a full can of Oh, Hells Yeah on the NWN custom content community.
               
               

               
            

Legacy_Bannor Bloodfist

  • Hero Member
  • *****
  • Posts: 1578
  • Karma: +0/-0


               

The Amethyst Dragon wrote...

And thus, OldTimeRadio opens a full can of Oh, Hells Yeah on the NWN custom content community.




Heh... he has a habit of doing that quite frequently!

Great find, and things will open up even more as folks experiment with the TXI commands.

Thank you OldTimeRadio, for another VERY useful idea, complete with instructions on how to implement it!
               
               

               
            

Legacy_OldMansBeard

  • Full Member
  • ***
  • Posts: 245
  • Karma: +0/-0


               Wow! Thank you, OTR, it's just what I need for ... er ... something I'm doing.

*OMB looks shifty*
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0


               Great job OTR...
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0


               Great job, you are really the true master of CC OTR!
               
               

               
            

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0


               

ShaDoOoW wrote...
Great job, you are really the true master of CC OTR!

Psshhh!  Don't jinx me!

'<img'>
               
               

               


                     Modifié par OldTimeRadio, 14 mai 2011 - 05:25 .
                     
                  


            

Legacy_Aurdae

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0


               I do believe this might have uses outside of body parts. *will be testing* ':devil:'
               
               

               


                     Modifié par Aurdae, 15 mai 2011 - 05:41 .
                     
                  


            

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0


               Alright, I'm not a modeller, I tinker at the best of times.


Anyhow I've been staring at this all day and I'm wondering if it's possible to use two PLT textures and two TGA with the TXI combine. Pictures are worth a thousand words.

'Posted

As of now there are 4 meshes with 3 TGA textures. I am looking at taking mesh 2 and 4 and trying to convert them to PLT. Am I in the realms of impossible here?  I suppose I need to mention that 2 and 3 are using the same texture file at the moment.
               
               

               


                     Modifié par Calvinthesneak, 15 mai 2011 - 08:58 .
                     
                  


            

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0


               

Calvinthesneak wrote...
Anyhow I've been staring at this all day and I'm wondering if it's possible to use two PLT textures and two TGA with the TXI combine. Pictures are worth a thousand words.
As of now there are 4 meshes with 3 TGA textures. I am looking at taking mesh 2 and 4 and trying to convert them to PLT. Am I in the realms of impossible here?  I suppose I need to mention that 2 and 3 are using the same texture file at the moment.

Right now, the only way I know of to display 2 PLT's on the same bodypart at the same time is to combine both PLT's (side by side, for instance) into one image and then use that.  So if you have 2 PLT's which are both 64 x 64, you'd be combining them into one PLT which was 128 x 64.  I think the only hassle you'd have to deal with, in that case, is that you'd have to move the UVW mapping for the added mesh 64 pixels to the right so it overlays the correct portion of the PLT.

Using my method you can add multiple TGA/DDS texture but pointing a sacrificial texture's TXI to something that exists only as a PLT seems to produce just whiteness on the selected mesh. (shrug) Still lots of undiscovered land out there, though, and lots of untried experiments.
               
               

               
            

Legacy_Zwerkules

  • Hero Member
  • *****
  • Posts: 1997
  • Karma: +0/-0


               

OldTimeRadio wrote...

I think the only hassle you'd have to deal with, in that case, is that you'd have to move the UVW mapping for the added mesh 64 pixels to the right so it overlays the correct portion of the PLT.


Both meshes would have the whole texture applied after you joined the two textures, but there is a modifier that allows to change the uvw mapping so they both show the right parts of the texture.
 
Let's say that mesh A uses the left half of the texture and mesh B uses the right half.
Now you apply an uvw xform modifier to mesh A. The modify tab will now show a number of input fields.
Where it says 'U Tile'  you have to change the value shown there (probably 1.0) to half of what it is.
So if it is 1.0 change it to 0.5. Now the mesh will use the left half of your new texture.

Do the same for mesh B. You want this one to use the right half instead of the left half, so you  enter 0.5 where it says 'U Offset'.

If you had made a texture that had one texture below the other one instead of to the right of it, you could do the same as described above only this time you'd change 'V Tile' and 'V Offset'.