Advanced textures

I’m trying to to implement a sort of “embedded hud” in to my game where hud elements are on the model (kind of like dead space). this is the character in question: http://i.imgur.com/QljvB8ph.png

the orange dots on his backpack represents how much ammo he has (8 shots), and I want the orange dots to turn black when he uses that ammo.

However, i can’t really think about how to do this. The character is just a single geometry with a single texture.

The brute force way I guess would be to have 8 model textures with each level of ammo (though I suspect this wont work well as you gain and lose ammo constantly throughout the game). I cant really think of any other way. (i want to avoid anything that requires the use of scene processors or dynamic lighting as I want the game to be runnable on computers with integrated graphics)

You could use the ImagePainter plugin to modify the texture. Or you could add a child object to the backpock option which adds the orange/etc dot. Or you could do a custom shader and pass in the number to that somehow.

Most efficient is probably just modifying those texture coords to either reference the yellow part or black part of the texture based on the current ammo level… However it is a bit hack-ish.

Another, perhaps more artist friendly way is using lightmapping as a 2nd texture layer which is replaced with the texture that represents the corresponding ammo amount (you would need 8 textures for this).

ImagePainter is also a possibility, but then the texture data would need to be sent every time the ammo amount changes. Not as efficient as the other two ways.

It sounds like you guys are both suggesting something similiar. Is it possible to use ImageRaster and/or ImagePainter to select areas of a one texture and copy that to replace the x/y area of another? (most of the methods i seen in the javadoc seems to be based around setting pixels, havent had a chance yet to really experiment with either classes)

When you say that doing this is “hackish” do you mean that it might not perform well/look good when changing textures? or just that itd require a lot of ugly code to handle all the swapping of texture coords?

@icamefromspace said: It sounds like you guys are both suggesting something similiar. Is it possible to use ImageRaster and/or ImagePainter to select areas of a one texture and copy that to replace the x/y area of another? (most of the methods i seen in the javadoc seems to be based around setting pixels, havent had a chance yet to really experiment with either classes)
Yes, it is possible.
@icamefromspace said: When you say that doing this is "hackish" do you mean that it might not perform well/look good when changing textures? or just that itd require a lot of ugly code to handle all the swapping of texture coords?
You have to know which texcoords to change. Communicating that information through your typical model editor might be difficult (might have to encode it into some other vertex attribute for example)

Yeah, artist’s pov, let forget the textures stuff! (This is another way arround)
Make a separate 3d model for that 8 ammos with it own texture:

  • 8 geometries more
  • about 64 tris more
  • 32x32 texture
    Your artist will thank you infinitely when they have to modify them.

To shut a single ammo, turn its texture to gray, or remove the geometry your choice. No hard code on TexturePainter, nor 2d manipulating, or saved coordinate whatever (sound good?)

ImagePainter is a plugin that uses ImageRaster and provides a lot of functionality - including things like painting one Image into another Image.

Thanks for the responses guys. We ended up actually deciding that the camera was too far away to actually see all 8 orange dots/count them quickly (i moved the camera in quite a bit just to show the screen shot in my OP)

However now that I know about ImagePainter (and ImageRaster) I’ll know what to do next time I need to do this kind of texture modification.

Atomix is probably right, we should probably have a seperate model just for the ammo count count/backpack/thing. This was sort of an after-the-fact idea we had while we’ve been trying to decide what the HUD system should be. For this game its probably just a bad idea.