Search code examples
c#xnatexturestexture2d

XNA Procedural Textures


I'm trying to make procedural textures in my XNA 4.0 game, mainly for buttons but for other textures as well. Here's an image describing what I want:

enter image description here

Hope you understand what I want to do, if you don't, heres some words: I want to make objects in my game. These objects will all use the same texture, but can be resized, and their texture will not be resized so the pixels are "stretched", but procedurally placed.


Solution

  • The general way to do this is to have one texture for the middle, 4 for each corners and 4 for each edges. The vertical edges and middle would be stretched vertically, and the horizontal edges and middle would be stretched horizontally.

    You could pack it into 1 texture for easy editing. You'd define the corners and edges implicitly with a border distance, which would define the parts of the texture that should not scale.