Creature Texture Generation

Since macroscopic stage development is set to start in less than half a year, I feel that it’s time to start this discussion. Thrive’s repository already contains code for both creature model generation and UV unwrapping of these models (aka calculating texture coordinates for the models); so the foundation is already there.

Texturing

Unless we want to display other features on the texture, there will be three main layers:

  • Pigmentation patterns
  • Skin texture
  • Dirt/imperfections (can be skipped depending on our graphics style)

Skin Texture

This is the hard part. A texture has to be projected onto an uneven model with minimum distortion and no visible seams. The simplest method is to use 3-planar projection, which projects three textures from three orthogonal directions and blends them inbetween.

This works fine with something like skin or fur, the details of which aren’t very clear or visible. Seams on scale and feather textures, however, stand out a lot more.

The feathers here have a pretty obvious discontinuity:

The simplest and most flexible solution that I see is to project a bunch of textures on top of that like decals, covering up the seams, but still relying on the 3-planar projected texture as a fallback.

Here’s what a scaly creature looks like with 500 projected textures. I will discuss the methods of applying these textures closer to the end, but needless to say, projecting this many textures is not viable real-time.

Pigmentation Patterns

Applying pigmentation patterns will be simpler. My idea is to give the player controls over what “layers” of pigmentation are applied, how, and with what colors. I will now outline some of these.

Noise application is probably one of the most powerful tools at our disposal. The pattern it generates can be controlled by scaling the noise and coloring it with a few curves. These two screenshots use a mixed 3-planar-projected noise, but using 3D noise is also an option.

Projected textures can also be used here; spots are the simplest application, but obviously any texture can be projected.

Coloring can also be applied based on the part of the creature (normals and custom vertex weights can be used). I don’t have a screenshot to demonstate that though.

A lot of this depends on the artistic application, so if anyone knows examples of animal patterns that can be used as an inspiration or, in general, has any ideas regarding this, feel free to share.

Dirt/imperfections

This is the simplest step. It can be done using simple 3-planar projection. Because of this, it can be made dynamic even if the rest of the texture is baked. The same technique can also be used for dynamic blood. If we want to go the extra mile with dynamicity, these effects can be applied based on custom vertex weights, i.e. only to a part of the creature.

The technical aspect

I’ve already shared this on the developer discord, but I see two viable approaches to generating these textures. They can either be baked or generated in real-time using a fragment shader. Here’s what to consider:

  • Baked textures require UV generation, which is very expensive in terms of performance; 5-10s based on the tests that I can remember. I have a github branch with some changes to xAtlas’ parameters that reduces this time x5 though, and I remember there being an alternative to xAtlas that may or may not be more performant.
  • Baked textures can theoretically be used for things like texture painting. But both methods can support vertex-based painting.
  • A real-time shader doesn’t have a limited resolution. Though if it projects a pre-made texture, it’s of course going to be kind of pixelated. This is not a big advantage; a baked 2048x2048 texture is barely distinguishable from a real-time generated one.
  • A real-time shader requires real-time calculations. The performance problem arises if we need to project hundreds of textures like in the examples above.

Both solutions are a trade-off of some sort. The expensive UV generation is the biggest point in favor of using a real-time shader in my opinion, but the power and versatility of using a big number of projected textures is too much to ignore. Luckily, if UV generation times prove to be too much, converting the baking system into a real-time shader would be extremely easy. After all, it still uses a shader at its core.


So, my plan for now will probably be to implement texture baking into the actual game. For now, I will only implement skin textures. I don’t have many ideas for the pigmentation pattern part, so any ideas regarding that would be great.

1 Like