Multiple materials for swapping textures

Started by Mospheric, January 03, 2013, 12:01:02 AM

Previous topic - Next topic

Mospheric

So this has proven a bit tricky. I have created a slot machine mesh that will contain two materials. The body is the standard metal, while the screen will contain numerous textures in different game states so we can switch them out to give it an active state.

We have tried several different methods:

       
  • Creating 1 object (containing the body and screen) with 1 multi-material
  • Creating 2 objects (1 for the body, 1 for the screen) with 1 multi-material
  • Creating 2 objects (1 for the body, 1 for the screen) with 2 materials (1 standard for the body and 1 multi-material for the screen)
Got the same results each time... replacing the texture on the multi-material for the screen will replace all textures on the model.


From what I can tell, the only way to create an object where you can switch out the textures is to actually export the body as 1 object with 1 texture. Then export the screen as 1 object with 1 multi-material texture. Then you would would have to manually line them up in the engine when placing them.


Does this seem correct? Thanks for any help!

wallworm

I have added support for that into the current Dev version of WW. I need to test a few things before I release it... but I may have that out tonight.

Mospheric

Awesome! Once the update is pushed, just let me know how I should set up the model in Max, and I'll be happy to do some testing :P

wallworm


Mospheric

So I got the file and checked it out. I didn't know about proxies, and it seems like a handy feature! I'm not sure if this is something that I need to use on my model or not.

Here is the model as I have it in 3ds Max:



Right now I have the body as one object, and the screen as another. I'm using the "Add Sel" button to make them one wall worm model. They do not use the same UVs. Since the body of the machine never has to change, we are trying to just use one texture for that. The screen will be the only thing cycling through textures. Though when our level designer changes the screen texture, it appears all over the model.

Perhaps it's a limitation of Source? I think that may be why when looking at a similar example, a jukebox, it's actually divided into two separate models that you have to align within Source.

Mospheric

Alright, looking through Valve's documentation and lots of threads on Steam, I think I found what I need.

I think I need a texture group that looks like this:

$texturegroup fruit_machine_skins
{
   { "fruit_machine_body"    "body_texture"   }
   { "fruit_machine_screen"    "game_state_01_texture" }
   { "fruit_machine_screen"    "game_state_02_texture" }
   { "fruit_machine_screen"    "game_state_03_texture" }
   { "fruit_machine_screen"    "game_state_04_texture" }
   { "fruit_machine_screen"    "game_state_05_texture" }
}



If this is the final result, how would I go about exporting my model to get a similar result?

wallworm

That's what you should get if you export the VMTs/VTFs from the sample scene I loaded... make sure you have the latest version of WW before testing that. Then export the VMTs. Then the model... and if you open the QC that WW makes you'll see all the texture groups.

wallworm

#7
I should have mentioned that the point of the sample scene is to show how you set up a material for this. I did it like this:

I made a single model with 2 materials as the main material (the multimaterial). I then made three proxies ... which I used only for convenience. Each of those proxies then had its own multimaterial (where slot 1 would override the main material's first material, and slot 2 overrides the second). I then used the Collect Skins from Proxies function in WWMT to set the materials from the proxies as the skins.

This create a new Multimaterial to store all the skins. That Skins multimaterial is applied to the WWMT helper (not the main model). To see what material is on each mesh in the scene, open a new Slate view and use the picker tool to select that material... you'll see the material used for that mesh.

I exported the model's textures and then the model.

Now, in the model's QC it made this section based off of the materials:


$texturegroup "MultiSkinTest3_skins"
{

{  "Skin1base" "Skin1checker" }
{  "Skin2base" "Skin2checker" }
{  "Skin3base" "Skin1checker" }
{  "Skin4base" "Skin2checker" }

}


So by opening Slate in Max, you can then look at the material setup to see how it works.

Hopefully that makes more sense now. :)

Mospheric

Thanks for all your help! I think I got it working. It produced a QC file that looks right. I'm going to hand it off to our level designer and see if it's switching textures how we want it to. I actually bypassed the proxy part and just mimicked your final multi-material that had other multi-materials in it.

I'm still new at understanding source and wrapping my head around concepts. I mostly come from a unity/UDK background where the tools are a lot more user friendly. I definitely wouldn't have made it this far into Source without your exporter. Keep up the great work!

wallworm

I'm glad you got it working.

There are two main reasons I often use the proxies for making skins:

1) You can see multiple skins all at once in your scene.

2) It is really convenient if you are generating your textures inside of 3ds Max because you can simply Render To Texture a Proxy as a new Skin OR Paint a new texture with the Viewport Canvas. Of course you have to be careful to set each new Proxy to have a new material so that when you alter its material you aren't over-writing the existing materials.

Anyway, these are just tips.

SMF spam blocked by CleanTalk