Open skalimoi opened 1 year ago
Hey there, I want to use this plugin to render procedural terrain that is created on runtime, so setting a heightmap on the editor isn't possible. I see the MTerrain class has a bunch of methods but there is no documentation so I was wondering how to do this.
My script right now looks as follows, based on what I guess the methods do (probably incorrect):
extends MTerrain func _ready(): self.dataDir = "res://data/terrain/" self.layersDataDir = "res://data/terrain_layer_data/" self.terrain_size = Vector2i(1024, 1024) var heightmap = Image.load_from_file("res://data/raw/eroded.png") self.material.set_shader_parameter("m_terrain_heightmap", heightmap) self.material.set_shader_parameter("region_size", 64) self.start() func _process(delta): self.update() self.update_physics()
However this error pops up on runtime:
0:00:03:0651 terrain_test.gd:12 @ _ready(): Can not find heightmap
Surely I must be doing something wrong, so i was wondering what is the correct way of setting up a terrain by code.
Thank you
Hello Dear There is no need to load the image manually the images are going to load into m terrain automatically
If you just set the data directory it will automatically grab the images from there and it will set inside terrain material automatically, This will happen after you call create_grid()
So this step is done automatically material.set_shader_parameter("m_terrain_heightmap", heightmap)
you don't need to specify that, Everything with m_terrain prefix is going to set automatically by plugin
I am currently working on documentation But for now there are some pages in wiki which I know they are not complete but if you read them they will give you an idea how the this terrain system works This is the wiki page link: https://github.com/mohsenph69/Godot-MTerrain-plugin/wiki
For now You can also use the videos on my youtube channel also
Thanks a lot for your response, I now have figured out the basic configurations.
Still I'm encountering some problems. The terrain only loads fully on the first region, and the rest are transparent - I imported the terrain using the importer tool.
Also the terrain straight up won't show up on the game, only in the editor. Why is that? First image is camera preview and second image is the actual game.
Thanks a lot for your time
Thanks a lot for your time
I wish you showed me the setting for your terrain in these photos
So my first question is how you created the height-map in the first place?
Heightmap should be imported or created by terrain as each region should be separated and there is a naming convention for each region
So make sure all data for heightmap for each region exist in the data folder Make sure you terrain setting match the heightmap data
And finally I made a simple demo example for terrain, Take a look at it, see the terrain setting and the data in the data directory
https://drive.google.com/file/d/1KMrD15Ct3RFIsx0PBSFnlBzOkv9OGyj8/view?usp=sharing
If that even not working send me your terrain setting image and a image of data directory
Hi,
Thanks a lot for the demo example. Unfortunately I don't have access to the files (check the sharing options for the link, it happens a lot): It's in Spanish - it basically says I have no access to it.
In the meantime I'll share the options and the data directory in case there's something wrong with any of it. Options of MTerrain node:
Data directory (there are many files so I'll share only a few):
The data was generated using the terrain importer tool provided by the plugin, with the following settings, from a 4096x4096 Luma16 heightmap in png format:
Which by the way prompts another question: is it possible to do the terrain importing via code and not using the GUI? Since the terrain will be procedural, I must prepare it for the plugin programatically also.
Thanks a lot again
Something is wrong with your regions
You do the math
Your original image is 4096x4096 and each region is 513
You should have a grid of 8x8 regions But in your data directory I see a lot of images for regions much bigger than 8, You can see that
if you import a 4096x4096 heightmap image and each regions is 513, Your heightmap region should start and end like this:
heightmap_x0_y0.res
.
.
.
heightmap_x7_y7.res
in another word they should be in a grid of 8 by 8 which each region is 513 pixel and 512 meter long, if you read the wiki you know what I mean
So there is something wrong with the heightmap which you importing, Check the size of each heightmap_.res they should be 513
Now the demo link working sorry about that: https://drive.google.com/file/d/1KMrD15Ct3RFIsx0PBSFnlBzOkv9OGyj8/view?usp=sharing
@skalimoi Have you tried adding create_grid = true
to the MTerrain _ready function? This actually creates the terrain using the data_dir.
Hey there, I want to use this plugin to render procedural terrain that is created on runtime, so setting a heightmap on the editor isn't possible. I see the MTerrain class has a bunch of methods but there is no documentation so I was wondering how to do this.
My script right now looks as follows, based on what I guess the methods do (probably incorrect):
However this error pops up on runtime:
Surely I must be doing something wrong, so i was wondering what is the correct way of setting up a terrain by code.
Thank you