how to use czm_inverseViewProjection matrix?

In my post precessing shader code,I want to get the screen point to world coordinates. I found "AutomaticUniforms.js" have a "czm_inverseViewProjection" variable,and document say:" It's An automatic GLSL uniform representing a 4x4 view-projection transformation matrix that transforms clip coordinates to world coordinates." So in the post pressing fragment Shader, I use code like this:

float depth = texture2D(depthTexture, v_textureCoordinates).r;
vec2 xy = vec2((depthTexture.x * 2.0 - 1.0), ((1.0 - depthTexture.y) * 2.0 - 1.0));
vec4 posInWorld = czm_inverseViewProjection * vec4(xy, depth, 1.0);
posInWorld = posInWorld / posInWorld.w;

But when I check the variable "posInWold", that seem not equal to the point world coordinates?
what's problem?

You can get the position in eye coordinates by applying czm_inverseProjection, then convert it to world coordinates with something like the following:

vec4 worldCoordinate4 = czm_inverseView * eyeCoordinate;

vec3 worldCoordinate = worldCoordinate4.xyz / worldCoordinate4.w;

``

Thanks!

Gabby

Thanks your help
But in "Apps/Sandcastle/index.html?src=3D%20Tiles%20Feature%20Picking.html" demo. I write post processing shader code like this:

void main(void)
{
    vec4 finalColor = texture2D(colorTexture, v_textureCoordinates);

    // get position clip coordinates
    vec2 uv = vec2(v_textureCoordinates);
    float depth = czm_readDepth(depthTexture, uv);
    vec2 xy = vec2((uv.x * 2.0 - 1.0), ((1.0 - uv.y) * 2.0 - 1.0));

    // get position in eye coordinates
    vec4 eyeCoordinate = czm_inverseProjection * vec4(xy, depth, 1.0);
    eyeCoordinate = eyeCoordinate / eyeCoordinate.w;

    // get position in world coordinates
    vec4 worldCoordinate4 = czm_inverseView * eyeCoordinate;
    vec3 worldCoordinate = worldCoordinate4.xyz / worldCoordinate4.w;
    
    // use ellipsoid equation to test the position is on ellipsoid surface?
    vec3 radii = vec3(6378137.0, 6378137.0, 6356752.314245);
    vec3 inverseRadii = vec3(1.0 / radii.x, 1.0 / radii.y, 1.0 / radii.z);
    vec3 scaled = inverseRadii * worldCoordinate;
    float one = dot(scaled, scaled);
    
    if (one >= 1.0)
    {// Isn't on ellipsoid surface, draw original color
        gl_FragColor = finalColor;
    }else
    {// On ellipsoid surface, draw red color
        gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n\
    }
}

I want just show 3D build model and draw red to earth surface,but the picture isn't right. Do your have any suggest?

Are you using terrain? Terrain won’t match the shape of the WSG84 ellipsoid exactly.