Dynamic Skins (Palette Swapping)
by Jonathan Flom · in Torque Game Engine · 04/19/2002 (3:56 pm) · 2 replies
We are currently trying to devise a method to implement dynamic player model skins. What I mean by this is that we are trying to set certain areas of the player model to be able to do palette swaps, such as hair and skin color. We only need this to happen once - when a player creates their character. Any ideas on methods to accomplish this task, from both a coding and art standpoint?
Thanks
Thanks
About the author
#2
Depending on exactly the effect you're looking for however, this approach might be tedious for the content creator (for example if the skin area needs to have thirty different shades) and/or have performance problems (for example if you need to continuously and rapidly make the changes, altho this isn't the case for Jonathan apparently). So in some situations it could be more convenient to be able to programmatically change the skin. You could actually borrow some of the skin-swapping code to get started with this; instead of the server sending the client a tagged string ID for the name of the skin to swap to, it would send some other information, like perhaps the shade to change to.
The interesting part would be getting the client to do the necessary things with that info. The clent could take the TextureHandle for the skin texture, do a getBitmap to get at the actual texels, and programmatically modify them. If you're modifying the whole texture, you're pretty much home-free at this point.
If you want to modify only part of the texture, the best approach would be to have an associated "mask" bitmap that specifies which texels to change, so in that case you'd have some more work in front of you.
04/21/2002 (10:34 am)
Yeah, you could use the skin resource code I posted to swap in and out pre-created skins for various sections of the model. I'd recommend that if you have a fairly limited set of different possible textures to choose among.Depending on exactly the effect you're looking for however, this approach might be tedious for the content creator (for example if the skin area needs to have thirty different shades) and/or have performance problems (for example if you need to continuously and rapidly make the changes, altho this isn't the case for Jonathan apparently). So in some situations it could be more convenient to be able to programmatically change the skin. You could actually borrow some of the skin-swapping code to get started with this; instead of the server sending the client a tagged string ID for the name of the skin to swap to, it would send some other information, like perhaps the shade to change to.
The interesting part would be getting the client to do the necessary things with that info. The clent could take the TextureHandle for the skin texture, do a getBitmap to get at the actual texels, and programmatically modify them. If you're modifying the whole texture, you're pretty much home-free at this point.
If you want to modify only part of the texture, the best approach would be to have an associated "mask" bitmap that specifies which texels to change, so in that case you'd have some more work in front of you.
Torque 3D Owner Xavier "eXoDuS" Amado
Default Studio Name
You would then use Joel's code (in the resources section) to change the skins dynamically from scripts
Easy task :)