Skip to content
This repository has been archived by the owner on May 22, 2020. It is now read-only.

Terrain clipping too close #8

Closed
faculezcano opened this issue Nov 3, 2017 · 21 comments
Closed

Terrain clipping too close #8

faculezcano opened this issue Nov 3, 2017 · 21 comments
Labels

Comments

@faculezcano
Copy link

I create a heightmap with a raw file, the terrain is clipping too close and it seams that has to do with the camera pitch, when i watch to the bottom it doesnt clip.

captura de pantalla_2017-11-03_15-46-46

Thanks!

@Zylann
Copy link
Owner

Zylann commented Nov 3, 2017

I know about this bug for a while, and there is no way to fix it... until the first feature of this list gets done in Godot Engine ^^" ==> godotengine/godot#9046

The cause is basically that the module renders terrain patches by using shader displacement, but it creates a difference between the AABB of the mesh used (a flat plane with optional seams) and the visual result. The Godot renderer then fails to cull patches properly...

Some advice:
I see your filesystem contains heightmaps under the *.tres format. I would not recommend it, because heightmaps are comparable to images in terms of file size, text format is really suboptimal for them (I don't even remember if I implemented support for .tres).
Prefer using the .heightmap format, which is smaller in size and faster to load ;)

@Zylann Zylann added the bug label Nov 3, 2017
@faculezcano
Copy link
Author

I figured that out after posting the issue! There is no other way to displace the plane? like accessing the mesh data?

@Zylann
Copy link
Owner

Zylann commented Nov 3, 2017

That's how the module worked before, every patch had its own mesh, but shader displacement ended up being faster, and costs less memory.

@faculezcano
Copy link
Author

Oh i see, do you even know where to start reading in the engine code, where the AABB is taking the original mesh data instead of the one displaced by the shader?

@Zylann
Copy link
Owner

Zylann commented Nov 3, 2017

Somewhere in VisualServer, I don't know much the renderer implementation in detail. There is a struct that represents an instance, and what I need is an optional AABB on it that could be used by the culling system instead of falling back on the mesh resource in use.
Particles have this feature already (for the same reasons). I think if that feature is extended to all visual instances, Particles wouldn't need this specially on them.

@faculezcano
Copy link
Author

I was looking in the visualserver code and realice that ArrayMesh have a set_custom_aabb, and looking in the mesher code, when you create flat chunks here, what if you set a custom aabb with a height of max height to the ArrayMesh? I know it's not the properly solution but if it works is close to a fix.

@Zylann
Copy link
Owner

Zylann commented Nov 4, 2017

It should not be here, make_flat_chunk() isn't actually called for each chunk update.
What it does is to generate a precalculated flat mesh (where all vertices have the same Y set to zero) for a given LOD, which will be re-used for many chunks, and will be displaced later in the shader per instance.
In other words, doing this on meshes is irrelevant, because the data source is a texture, not a mesh ;)

I am currently giving a try at adding per-instance custom AABBs to the Godot renderer. Once I have it, I will be able to set the AABB in here instead:

chunk.set_mesh(mesh);

@Zylann
Copy link
Owner

Zylann commented Nov 4, 2017

First tests look promising, no clipping anymore :)

@faculezcano
Copy link
Author

Nice! I'm glad to hear that, I'll wait for the commit

@Zylann
Copy link
Owner

Zylann commented Nov 5, 2017

Might take some time, waiting for this first: godotengine/godot#12645

@faculezcano
Copy link
Author

Hi @Zylann, is vertex painting working?

@Zylann
Copy link
Owner

Zylann commented Nov 7, 2017

@faculezcano map painting code is there (with chunked undo/redo etc), but not used yet for texturing nor exposed in the UI. That's something I should work on next. If you have a concern about it, please open another issue.

@Zylann
Copy link
Owner

Zylann commented Nov 14, 2017

I implemented AABB calculation here 968fee4, but it won't do anything because this line uses a feature Godot doesn't support yet: 968fee4#diff-6ecc4ee3460d2605411e9326fbfad3bdR91

All it needs is to have the PR I linked above to be merged, however that it is not scheduled to be in 3.0 :p

@faculezcano
Copy link
Author

Thank you so much @Zylann! Really is not being merged before nov 20? i am tracking this and the alpha close, if we push reduz to review your pr in the last issue of BETA APPROACHING? haha

@Zylann
Copy link
Owner

Zylann commented Nov 14, 2017

I talked to him on IRC, it's not going for that version, but maybe the next

@darrylryan
Copy link

I'm trying to get this working but got a bug:

image

@Zylann
Copy link
Owner

Zylann commented Nov 14, 2017

@darrylryan did you get this immediately or after moving around?
Also, what is the resolution of your heightmap?

@darrylryan
Copy link

@Zylann it did it as soon as i tried to create a new empty heightmap data

@Zylann
Copy link
Owner

Zylann commented Nov 14, 2017

@darrylryan it should be fixed now

@darrylryan
Copy link

@Zylann Its working! Thanks for the fix :) 👍

@Zylann
Copy link
Owner

Zylann commented Nov 20, 2017

Clipping issue fixed in ae96cf5

@Zylann Zylann closed this as completed Nov 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants