"U_scaleAndBias" meaning

There is a scaleAndBias matrix variable in the uniformMap variable in the ceisum GlobeSurfaceTileProvider.js file, and the change amount is used in GlobeVS.glsl. But I found that the tiles only use the change value when they are scaled to level 13. What is the purpose of the scaleAndBias variable, can anyone answer my question?

@mylove10086

It looks like this.properties.scaleAndBias is a four by four matrix that is used to update the clipping planes in GlobeSurfaceTileProvider.js. Unfortunately, not much more information is provided in our documentation or in the codebase. Can you please provide me with some more information about your use case and application? This would help me give you a more tailored response.

-Sam

I found the “U_scaleAndBias” variable in the GlobeVS.glsl vertex shader. It is assigned in the ‘addDrawCommandsForTile()’ function of GlobeSurfaceTileProvider.js, and the explanation in TerrainEncoding.js is ‘The matrix used to decompress the terrain vertices in the shader for RTE rendering’. To transform the vertex coordinates in GlobeVS.glsl, the code is like this:
void main(){
#ifdef QUANTIZATION_BITS12
vec2 xy = czm_decompressTextureCoordinates(compressed0.x);
vec2 zh = czm_decompressTextureCoordinates(compressed0.y);
vec3 position = vec3(xy, zh.x);
float height = zh.y;
vec2 textureCoordinates = czm_decompressTextureCoordinates(compressed0.z);
height = height * (u_minMaxHeight.y-u_minMaxHeight.x) + u_minMaxHeight.x;
position = (u_scaleAndBias * vec4(position, 1.0)).xyz;

I still don’t understand why the terrain code changes after cesium is zoomed to level 13 tiles?

@mylove10086

Thank you for the additional information.

I will check in with a few other Cesium developers about this question and get back to you ASAP.

-Sam