Ability to manipulate texture contents on-the-fly for easier customization

There is a problem with the current implementation of textures. Lets say I want my game to have a customization system where the user can choose there mouth shape and color, nose shape, and eye shape and eye color. Currently I can do that by having a insane amount of textures covering every single possible combination of outcomes, or I can make my face 3 separate meshes, where the mouth and eyes have every shape and color combination. Nither of these options are ideal which is why I am requesting a basic image editing library.

To over-simply my request, I think the ability to recolor and combine multiple images together using different blending techniques would allow developers to do a lot more with there game.

The simplest way I can conceive of to give any system such as this the flexibility required would be as such, though that is not to say that there is no alternative. As I am most familiar with C#, I will be using a similar syntax to convey my thoughts.


Details on my suggested implementation:

A new object called image with the following attributes and methods.{
xSize: the number of pixels that make up the image in the x dimension
ySize: the number of pixels that make up the image in the y dimension
opacity: How transparent a solid pixel is.

New(image asset id):Generates a new image object containing the image found in the asset id
Generate():Returns a new image asset ID for the image stored within the image object
Scale(double): takes a double and rescales the image accordingly
Scale(double X, double y): takes two doubles and scales the x and the y separately
SetOpacity(double input): sets the opacity of the image

Cut(int xStart, int yStart, int xSize, int ySize): Returns a new image object that consists of the pixels found after the start values and before the start values + size values.
Erase(int xStart, int yStart, int xSize, int ySize): Similar to cut, but replaces the pixels in the original with completely transparent pixels.

Stack(image object, string blendType, int xStart, int yStart): Sticks a image ontop of itself at the start chordates, using the blend method provided (various blend methods might be blend, overwrite, lighten, and darken though there is a bunch more that could be implemented)
}

Templates, a child object of image, but only accepts images that are black and white. The black portions would be recolor able, the white would be alpha. This object would be extended with the following methods.{
Recolor(RGB): takes a rgb input and returns a image object in the shape of the template
Recolor(hex): same but takes a hex value instead
}


Taking the same hypothetical as before. I can now do it with one mesh, and while I will need up to 4 images per mouth and per eye (A lighten map, a darken map, and a solid map and a imageTemplate), I can make the mouth and eyes in any color I want, so as long as I wanted more then 4 colors for the user to choose from I am still saving on images I have to upload to robloxes servers and the user has to download when playing my game.

Though allowing for the player to customize textures would not be the only applicable field for tech such as this. I can see this being useful for both GUI design and procedural generation. A library such as this could also be further expanded with support for say SVGs and custom fonts, allowing the user to rasterize a SVG at a desired resolution to turn it into a image.

3 Likes