x


Layering multiple 2d images on one texture

What I am trying to do is build a customizeable 2d mech game, where you select armor and parts, and the appearance of your avatar changes accordingly. This means, with a top-down view, I need to layer shoulders, head, legs when walking, etc.

How do I do this? I've looked at Texture2d, and found the SetPixels command, but that seems to be rather clumsy. The only way I can envisage this is to GetPixels from the smaller images, then SetPixels, but as I said, this is rather clumsy.

Is there a better, easier to use way?

more ▼

asked May 06 '10 at 03:17 PM

Zeroth gravatar image

Zeroth
48 14 14 21

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

Hrm. So you've unwrapped entire mechs to textures and then split the model apart so you can have piecewise mechs where for some odd reason you want all the individual pieces to use the same texture file?

The answer from a proper pipeline standpoint is to allow each piece to use its own texture file- as long as you've loaded all the textures into Unity, it shouldn't actually chew up more VRAM to have multiple textures represented in multiple pieces of your mech. You may want to even split out and re-unwrap your mechs as separate pieces that can use separate texture files. This will make everything more modular and less headache-y.

If you really want to stick with compositing multiple parts of multiple textures into a single image, your best bet would be writing a shader that takes multiple textures and a grayscale mask image delineating which pieces of the final uv space to fill from which source image.

If even that would be a stretch, you may be able to somehow composite multiple Decal shaders, each with a texture that is transparent save for the part of the map you need, but I'm not sure offhand if Unity lets you stack render passes like that.

If you want to get REALLY pathological... I suppose you could (on a Pro license) stack up multiple simple full-viewport-sized planes each with an unlit transparent material and a component texture similar to the previous idea, render that to texture via a script, and plug the render result in as your final model texture.

more ▼

answered May 06 '10 at 09:19 PM

sean gravatar image

sean
296 11 12 19

No, I haven't taken apart mech models. This is an old-school 2d style game. :P

May 06 '10 at 10:31 PM Zeroth
(comments are locked)
10|3000 characters needed characters left

You are building a top-down 2d mech game? You could avoid compositing them altogether and draw each piece at a different y height. Let the transparent sorting take care of the composite.

more ▼

answered May 06 '10 at 10:05 PM

Chris Masterton gravatar image

Chris Masterton
474 6 10 22

that, and make sure your camera is set to orthographic so you don't get scaling issues between pieces

May 07 '10 at 02:09 PM sean
(comments are locked)
10|3000 characters needed characters left

If I understand http://answers.unity3d.com/questions/16020/multiple-textures-layered-in-a-single-mesh correctly then you can just make each mech part a different Texture and add a Material for every part/texture.

more ▼

answered Sep 03 '10 at 08:55 PM

Sammual12 gravatar image

Sammual12
63 2 3 8

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2206
x293
x258
x106

asked: May 06 '10 at 03:17 PM

Seen: 3709 times

Last Updated: May 06 '10 at 03:17 PM