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

Protruding geometry when using flat shading #714

Open
NecroDes opened this issue Nov 22, 2024 · 3 comments
Open

Protruding geometry when using flat shading #714

NecroDes opened this issue Nov 22, 2024 · 3 comments

Comments

@NecroDes
Copy link

NecroDes commented Nov 22, 2024

Hello. I'm just starting to use this plugin. The documentation shows an example of how to make flat shading.
I inserted NORMAL = normalize(cross(dFdy(VERTEX), dFdx (VERTEX))); at the end of fragment shader in transvoxel_terrain_material.
Is there a way to get rid of this?

image
P.s. I am using the latest release version

@Zylann
Copy link
Owner

Zylann commented Nov 22, 2024

This is an artifact present due to a workaround to a caveat of marching cubes (which Transvoxel is based on): they can generate slivers, extremely thin or small triangles which are known to make the Jolt Physics addon unhappy, amongst other things.
So the way the implementation works around this is by clamping interpolation factors, which prevents triangles from becoming too thin, but a downside is in your case where shading is based on triangles and not on normals computed by the mesher, which makes them stand out.
Before this approach, the mesher was instead eliminating those triangles, which led microscopic holes to appear instead (and had a slightly higher performance cost). Which also caused various edge case issues.

If you don't want the current workaround to be active at all (and therefore you will get slivers), you can set the edge_clamp_margin property to 0 in the transvoxel mesher.

@NecroDes
Copy link
Author

Thanks for the advice. Is there a list of games that use your plugin? It would be interesting to see a similar list as in the documentation of the Terrain3D plugin.

@Zylann
Copy link
Owner

Zylann commented Nov 23, 2024

I haven't considered adding a list of games because I don't know many projects using it. There are a few that used it at some point, others that might still be using it but haven't heard of in a while.

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

2 participants