Friday, 19 Feb 2016
A couple days ago, we did a bunch of editor improvements / fixes. Some things were getting really annoying, for instance opening the model viewer was taking minutes, even for a simple object. After investigation we discovered that it was caused by the wireframe material…
-
There isn’t just one, but actually two wireframe materials. They’re not compiled on-demand ( like when you press the wireframe button ), but the first time you open a model…
-
Those wireframe materials were compiled for all shader models ( SM3, 4, 4.1, 5 ) even though only one is in use at a time.
-
Those materials were compiled with max shader optimization level, when the user probably doesn’t care about performance in the first place.
I fixed the 2 last points, which reduced the initialization time from a few minutes down to around 10 seconds. That’s still a lot just to open a cube model, I think we’re definitely going to have to implement a caching or precompilation mechanism for some special materials.
In other news, I’ve started to investigate decal materials. Before I get into details, I must make it clear we’re not talking about decals as in “decal billboards” such as damage effects here. We’re talking about decal geometry, such as what Star Citizen uses to add all their details to their models. There is plenty of information on the technique on the net, so google for it if you’re interested in the topic.
This is a major art pipeline change that we’ve wanted to use for a while now. It does have a lot of benefits compared to the old “uv-map, skin and make unique textures for every single 3D model” pipeline:
-
Higher quality: decal geometry can re-use texture chunks, so all details are much higher quality than what you could do in a unique texture. Imagine a screw in a cockpit for instance. With a unique texture, there’s no way you’re gonna have any decent resolution for the screw details. With decal geometry, you simply add a quad which samples another texture with the details at a much higher resolution.
-
Lower VRAM: this is actually the #1 motivation for using this technique. The prototype currently uses close to 3.5 GB of VRAM, and it’s not like it features dozens of different ships. We really need to decrease our VRAM usage, and decals help a lot.
-
Faster work: a side effect is that you no longer need to model a high-poly model, uv map it and compute the difference to generate a normal map. That saves a lot of modelling time. You still need normal maps for the details though.
It also has some downsides:
-
Higher polycount: decal geometry is geometry, even if simplistic, it definitely increases the total model’s polycount.
-
How to do unique texture details, such as rust, scratches, etc… When those details are isolated, you can do them as decals, it’s easy. But when those details are shape / geometry dependant ( such as rust/weathering near plating edges ) it becomes problematic. We think that’s probably the reason with SC’s ships look all shiny & clean. Our artists are currently investigating what are the limits of this technique in this area.
-
Level-of-detail and Z-fighting. I don’t think Z-fighting will be too much of a problem ( SC seems to have lots of it when far away, but we do Z-buffer tricks due to the nature of our planetary engine, which makes those problems disappear ). LOD however, well, you can’t simplify the decal geometry since it’s already quite simplistic to start with ( if a screw is a quad, you can’t really simplify it… ). The other problem is that if an asset has a lower LOD level, if you use the decals from a higher LOD level, the two don’t match anymore. We planned to do automatic LOD, but I’m starting to think that won’t be an option due to this issue. Artists might have to manually create every single LOD and their matching decals.
On the engine side, I’ve started to implement the missing features to support these geometric decals & materials. Exposing things such as a ZOffset/Zscale to the user ( to avoid z-fighting ), a render order index ( to ensure that the material is rendered after its base material ), writing masks ( some decals might only want to write normals, others only diffuse, others both… ), alpha blending or masking etc…
Alpha blending ended up being a major issue with our deferred renderer, and incompatible with our current GBuffers setup. I’m going to have to change it so that we can do decals blending. I’ll probably work on that today the entire day.