Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It is time for another stab at the terrain shader file. I gathered some new insights on what is important to produce the best results possible, partly from looking at BAR maps, partly from looking at maps from @sting-2 and these insights are the basis for the following changes.
The way to achieve the best quality seems have a huge (4-8k) map-wide albedo texture and to interpolate it with the other stratums that provide details. This way the map albedo texture can break up the texture repetition and provide much more color variation than you could by just tiling 8 regular textures.
The mapwide normal should ideally also be huge. To justify thse file sizes we need compression. Until now we stored the shadows, water depth and map normals all in one texture. Compressing these leads to severe artifacts and basically all our inputs are sensitive to artifacts. The dds compression was meant for colors, but if we store non-color data we notice this much more.
But we can utilize a trick. The alpha channel does not suffer from artifacts and the color channels also have basically no compression if we store the same value in all color channels. So we can store two channels per texture, with compression, and it still looks good. We put the normals in the texture like this:
R: normal y
G: normal y
B: normal y
A: normal X
A nice upside of this is that normal decals are compatible to this encoding. So if someone has made a normal decal for their map normals in the past, they can use this texture directly.
By separating the normals from the shadows and water, we can crank up the resolution on the normal texture and choose a lower resolution on our shadows and water, saving disk space.
In fact, we only need the water channel when we have a map with biplanar mapping (BPM), because then we need to sample one more texture and we are already at the limit of texture samplers. We store the channels like this:
R: AO or water depth
G: AO
B: AO
A: shadow
When we have a non-BPM map, then we can fill the water channel with AO and save the texture with compression without artifacts. On BPM maps we have to save uncompressed because we need the water channel.
The downside of all this is that we have one more texture now. I changed the slots of our map textures to accomodate this as well as possible.
The macro texture now does not have a dedicated slot anymore. Instead the lower albedo can get used as a macrotexture. Different shader variants allow control over how the lower albedo gets treated.
I changed the order of the height an roughness channels in the PBR atlas. This way you can omit the alpha channel with BC1 compression for shaders that don't need the height information. This helps saving a little bit of disk space.
Summary of the changes:
Previous layout:
upper albedo: map info texture: map normal + water depth + shadow
stratum7 albedo: macrotexture with alpha
stratum7 normal: heightroughness texture
New Layout:
upper albedo: RoughnessAndHeight texture
stratum7 albedo: terrain info texture: water depth + ambient occlusion + shadow
stratum7 normal: terrain normal: normal y + normal x