melowntech / vts-browser-js

JavaScript WebGL 3D map rendering engine
BSD 2-Clause "Simplified" License
218 stars 42 forks source link

z-buffer styling of geodata removes culling #201

Closed jrjdavidson closed 3 years ago

jrjdavidson commented 3 years ago

Once z-buffer value is added, geodata become visible through objects - incuding through the globe ! I'm trying to figure out if this is an intended 'feature' or a bug?

I guess a workaround would be to add a fixed height when processing heights instead of using z-buffer, is it possible to do this in vts-browser or do i need to set a z height above ground in the original data?

Cheers

davidmtech commented 3 years ago

Setting z-buffer value is tricky. I do recommend to start with small values. i.e.

    depthOffset : [-0.01,0,0]

more details depthOffset paramater can be found in documentation.

But unfortunately there is no optimal setting which works in all cases (some setting works for small zooms, another setting works big zooms). Another downside of current solution is that it applies correction per object not per pixel. Per pixel solution will have some performance penalty and will need support of WebGL extension (EXT_frag_depth) or WebGL 2. Unfortunately at this moment I am not able to tell when we will have free resources for development of this feature.

Adding some extra height can help in some cases. There are two possible ways. In case you know height, you add some extra height and use 'fix' height mode. In case you do not know height, you use you extra height value as height (instead of zero) and use 'float' height mode. In 'float' height mode is height value interpreted as height above terrain.

jrjdavidson commented 3 years ago

Starting with small values solved it! thanks