kaktus40 / Cesium-GeoserverTerrainProvider

plug in to use geoserver as terrain provider
Other
356 stars 140 forks source link

Setting waterMask true gives error #13

Closed sushrut141 closed 8 years ago

sushrut141 commented 8 years ago

I'm using SRTM data to get the Height Map. Everything works fine when waterMask is set to false however when I set it to true I get a number of rendering errors. Also the globe is rendered awkwardly with tiles that keep flikering in and out. INVALID_OPERATION: texImage2D: ArrayBufferView not big enough for request with UNPACK_ALIGNMENT > 1

texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering. image

Parthesh commented 8 years ago

You can refer https://github.com/kaktus40/Cesium-GeoserverTerrainProvider/issues/11 I had the same problem; stepping down the geoserver to 2.7.5 version did the trick for me.

sushrut141 commented 8 years ago

I tried running it by hosting the layers on Geoserver 2.7.5 but the issue still persists. Setting waterMask true still causes the tiles to flicker and the terrain doesn't load.

Parthesh commented 8 years ago

I too am getting the same WebGL warning but am not getting the flickering though.. watermask_issue

sushrut141 commented 8 years ago

is the water surface being animated?.....I've loaded the SRTM data as an image mosaic wuth the data being published in .png format. Could the error be because of mismatch in dataType as in float32 vs int16?

sushrut141 commented 8 years ago

From what I understand the plugin requests a BIL image first and if a good size image is not available it then requests a styled or converted image. In the code I assumed that imageToHeightmapTerrainData() was called when data was being read from an image. In this function the waterMask is set as follows

for (var i = 0; i < heightBuffer.length; i++) { if (heightBuffer[i] <= 0) { waterMask[i] = 255; } }

However, the array "heightBuffer" is not defined in this function. It is defined in the function arrayToHeightmapTerrainData(), which is used when parsing data from a BIL I assume. The data in the imageToHeightMap function is being stored in the array "buffer". I changed the waterMask to reflect this as :

for (var i = 0; i < buffer.length; i++) { if (buffer[i] <= 0) { waterMask[i] = 255; } }

On running with the modified plugin and using png images as source(by providing the formatImage object to the plugin) the tiles weren't flickering. Using the debugger I saw that heightBuffer was "undefined" within the bounds of this function. Which may be why the waterMask had undefined values causing the voids.

The water still isn't animated. Could anyone suggest a method to fix this.

kaktus40 commented 8 years ago

I merged your pull. Is it Ok for you?

sushrut141 commented 8 years ago

Thanks. That fixes the flickering but the water still isn't animated. Can you share some details on how it is implemented? For example, the Cesium site says that for tiles having a mixture of land and water the waterMask is 256*256 bytes and elsewhere it is only one byte(pure land or water). I can't find a reference to this in the implementation.

Parthesh commented 8 years ago

Still getting the flickering with geoserver 2.8.0 with waterMask kept either true or false.

flickering_issue_geoserver_280

sushrut141 commented 8 years ago

Did you try setting getTileDataAvailable as true always? What about the format in which you are receiving images....the plugin expects little endian Int16 for bil images and 8 bit images otherwise.

sushrut141 commented 8 years ago

The sandcastle Materials examples uses a specular map of Earth to distinguish between land and water bodies. The water is enabled by creating a new material of type water.

primitive.appearance.material = new Cesium.Material({
    fabric : {
        type : 'Water',
        uniforms : {
            specularMap: '../images/earthspec1k.jpg',
            normalMap: require.toUrl('Assets/Textures/waterNormals.jpg'),
            frequency: 10000.0,
            animationSpeed: 0.01,
            amplitude: 1.0
        }
    }
});

Eath Specular map. earthspec1k Any ideas on how this could be used to enable water in a similar fashion.

Parthesh commented 8 years ago

Yes I tried all those settings. Its still same.

sushrut141 commented 8 years ago

Can you post the code where you are creating the GeoserverTerrainProvider instance? Check the network tab in Chrome debugger and see the image being returned by the wms request. If its a bil image it ought to look muddy brown with terrain features barely visible , otherwise it should be a translated(bluish) image with the blue highlighting terrain. Your issue might have something to do with your height data exceeding the bounds of the plugin. See the limitations value passed to the instance ie. limitions.offset, limitations.lowest..etc...Also the check how the image looks when the SLD provided is enabled in geoserver.

kaktus40 commented 8 years ago

There is no activity on this issue, so I close.