QuinnZhell / WebXR-Mars-Simulation

0 stars 0 forks source link

Dynamic Terrain Problem - Replacement system needed. #9

Open QuinnZhell opened 2 years ago

QuinnZhell commented 2 years ago

Up until now, the Dynamic Terrain extension for babylon js has provided a lot of help with building the terrain however I recently discovered a problem with using it for the final build. The way that Dynamic Terrain works is by creating a large datamap which a mesh is constructed on top of. However each dynamic terrain object contains only a single mesh. The mesh's position within the world is dependant on the active camera, however if there are multiple agents within the scene which agent has the active camera should Dynamic Terrain be using to create a mesh? Possible solutions I have identified:

Currently the height maps used are very large, there remains the option to use data sets instead however the height maps are a simple replacement for the time being. The problem with the height maps size is that the pixels which are used to determine height can change their values drastically resulting in a spiked texture. A proposal is a 'smoothing' function that will take a look at every individual pixel and construct a 9 point data structure for each. Then each pixel could have some interpolation between them. This would work as such: Take the middle of each grid to be the value of the original pixel in the height map. image In an original height map implementation, the points with value 3 and value 0 would be adjacent, resulting in a jarring slope downwards. The proposed change would be to interpolate between the two points to insert points around them which make transition between points smoother. Now consider the example expanded to four pixels with altitude values. image The green cells represent the new interpolation between the original points. The red cells represent that this is the boundary of our selection, without any further points to interpolate between these would be the edge of our terrain.

QuinnZhell commented 2 years ago

The interpolation solution given above has its own problems. With larger interpolation values, the more the height map is stretched the flatter terrain would appear to be.

Considering switching to raw data instead of height maps using the digital terrain models provided by The University of Arizona: https://www.uahirise.org/dtm/