-
-
Notifications
You must be signed in to change notification settings - Fork 160
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
A more efficient way of terrain details processing #296
base: master
Are you sure you want to change the base?
Conversation
Nice work @painfulexistence . I did some testing on it.
Results w/ 3 Detail LayersFPS
Script TimeFull Scenew/ day/night cycle, water, trees, animals, houses, etc.
8 detail layersHere I added more 2D textures and 3D meshes for flowers, pinecones and branches. Overall, it seems the FPS performance of the old classes is slightly more consistent. I can't tell if the FPS is any faster. We must be bound by the performance of the renderer and MMI. However there is a definite improvement to script time. I think for our game, we're just going to have to limit the use of grass with sparse ground vegetation so as to not overwhelm the renderer. |
9d20b5a
to
324ca4f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like some things can still be optimized by applying coordinate conversions differently.
Also, I think you are still missing the case where the terrain is sculpted.
@@ -81,6 +80,8 @@ var _debug_wirecube_mesh: Mesh = null | |||
var _debug_cubes := [] | |||
var _logger := Logger.get_for(self) | |||
|
|||
var _chunk_size: int = load("res://addons/zylann.hterrain/hterrain_detailer.gd").CHUNK_SIZE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the constant could actually be in that script instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean define CHUNK_SIZE in both script, or define it in the detail_layer.gd and then reference it from other scripts if needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Zylann I updated it as putting CHUNK_SIZE in both script. Is this okay with you?
If so, then this PR is ready to be merged🙏
Hi @Zylann, |
There is the following signal in
However it is emitted for other channels than just the heightmap. I still have a feeling that extra cache is really just complexity inflicted by GDScript alone, because bounds precomputed inside HTerrainData should have been fast enough to use... |
- Update detail chunk AABBs only when necessary - Maintain a list of calculated AABBs for subsequent frames
324ca4f
to
cc861a5
Compare
@Zylann Yes, I understand the extra cache of AABBs is somewhat redundant, but I could't come up with other ways to make detail chunk AABBs update faster😭 |
Yeah sliding box could be done later |
Maintain a dict of AABBs for all detail chunks
Update all chunk AABBs only when necessary: