Aller au contenu

Photo

HowTo Display a TGA & PLT on the same body part at the same time using TXI's "bumpreplacementtexture" command


  • Veuillez vous connecter pour répondre
31 réponses à ce sujet

#1
OldTimeRadio

OldTimeRadio
  • Members
  • 1 400 messages
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.

:(

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

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

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 Image

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

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 Image
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 Image

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 ImagePosted Image
Posted ImagePosted Image

OldTimeRadio

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


#2
Zwerkules

Zwerkules
  • Members
  • 1 324 messages
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!

#3
OldTimeRadio

OldTimeRadio
  • Members
  • 1 400 messages
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 .


#4
Frith5

Frith5
  • Members
  • 381 messages
Holy WOW, as they say in da U.P., eh!

#5
Calvinthesneak

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

#6
The Amethyst Dragon

The Amethyst Dragon
  • Members
  • 1 881 messages
And thus, OldTimeRadio opens a full can of Oh, Hells Yeah on the NWN custom content community.

#7
Bannor Bloodfist

Bannor Bloodfist
  • Members
  • 940 messages

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!

#8
OldMansBeard

OldMansBeard
  • Members
  • 152 messages
Wow! Thank you, OTR, it's just what I need for ... er ... something I'm doing.

*OMB looks shifty*

#9
Pstemarie

Pstemarie
  • Members
  • 2 745 messages
Great job OTR...

#10
Shadooow

Shadooow
  • Members
  • 4 471 messages
Great job, you are really the true master of CC OTR!

#11
OldTimeRadio

OldTimeRadio
  • Members
  • 1 400 messages

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

Psshhh!  Don't jinx me!

:P

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


#12
Aurdae

Aurdae
  • Members
  • 1 messages
I do believe this might have uses outside of body parts. *will be testing* :devil:

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


#13
Calvinthesneak

Calvinthesneak
  • Members
  • 656 messages
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 Image

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 .


#14
OldTimeRadio

OldTimeRadio
  • Members
  • 1 400 messages

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.

#15
Zwerkules

Zwerkules
  • Members
  • 1 324 messages

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'.

#16
Calvinthesneak

Calvinthesneak
  • Members
  • 656 messages
Ummm yeah... my 3d modelling skills don't extend that far. I have followed various UVW tutorials and never gotten them to work satisfactorily for NWN. Granted I have no experience save tinkering with 3ds. I probably need to start from the beginning and learn all of this the right way.

#17
OldTimeRadio

OldTimeRadio
  • Members
  • 1 400 messages
@Zwerkules Thanks for that!

@Calvinthesneak Since you don't have so much experience in the UVW aspect, you could always start out with your model just using TGA/DDS textures and then PLT-ize some of the textures later, when you're more comfortable.

One thing I like is that if I want to bring a model into NWN I can always bring it in as a "creature" so I don't have to deal with the PLT side of things. If you look at c_yinnkeep.mdl it's your basic standard male but it is very easy to edit and doesn't have PLT textures. No mucking around with separate body parts or PLT's or any of that. Assuming what you took the screenshot of was a model with a (TGA) texture, you could get away with getting c_yinnkeep.mdl in G/Max, then resizing that new head till it was about the same size as c_yinnkeep.mdl's head, doing a ResetXForm on it, then just attaching the new head to the old one or, if you had named the new head correctly, you could attach it to the neck and delete the old head.

I was just doing this this afternoon as you can see the original neck peeking though.  My character wears the new head like a "helmet" but if you did the same thing on an NPC model like the one I mention above it's very quick:
Posted Image
In your case it gets a model in-game and then you can refine it if you still like the look or ditch it and move onto something else if you don't.  No worries about swapping around UVW mapping/PLT and that stuff unless you want to stick with the conversion, though the texture names might be too long and those just need shortening and re-application onto the model (drag and drop onto it) from G/Max.

Modifié par OldTimeRadio, 15 mai 2011 - 09:02 .


#18
Estelindis

Estelindis
  • Members
  • 3 700 messages
Yes!  Freaking revoluationary!  This opens up so many possibilities!  :o  (Please excuse the excess of exclamation marks - this is just that awesome.)  I wonder if this allows for transparency in the TGA texture?  There are lots of shortcuts one can take in order to create detailed-looking hair with many wispy bits if one uses a texture with transparency...

Incidentally, I've already PLT-ised the whole FR pantheon's symbols in my cloak collection, and it did take a very long time - plus I had to accept certain limitations due to the limitations of the PLT format.  This new method libeates us from such slavery.  Hurrah!

#19
OldTimeRadio

OldTimeRadio
  • Members
  • 1 400 messages

Estelindis wrote...
I wonder if this allows for transparency in the TGA texture?

Yep.  I don't have a screenshot but I had targeted another one of the exported Planescape:Torment animations onto one of your medallion's faces and the alpha seemed to work fine.  Also, in the video I link to, that animation also shows alpha transparency.

  There are lots of shortcuts one can take in order to create detailed-looking hair with many wispy bits if one uses a texture with transparency...

I'd love to see some hair using that sort of technique especially if it could be combined with danglymesh, which it should.  If you find that transparency settings you make on the AuroraTrimesh modifier are not being respected or behaving unexpectedly, remember that there are also alpha-related TXI commands which may be needed to get the desired effect.  And I guess if you were doing that you'd want to put those commands into a TXI file for the desired texture and not the sacrificial one.  Can't wait to see what you come up with!

Modifié par OldTimeRadio, 16 mai 2011 - 02:19 .


#20
OldMansBeard

OldMansBeard
  • Members
  • 152 messages
I can get transparent holes in tga overlays to work if envmapping on creatures is turned off in the client, but otherwise I just get shiny. Setting an envmaptexture in either or both of the txi's doesn't seem to override that. Am I missing something ?

#21
OldTimeRadio

OldTimeRadio
  • Members
  • 1 400 messages

OldMansBeard wrote...
I can get transparent holes in tga overlays to work if envmapping on creatures is turned off in the client, but otherwise I just get shiny. Setting an envmaptexture in either or both of the txi's doesn't seem to override that. Am I missing something ?

You're right, OMB.  I just looked in my own client and environment mapping was off.  A few days before getting into tinkering with this I had been working on a method of getting bumpyshiny onto a shield but I was running into a problem where I believed the envmap on the player (or the tileset or...(?)) was causing an unwanted effect which caused some bizarre problems with the GUI & game.  My blog entry "Shinywater on a shield- but not without problems" has a video attached which you can see the bumpyshiny effect and also the problem associated with it.  Anyway, I must've turned it off during those experiments and forgotten about it.  :(

If you wanted to take a stab at tinkering, these were some untested ideas I had about what kinds of things might be tried to either remove an envmap or negate it in relation to my problems with the shield which might be applied to the problem of envmap on the 32-bit TGA mesh.  You're probably more familiar with how some of these work than I am but I'll toss them out anyway:
* isenvironmentmapped- Boolean, I assume, maybe can set to false to turn off?
* envmap - directed to a purely transparent TGA
* cube - TXI with cube 1, filerange 6 pointing to TGA's 0-5 which are also purely transparent
* alphamean - Zeroed out alphamean added to TXI for the above cube and envmap suggestions.  I haven't used this one much, I believe that would make it as transparent as possible.

And, of course, anything which might be applied via an AuroraTrimesh modifier.

If a workaround via TXI can't be found to get rid of that envmap, and if the problem really is caused by the default environment map listed in appearance.2da, then it might require making a new phenotype with ENVMAP set to "****" or testing with a creature appearance without an ENVMAP to at least see if the idea is going in the right direction  Hopefully it won't come to having to make a new pheno just to solve an envmap problem but there's a fallback system for phenos which might be able to get around the worst of it.

Don't have too much time this morning to test these ideas out and some of them migth just be flat-out wrong suggestions but my RL took a turn for the ultra-weird yesterday so I'm a bit scatterbrained at the moment:  I'm selling a bit of property with a building on it which is next to my house.  And there's a buyer who seems really interested in it.  So interested, it turns out, that he was driving by the property at 3AM Sunday morning and noticed there was someone breaking into the building.  He confronted the burglar, thinks the burglar might have a gun, drives off and calls the police.  Police come and arrest the burglar and all the day before the buyer is to be shown around the property for the first time, today!  :blink:

Modifié par OldTimeRadio, 16 mai 2011 - 02:54 .


#22
s e n

s e n
  • Members
  • 408 messages

OldTimeRadio wrote...

If a workaround via TXI can't be found to get rid of that envmap, and if the problem really is caused by the default environment map listed in appearance.2da, then it might require making a new phenotype with ENVMAP set to "****" or testing with a creature appearance without an ENVMAP to at least see if the idea is going in the right direction  Hopefully it won't come to having to make a new pheno just to solve an envmap problem but there's a fallback system for phenos which might be able to get around the worst of it.


i think 2da edit to disable evironmental maps on the creature is the only way to get transparencies on creatures, correct me if im wrong
about an year ago i tried to cook a water texture that has both reflection (envmap) and transparency layer, but i couldnt succeed, it seems the alpha layer of the tga is used for transparency as default (if there is no txi info), but if you add a txi to tell him to reflect the envmap or whatever other effect, the txi gets informations from the alpha layer and so your transparency will go to BLEEEPP!

#23
OldMansBeard

OldMansBeard
  • Members
  • 152 messages

OldTimeRadio wrote...
...

* isenvironmentmapped- Boolean, I assume, maybe can set to false to turn off?
* envmap - directed to a purely transparent TGA
* cube - TXI with cube 1, filerange 6 pointing to TGA's 0-5 which are also purely transparent
* alphamean - Zeroed out alphamean added to TXI for the above cube and envmap suggestions.  I haven't used this one much, I believe that would make it as transparent as possible.
...


I've tried three of those -
isenvironmentmapped 0
envmaptexture <a completely transparent tga>
alphamean 0

in txi's for both the sacrificial and the real textures and - it doesn't turn off shiny. :(

For my purposes, turning off the envmap on the appearances would be no hardship - provided I can do the opposite  and provide an envmap when I do want shiny.

#24
_six

_six
  • Members
  • 919 messages
I did some messing around with this with Project Q, when we were trying to create a wearable masks item type. Getting armour parts to use tga textures instead of plt is pretty easy - as well as this method, you can also just name the model incorrectly internally and it will confuse the engine into using whatever textures you specify instead.

Getting such a model to support alpha transparency, is a different matter. TXI files' alpha settings are completely ignored for this - as is the envmap column in baseitems.2da. The only way to remove shininess appears to be to disable it on the entire creature from appearance.2da. Which means you then have to edit the colour palettes to have no alpha channel, or else your metal armour becomes transparent.

Modifié par _six, 17 mai 2011 - 02:36 .


#25
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
Im very confused but ummm................Go team! :)