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

Terrain uv mapping performs correct? #839

Open
Wc4ever opened this issue May 5, 2024 · 8 comments
Open

Terrain uv mapping performs correct? #839

Wc4ever opened this issue May 5, 2024 · 8 comments

Comments

@Wc4ever
Copy link
Contributor

Wc4ever commented May 5, 2024

Have been running some test with terrain, there is a thing I can't understand. Whats the point of mapping like that?
debug
I did read the code and it dosent seem like a bug, seems like it's done on purpose. But I can't see how it could be used in real game. Also I never saw behaviour like that in other engines. When I trying to use texture with obvious details like rocks they look messy, they appear huge on near distance and they fade away obviously.
rocks
I assume resolution supposed to go lower but uv mapping have to stay consistent.

@turanszkij
Copy link
Owner

turanszkij commented May 6, 2024

If I don't do this, then texture tiling in the distance will look extremely bad. I'm curious, do you have a better alternative? This effect is computed in this shader, where the virtual texture tiles are rendered into the atlas: https://github.com/turanszkij/WickedEngine/blob/master/WickedEngine/shaders/terrainVirtualTextureUpdateCS.hlsl#L84
The overscale value will scale the texture tiling based on LOD to increase texture detail close to the camera and reduce tiling in the distance. Let me know if you can improve this.

@Nickykun
Copy link

Nickykun commented May 7, 2024

If I don't do this, then texture tiling in the distance will look extremely bad
The overscale value will scale the texture tiling based on LOD to increase texture detail close to the camera and reduce tiling in the distance. Let me know if you can improve this.

The huge rocks and grass blades on a mountain looks equally "extremely bad". And the use of patterned is impossible.
Is it possible to use a different material on the next LOD iterations? Or generate a texture from a 4x4 texture of a past iteration.
This will increase VRAM, however it could be used in real game.

@turanszkij
Copy link
Owner

This is how it looks like without uv scaling based on LOD, always tiling for max detail:
sc_09-05-2024 08-04-38

This is how it looks like constant uv scaling for min detail (1:1 factor texture to chunk):
sc_09-05-2024 08-09-02

The current solution is to increase tiling close to camera to max out virtual texture capabilities, but reduce tiling in the distance, which is intentional. Note that the base terrain textures in the Editor are 1024*1024 resolution. If you use higher resolution base textures, tiling will be different, as the it is always computed to map a whole base texture across a whole chunk completely in the distance.

Maybe we should introduce a second "detail" texture map close to the camera, and only blend it in close by, while keeping the base texture tiling constant?

On the other hand, I fixed the flipped texture that is visible on @Wc4ever 's first screenshot.

@Wc4ever
Copy link
Contributor Author

Wc4ever commented May 9, 2024

@turanszkij how you did it, can I recompile shaders on fly some how?)

@turanszkij
Copy link
Owner

In my first comment I wrote where to modify this effect:

This effect is computed in this shader, where the virtual texture tiles are rendered into the atlas: https://github.com/turanszkij/WickedEngine/blob/master/WickedEngine/shaders/terrainVirtualTextureUpdateCS.hlsl#L84 The overscale value will scale the texture tiling based on LOD to increase texture detail close to the camera and reduce tiling in the distance. Let me know if you can improve this.

@Wc4ever
Copy link
Contributor Author

Wc4ever commented May 9, 2024

@turanszkij No I got it, I mean you got exactly the same screens which leads me you changed the shader without engine reload, or you just serialized the camera position?)

@turanszkij
Copy link
Owner

Oh I see, when you make changes to the shader source, the Editor will automatically recompile and reload it when the window gets back in focus. You can verify this happening when you open the backlog (Home button), there will be a message posted about shader recompilation. This doesn't work with release builds, for example Steam, you have to do it from a development build.

@Wc4ever
Copy link
Contributor Author

Wc4ever commented May 12, 2024

Just did some research, I think the main problem now there is to much cascades and all of them switching in near distance. Also last lod is to close to mid distance that produce blurry mid distance texture with huge details.
tiling_with_distance
Actually cascades on near distance not needed here is example of texture scaled x8 it looks fine on near no pronounced tiling. Just use big enough texture, almost every stock let you download 2k textures for surface I think it is good baseline.
Снимок1
Also I tested how it works in Space Engineers looks like they use similar approach. They have something like 3-4 cascades in total and first one starts in mid distance also blending is way smoother. Take a look test1 test2 Also scale difference not as huge as we have now(seems like diffrenece x2 or x4 between near and mid distance).

So I think as first steps to tune current approach would be good to reduce number of cascades, rearrange them and may be allow to adjust some setting for example first cascade prescale. Detail material for closeups it is also good idea but seems like more advanced feature to implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants