Post news Report RSS New technology: composite texture

Introduction of a new technology for detailed texturing of large models like terrains.

Posted by on

It has been some time since last blog activity, more than it should be. It has two main reasons. The one is that I've been distracted with unrelated matters more than usual. The second is that I'm working on a new technology for Resistance Force's engine: something I called the composite texture.


Image on the left shows low resolution preview texture in map editor
and image on the right high resolution in Composite Texture Editor

When I started working on extending the existing map and adding more details I've very soon ran across a big problem with detail texturing of large areas like terrains. You can either repeat some detail texture over and over (as done for regular "blocky" geometry, often called brushes), but you'll lose control about any details. Or have one big texture for the whole area. But due to memory/speed constraints you can't have really big textures.

Shows how are textures combined in texture splatting
Shows how are textures combined in
texture splatting (source)

In other engines there is usually special case for terrains using technique called texture splatting. Instead of one repeating detail texture there are 4 detail textures (like rocks, grass, dirt, ...) in addition to control texture with 4 color channels (red, green, blue and alpha channels), each controlling how much any given detail texture is visible. This works great, but it's often limited with maximum of 4 detail textures (the reason is that it can be easily done in single pass using one control texture) and it's available only for regular grid terrains.

Another interesting technique is MegaTexture developed by id Software. It allows you to have one really big texture for all geometry. The big texture is heavily compressed and stored on disk and dynamically streamed from it depending on what area player sees. The advantages are big: in engine it has practically constant performance characteristics so artists can go wild and touch any individual pixel they want to without worrying about anything. There are also disadvantages though: hugely increased amount of disk storage needed (even more for editing) and increased workload for artists, both not much indie friendly.

I've taken different approach for Resistance Force with composite texture: basically I took the idea of texture splatting and extended it by removing limit of number of detail textures (layers) and by ability to use it on any mesh, not just regular grid terrains. By having unlimited layers it also opens new possibilities such as placing any number of decals or even touching individual pixels by transforming some detailed area to decal and editing it in graphics editor. This way I have much more freedom when texturing while maintaining minimal disk storage and performance costs.

Post comment Comments
JustDaveIsFine
JustDaveIsFine - - 1,545 comments

I really like what you've guys made so far!

Reply Good karma Bad karma+1 vote
Bon.
Bon. - - 172 comments

Lovely technology, that road looks very pleasant.

Reply Good karma Bad karma+1 vote
Anddos
Anddos - - 390 comments

I just wish more people played the mp of the current build.

Reply Good karma Bad karma+1 vote
NullSoldier
NullSoldier - - 973 comments

Nice, I implemented texture "splatting" in my 2D engine recently and it works really well it's a great method for avoiding one repeating texture even in 2D games.

Reply Good karma Bad karma+1 vote
Dragonlord
Dragonlord - - 1,934 comments

So is this now a height terrain in the screenshot or a terrain? Since for a conventional Triangle Mesh terrain you have already the edges you need which texture splatting is trying to simulate so what does this actually gain you? In the screenshot it looks like there is a texture layered onto it. Triangle Meshes are though best known for having overlapping UV unwraps in contrary to height terrains which force this to never be the case. Just asking since from the description there I see right now a bunch of problems in the long run but no real benefit.

Reply Good karma Bad karma+1 vote
jezek2 Author
jezek2 - - 42 comments

By using edges directly you can only obtain hard transition between textures, both composite texture and texture splatting is working with soft transitions. Additionally in case of composite texture it can do (semi-)hard transitions on any place, not just on triangle edge. This is achieved by layer sharpness setting which allows to have sharper shapes using low resolution control texture (eg. the asphalt marks uses this). Comparing to texture splatting it also typically uses higher resolution of control texture so it has more control on details.

The terrain on the screenshot is normal mesh using subsurf modifier in Blender. It has single UV map and yeah it's texture layering. While I can do soft transitions manually with triangle meshes by either having multiple UV maps or by creating geometric decals, there are limits (eg. number of layers, uv mapping not compatible with other type of geometry like brushes) and issues with that (extra cumbersome workload, some things more complicated).

The beauty of the composite texture is that I don't need to touch the geometry by hand at all, it's done automatically for you. For an artist it works just like regular texture you can edit (just fancier). By having automatic tools it can exploit engine dependant optimizations the way that's hard to create manually in modellers. In future it will have ability to automatically split the geometry depending on decals used, minimizing rendering of more layers than needed.

Another nice thing is that the painting on texture is done using sphere and not just flat circle over UV map. Thanks to this (and the specific processing) it works quite well across UV seams as long as you use UV mapping not dependant on original UV map (like with axis mapping).

