Author Topic: HowTo: Recolor a texture conventionally or with an envmap for an "infinite" recolor  (Read 480 times)

Legacy_OldTimeRadio

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


               Even with the variety available to us in Neverwinter it's not uncommon to look at a creature or a placeable or something like that and find yourself wishing for more color variations of the whole thing or maybe just bits of it.

This tutorial will serve as a quick and dirty guide to doing recolors in a traditional way, the inefficiency of the method, and also show you a much more efficient method which allows for making the texture of certain NWN objects "infinitely" recolorable using environment maps- if you're willing to trade shininess for color variation . 

'Posted
Let's say I wanted to get some greenish armor on the Gnoll Warrior (c_gnoll.mdl) instead of the silver colored armor he currently has.  Here is what he looks like and next to that, his texture::
'Posted'Posted

If you wanted to make this modification yourself, your first instinct might be to crack open the image editor of your choice and start fiddling with hue and saturation controls or, if you use GIMP like I do, jump straight to the Colorize tool and go to town!  Unfortunately, here's the first problem you run into: By mucking with the color controls for the whole image, you've tinted everything when you only wanted to tint the armor.  The two images below are the tinted texture and how the model looks in-game:
'Posted'Posted
Okay, to get around that problem we use two layers in our image editor.  The original as one layer and then the tinted version as another, with (say) the tinted layer on top.  Then what we do is erase all the parts of the tinted layer that we don't want to be colored- revealing the original colors in the layer below.  When you save, the layers will get flattened and the resulting texture and model would look like this:
'Posted'Posted
Ok, it looks a lot better now and more like what I wanted. 

But there's a downside and you'll start to notice it if you do more than a few of these recolors on different models: It is very inefficient, spacewise. 

