Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yet another shader rework #6683

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft

Yet another shader rework #6683

wants to merge 6 commits into from

Conversation

BlackYps
Copy link
Contributor

@BlackYps BlackYps commented Mar 1, 2025

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 normals in one texture and our shadows and water depth in another.
An example:
R: normal z
G: normal z
B: normal z
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 even more disk space.

The downside is that we have one more texture now. I changed the slots of our map textures to accomodate this as well as possible.

Previous layout:
upper albedo: map info texture: map normal + water depth + shadow
layer8 albedo: macrotexture with alpha
layer8 normal: heightroughness texture

Now:
upper albedo: heightroughness texture
layer8 albedo: map info texture: ambient occlusion + shadow + water depth
layer8 normal: map normal

I added ambient occlusion because it might be a nice addition and you can sometimes squeeze in three channels into a compressed dds texture without too many artifacts. Alternatively we could maybe store this texture uncompressed because it is not so big. AO is not implemented yet. I need to test it some more. To future-proof the map info texture a pure white should be used in the AO channel.

The macro texture now does not have a dedicated slot anymore. Instead the lower albedo can get used as a macrotexture. Different shader variants will allow control over how the lower albedo gets treated.

Checklist

  • Changes are annotated, including comments where useful
  • Changes are documented in the changelog for the next game version

@BlackYps BlackYps added the area: graphics Anything Related to the Game Graphics label Mar 1, 2025
@github-actions github-actions bot marked this pull request as draft March 1, 2025 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Anything Related to the Game Graphics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant