Jump to content

Stiching 2 planes generated from heightmaps


Ron
 Share

Recommended Posts

Hi all, I am new here so excuse me if this is the wrong section of the forum to ask this question.

 

I have created 2 planes from 2 different heightmaps (which have almost similar edges)

when i place the 2 planes next to each other, there are some gaps in between them (some places are higher than the other on the line between the 2 planes)

 

is there any way to join those 2 heightmaps? i know it is possible by merging the 2 heightmap images and create one plane of that, but the reason i don't want to do it is that generation of each plane is dynamic (unlimited world)

 

see attached image as an example

 

Thanks in advance :D

post-8730-0-58080100-1400512590_thumb.pn

Link to comment
Share on other sites

Hello Ron,

 

Welcome!

 

First, since the planes have almost similar edges you get the expected result: gap between "planes" (they are not really planes since the normals can change from a point to another one).

 

Secondly, to stich them you can set the vertices positions along the edges but you need the same number of vertices along the two edges to stich and they must be "in front of" each other. To set the vertices positions you can use [setVerticesData](https://github.com/BabylonJS/Babylon.js/blob/master/Babylon/Mesh/babylon.mesh.ts)

Link to comment
Share on other sites

Thanks for the info gwenael

all "planes" or terrains are 100x100 and built from an 100x100 pixel heightmap image (with max of 25 "things" in the API - sorry i don't know the name, just know that the more this number the more details are built) so i think they have same number of vertices along the edges (am i right :s ?) .

 

how can i iterate through the vertices of the edges and give them the same height of the other edge (i will average them later on just need to know how to access them ...)

Link to comment
Share on other sites

Oh and the edges of the generated terrains are darker than expected (the texture have only one color, in PNG format, tried JPG with 0% compression, same dark edges :( ) how can this be fixed ? otherwise even after stitching the 2 planes/terrains there will be a visible border because of the darker borders ... that's weird. any solution? or this maybe a bug?

Link to comment
Share on other sites

Thanks for the info gwenael

all "planes" or terrains are 100x100 and built from an 100x100 pixel heightmap image (with max of 25 "things" in the API - sorry i don't know the name, just know that the more this number the more details are built) so i think they have same number of vertices along the edges (am i right :s ?) .

 

how can i iterate through the vertices of the edges and give them the same height of the other edge (i will average them later on just need to know how to access them ...)

 

Yes they must have the same number of vertices.

 

To get the vertices positions you must use getVerticesData from the Mesh class.

Link to comment
Share on other sites

Oh and the edges of the generated terrains are darker than expected (the texture have only one color, in PNG format, tried JPG with 0% compression, same dark edges :( ) how can this be fixed ? otherwise even after stitching the 2 planes/terrains there will be a visible border because of the darker borders ... that's weird. any solution? or this maybe a bug?

 

Asking the same question.

Link to comment
Share on other sites

  • 2 weeks later...

Hi gwenael , actually I written some code to make the edges of the terrain heightmap equal as there were some problems, but still some heightmaps doesn't appear, i am attaching some of the heightmaps ... , when i create simple planes it works great, but when I put the heightmaps, they don't show up.

terrains.zip

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...