How to - Multiple texture in GeoMipTerrain from heightmap

Hello everyone,
I just met Panda3D and saw its potential. Now im learning Panda and making my dream-game in C++.
I just wanna ask something to you guys, im learning about terrains in panda and i can load GeoMipTerrain from a heightmap file. Also i can apply texture to it. Here is some code and screenshots;

void Background::LoadTerrain(string _mapname) {
	GeoMipTerrain terrain("terrain");
	const string _heightmap_file = "bin/neuera/maps/" + _mapname + "/height.png";
	terrain.set_heightfield(Filename(_heightmap_file));
	terrain.set_bruteforce(true);
	terrain.generate();
	terrain.get_root().set_sz(150);
	terrain.set_auto_flatten(GeoMipTerrain::AFM_strong);

	NodePath terrainNP = terrain.get_root();

	PT(Texture) sandTexture = TexturePool::load_texture("bin/neuera/tex/dirt.png");
	sandTexture->set_minfilter(SamplerState::FT_nearest_mipmap_linear);
	sandTexture->set_magfilter(SamplerState::FT_linear);

	PT(TextureStage) sandStage = new TextureStage("sandStage");
	sandStage->set_sort(1);
	sandStage->set_texcoord_name("terrain");
	terrainNP.set_texture(sandStage->get_default(), sandTexture);
	terrainNP.set_tex_scale(sandStage->get_default(), LVector2(5, 5));

	terrain.get_root().reparent_to(window->get_render());
}

But its applying one texture to entire terrain. I found @wezu 's level editor and its amazing!
Im just wondering is it possible to apply multiple texture to GeoMipTerrain like this? ;

IMAGE

Im searching but could not found too much information about this (especially in C++)
Thanks for your time and im sorry about my english…

First of all, greetings, and welcome to the forum! I hope that you find your time here to be positive! :slight_smile:

I think that these days that sort of thing is done in a shader.

In short, the shader would take in whatever data is provided–for example, the normal-vector of a given vertex in the terrain, or its height, or a sample from a particular texture–and use that to blend between various textures.

You might be able to do something similar with Texture Combine Modes–although I suspect that it would be less flexible.

1 Like

Thank you, yes i heard about shaders and im searcing about it. Also looking to wezu’s editor and trying to understand it to implement C++. But im new at all of this but i really want to learn sort of things. So, do you have any suggestion or maybe some github-source to practice? And thank you for the answer i really appreciate it.

For these subjects specifically? Nothing much offhand, I’m afraid.

The manual has some basic shader-examples, I think. Otherwise, I’d suggest searching the forums for examples.

(And if you don’t find examples here, then searching the internet at large.)

And the answer is my pleasure. :slight_smile: