Wrapping 2D textures/bitmaps around objects

I had a question concerning 2D textures and bitmaps, specifically ones being applied during gameplay. In this circumstance, we have 2D textures being “plastered” onto the existing world mesh/game objects in the map, i.e. objects exits launcher, collides with wall/tree/other game object, destroys itself, and leaves various size textures. Depending on the size of both the wall/tree/other object and the texture (determined by a random number generator), is it possible to wrap the texture or project past the object onto background objects/walls/trees (silhouetting)?

For example, the object collides with a tree, but the texture is wider than the trunk. Is there a way to make the parts of the texture that do not directly overlap the tree mesh project past it onto a wall that would be right behind it?

Would it also be possible to make the texture “wrap” around objects instead of silhouetting, or to bend to an angle in a wall? Not only this, but would we be able to make the texture conform to inconsistent shapes such the trees?

Any and all help with any of these issues/questions would be greatly appreciated in any level of detail or complexity.

You’ve seen a 3D game before right? You’ve seen how the 3D objects have textures and these textures wrap around the object? So yes you can map texture to 3D objects such that they wrap around the shape.

The difficulty in your case would be determining which parts of the textures to put on which parts of the objects. You may also need to increase the detail of your meshes if you want things to splatter in complex ways across multiple objects. Really depends on exactly what you are trying to achieve.

For a start take a look at some decal shaders.

Specifically, if a bullet were to hit a 5 by 5 square, and the texture was, say, 7 by 4 units, we would want the overhanging parts of the texture to be cut off so it only covers the part of the square it hit, and not have texture hanging off the sides in space, without wrapping around (this decision determined after some discussion after the question was initially asked).

Sounds like you want a decal system, i have seen some on the asset store that sound like they do what you need.

Karl

To be precise, I know there are two and the one that costs money is not anymore maintained.

To transfer a texture across multiple objects, here is what I would do:

Perform a Physics.RayCastAll() or something simliar to get all of the objects that the projectile will interact with.

They should be sorted by distance, and in this case you should iterate through them from closest to furthest.

Calculate what segments of the texture should be applied to the first object, transfer those pixels and then on the original texture, mark those pixels as alpha = 0 (or some kind of ‘dead’ pixel value to use). Then when you move onto the next object in the trajectory path, only transfer pixels that have not been marked as dead pixels. That way it should appear that the texture disintegrates as it flies into objects.