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:
// 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?