Reply Good karma+1 vote
Dragonlord
Dragonlord - - 1,934 comments

The problem with texture splatting actually is that it has soft transitions. In fact they are too soft. To compensate for this you need to increase the texture size. From what I read you do this. Problem there is that you get huge textures this way. On one side graphic cards can only handle certain texture sizes and on the other hand this explodes the GPU memory consumption. The texture size problem has to do with the fact that different GPUs handle different texture sizes differently ranging from fast to horribly slow. Of what kind of texture resolution are we speaking here now?

You mention that all is "done automatically for you". What exactly is manual? You say you use a control texture (aka a texture mask). Texture masks have to be painted by the artists unless you use a system similar to the Vegetation System I implemented. I don't see though in the description anything which indicates this process. Or do you simply blur the uv edges in the shader (you mentioned something about a "sharpness value")?

Reply Good karma Bad karma+1 vote
jezek2 Author
jezek2 - - 42 comments

The control texture size of all used layers is 1024x512 stretched over the whole model as seen on the screenshots. It can be even lower for most used layers without much quality degradation. However this texture as a whole is used only when editing, the processing creates internal engine specific and optimized textures quite different from it.

The soft transitions can be fluently tweaked by sharpness layer setting, from completely smooth (the default behaviour of texture splatting) to pixel sharp. It's a cheap operation on the sampled value. You can then create various shapes with various angles even with quite lowres texture using gradients (similar technique as alpha testing).

The authoring process is very simple: just create model with single UV map, there is only one requirement, no duplication/repeating of texture is allowed. It's then exported as simple .obj model. You then open the model in Composite Texture Editor and paint over the model with as many layers as you want. This process is manual, it's aimed for precise control of detailness and not only for terrains. Of course, for bigger terrains a generator can be easily created which would mix some layers according to terrain rules. I don't plan this extension any time soon as in Resistance Force there won't be really big terrains and manual approach is preferrable.

Engine integration is done also in a friendly way. While you have to "bake in" the actual model into custom map format, for reasons like precomputing static lights, radiosity, etc. The composite texture can be changed at any time without recompiling of the whole map. Just like normal texture can be changed at any time.

Reply Good karma+1 vote
Dragonlord
Dragonlord - - 1,934 comments

So you limit the terrain to very small then (2x pistol shot range)? Since if this very small map geometry requires already 1024 resolution texture you won't be doing small to medium size terrains. Or are the maps supposed to be only small urban maps where you can break up the terrain into very small lumps of geometry?

Reply Good karma Bad karma+1 vote
jezek2 Author
jezek2 - - 42 comments

Yes, there will be only small urban maps. The terrain will be used for smaller areas combined with standard brushes geometry for buildings, and areas outside playing area to make the player believe he's in a real world. It will be also used for some other static meshes than terrains.

While I'm using quite detailed textures, nothing prevents to use lowres ones for bigger terrain and by having unlimited number of layers you can place multiple highres control textures on places such as roads or whenever you need a more detailed control (similar to decals but for control texture).

For really big terrains some sort of swapping/streaming would be needed. This technique has quite potential for different usages and extensions beyond my primary usage.

Reply Good karma+1 vote
nolito
nolito - - 48 comments

Hello, I tell them my experience with your game, my PC is not very powerful, but could run HL2 without any problems (Seprom 1.9 mhz, 512 ram, WinXP Sp3 and Nvidia Gforce 6100 nForce 405 onboard 64MB) but could not play your game, try pulling down all the graphics and change the resolution to 800x600, but I had no success. The game run at 1 FPS.
Their idea is very good, so I download the demo. But you can`t enjoy it.
That's all, my idea is not disturbed. I just want to help.

Reply Good karma Bad karma+1 vote
jezek2 Author
jezek2 - - 42 comments

GF 6100 is very poor, but having just 1 FPS either means that the current usage of high resolution textures are simply too big for your card (there is currently missing option for setting lower quality), or even that some feature is done in software rendering as it's missing on this type of card, I know some features are missing in 6200 for example.

Also HL2 has three different renderers for DX7, DX8 and DX9, the lower performs better on lowend computers/videocards. Whereas Resistance Force uses DX9-type functionality + more advanced shader model.

The engine is still quite unoptimized and there needs to be more work on compatibility with eg. Intel video cards. So if it doesn't work now, you can try it with future updates (I've already done some optimizations for next version). However your card is very lowend and it will be probably unplayable even after optimizations and compatibility fixes.

Reply Good karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: