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

Fix terrain vertex normals #3327

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

amelentev
Copy link
Contributor

@amelentev amelentev commented Jul 31, 2023

It seems there is some bug in the vertex normal calculation, getGridNormal. The normal vector for the center of a tile does not correspond to near normals. You can see it if you draw only light in terrain_combined_medium.frag:
image

I'm looking into the issue.
For now, I have one workaround - to average tile normals for the center point. Since the center point is the average of tile points. Looks better:
image

@MaNGusT-
Copy link
Contributor

MaNGusT- commented Jul 31, 2023

As I thought, for some situations average normals work better. With such smooth normals ssao will look super good and natural.

Average vertex normals is classic method to smooth surface BUT they work really bad when angle between face normals is greater than 60* and completely wrong when greater than 90*. In these situations weightened vertex normals are strongly recommended. Probably it's also mesh-dependent.

@MaNGusT-
Copy link
Contributor

MaNGusT- commented Aug 1, 2023

We also have "color binding" effect since sRGB convertion (from/to) is a bit broken. So you probably can't get perfect results.
It's visible on your screenshots but clearly visible if move the camera under water to look at bottom texture.
image

@amelentev amelentev marked this pull request as ready for review March 8, 2024 16:47
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

Successfully merging this pull request may close these issues.

None yet

2 participants