The cost in resources using this method:
- Duplicate the model (111K to 757K, see Amethyst Dragon's reply below about supermodeling)
- Duplicate the texture (342K for DDS, 1,024K for TGA, 1.3M for both)
- Consumes a 2da line, in this case in appearances.2da
Total cost: 450k to 2 megabytes per recolor.  All for just changing about 15% of the texture.

Ten colors would cost you 4.5-20 megs of space, total.

Wouldn't it be nice if there were some way we could perform the same kind of recolor as we did above, but using a much more efficient method?  One that only required us to duplicate the full model and texture once?

Read on...

'Posted
What if instead of actually recoloring the image itself, we dedicated the alpha channel on the texture to the part we wanted to recolor and then assigned a solid color environment map via the appropriate 2da file?  Our new version of the creature (or whatever)  would have to give up whatever environment map the old version was using using but we could then have an "infinite" number of recolors which would only require the duplication of a single model and texture.  The actual space taken up by solid color environment maps is so small (1k), their resource consumption is negligible.

The cost in resources using this method:
- Duplicate the model (111K to 757K, see Amethyst Dragon's reply below about supermodeling)
- Duplicate the texture (342K for DDS, 1,024K for TGA, 1.3M for both)
- Still consumes another 2da line, in this case in appearances.2da
Total cost: 450K to 2 megabytes initial cost, 1k per recolor thereafter.  Ah, that's more like it!

Ten colors would cost you 450k-2 megs of space, total.

The typical drawback to this method is that you're going to be giving up shiny reflections on armor or metal.  Of course the texture will still look like metal, it's just won't have the envmap reflections.  On most things this isn't a huge deal but on some things, like the 1.69 Heavy War Horse, it would dramatically change the look if you made colorable versions.

Below, you'll see an example of this method in action on our Gnoll, using 5 different environment maps from this pack of 55 on the Vault.  Each environment map is just 1k.  They're just little color swatches, basically.
'Posted'Posted'Posted'Posted'Posted

'Posted
1. Pick a creature or placeable (possibly other things, depends on what their alpha is used for), copy and rename the model uniquely
2. Get the highest-quality version of textures the model uses, copy them and rename those uniquely.  Usually it's just one texture.
3. In the new model change references from old texture names to new ones, save
4. Open new texture in the image editing software of your choice (I use GIMP) and add an alpha channel if none is present.  If an alpha channel exists, completely white it out.  Explicit directions on how to open and close the alpah channel in GIMP are at the end of "Refresher, alpha channel" here.  View the image in channel mode.
5. Of the R, G & B channels, identify which one appears to have the most detail in them in regards to the bits you want to color.  If you can, stay away from layers with high contrast .  I usually wind up going with the Red channel, though not always.
6. Copy the selected channel into the alpha channel
7. Invert the image in the alpha channel For most textures, it's imperative that you do this step.  This will put the color on the highlights rather than in the "crevices" of a texture. 
8. Carefully lighten the darkest of the parts you want colored so that they aren't entirely black. Black means no blending and the raw envmap will show through, which we don't want.
9. Using a white brush, white out everything in your alpha channel you do not want to be colored at all.  You can blend, too, for a smoother transition.
10. Recompose the layers of your image and save them as a single 32-bit TGA.  Convert to .DDS if you'd like.
11. Copy original creature's line from appearance.2da into a new line, giving the creature a new name, updating the model name and making sure to add the solid color environment map's name as well.  For appearances.2da, the column for the environment map is called "ENVMAP".  In placeables.2da, it's the "Reflection" column.

Here is the alpha I used for the gnoll in the screenshots, with an indicator of what happens if you leave pieces too dark:
'Posted

 I wanted to use a model from Neverwinter which everyone was familiar with, but here are some much better examples of the method on a Crocman from Titan Quest, all of which are recolors.  Since I'm not coloring armor but skin, the blending is more challenging but the extra time pays off in a smoother, more natural transition:
'Posted'Posted
'Posted'Posted
His texture (with some notes about what to omit or blend) and the resulting alpha channel I created:
'Posted
'Posted


This effect can also be used on placeables.  To give them a weathered look in which they appear to have been painted and the paint has been worn away in places through use, just use white and a scratch brush in your alpha channel.

If you're a little fuzzy on envmaps and the alpha channel, I have a refresher on both here

OTR
               
               

               


                     Modifié par OldTimeRadio, 09 décembre 2011 - 03:47 .
                     
                  


            

Legacy_henesua

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


               Very nice tutorial. I'll see what I can do with this. I've been using a package of recolored pixies and willow wisps, but this sort of modification would improve things.
               
               

               
            

Legacy_The Amethyst Dragon

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


               Minor tip: if recoloring multiples of the same creature model, you can save some file space by using the original one as a supermodel for the others.

Pull your first copy into a plain text editor (which you're already doing to put in the new texture name anyway).  Near the start of the text will be a line that says "supermodel", followed by the model name of your new model and then another (likely "NULL" in your gnoll's case).  Change this "NULL" to the filename for the original model.  Then do a seach for the first "anim" line and you can strip out the parts referring to animations (down to the final "doneanim" near the end).  Save.

This should make your new gnoll (or other creature) use the animations from the original while reducing the file size of the new model considerably.
               
               

               
            

Legacy_shadguy

  • Jr. Member
  • **
  • Posts: 85
  • Karma: +0/-0


               henesua,

If those are the pixies and wisps I'm thinking of, they're a bit of a different case.   They have just recolored emitters - the wisps are nothing but emitters.  The pixies probably use the original texture, and only the wing emitters were changed.  You can have a lot of fun with emitters, but that's another topic.

-shadguy
               
               

               
            

Legacy_henesua

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


               Yup, shadguy those are the ones, your babies. I did not realize that was the case as I don't know anything about emitters.
               
               

               
            

Legacy_OldTimeRadio

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


               

The Amethyst Dragon wrote...
Minor tip: if recoloring multiples of the same creature model, you can save some file space by using the original one as a supermodel for the others.


Thank you, AD!  I updated the numbers and put a note for people to check out your reply.
               
               

               
            

Legacy_MerricksDad

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


               

Refresh my memory, is there a way to remove shiny bits on just part of a weapon model without removing all parts? I have a weapon with two parts which have alpha channels. One part I want to be shiny, the other I want to be transparent. Can I do that with any known method?


 


As far as I can see, on weapons you can't. I've tried playing with the transparency hint. I've tried playing with the txi file. I've tried playing with the three envmap columns in baseitems.2da. Nothing seems to work.


 


What I want is a transparent purple texture to show over another shiny texture, but both be on the same model part.



               
               

               
            

Legacy_OldTimeRadio

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


               

To my knowledge, there isn't.  But, then again, I've only really invested time to try to remove the envmap texture on character model nodes once it's been applied.  There may be some other dynamic at work in regards to weapons.


 


Edit: Wait, that's not true.  I had to give up on a conversion of some Titan Quest weapons because I couldn't pull off what you're trying to.  Definitely don't think it's possible.


 


Edit #2: FunFact: IIRC,  according to the original Bioware Export Scripts MaxScript files, transparencyhint goes up to 5.  What that means, if anything, is anyone's guess.



               
               

               
            

Legacy_Zwerkules

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


               


To my knowledge, there isn't.  But, then again, I've only really invested time to try to remove the envmap texture on character model nodes once it's been applied.  There may be some other dynamic at work in regards to weapons.


 


Edit: Wait, that's not true.  I had to give up on a conversion of some Titan Quest weapons because I couldn't pull off what you're trying to.  Definitely don't think it's possible.


 


Edit #2: FunFact: IIRC,  according to the original Bioware Export Scripts MaxScript files, transparencyhint goes up to 5.  What that means, if anything, is anyone's guess.




If transparencyhint works depends on rendering order. You can have one transparent mesh with transparencyhint 1 in front of say a wall and another one with transparencyhint 2 in front of the first one and you won't see those blueish edges if the meshes are also rendred in that order. If they are rendered in a different order, especially if the wall is rendered after the decals, it doesn't matter what the transparencyhint is set too, you'll always get some nastly blueish edges around the transparent textures.


Since the SAMs of doors are animated, they are always rendered after other meshes like the foliage of trees and you'll always see blue egdes around leaves if there's an open door behind a tree. Not even linking the leaves to an animation node will fix this (and it also makes tilefade impossible for the foliage).


               
               

               
            

Legacy_Pstemarie

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


               


Minor tip: if recoloring multiples of the same creature model, you can save some file space by using the original one as a supermodel for the others.


Pull your first copy into a plain text editor (which you're already doing to put in the new texture name anyway). Near the start of the text will be a line that says "supermodel", followed by the model name of your new model and then another (likely "NULL" in your gnoll's case). Change this "NULL" to the filename for the original model. Then do a seach for the first "anim" line and you can strip out the parts referring to animations (down to the final "doneanim" near the end). Save.


This should make your new gnoll (or other creature) use the animations from the original while reducing the file size of the new model considerably.




 


If you want to save even more space, change all the rendered nodes in the supermodel to "dummy" nodes. I usually do this in a text editor, replacing the term "trimesh" with the term "dummy." I then import and export the model so NWMax can cleanup all the unecessary elements left over from the now-changed trimesh modifiers. Once exported you should have a much smaller file.


 


DO NOT DO THIS TO SUPERMODELS WHERE YOU MIGHT ADJUST THE ANIMATIONS! ONLY DO IT FOR THE FINISHED SUPERMODEL!


               
               

               
            

Legacy_ShadowM

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


               

Just like to add something. When you using the colorize technique mention above you can use the selection tools(Rectangle select tool, ellipse select tool, and fuzzy select tool) to highlight the part of the texture you want to change with colorize and then when you do colorize it will only change the color of what you have selected. Hope this help a little in your workflow. '<img'>