Skip to content

Instantly share code, notes, and snippets.

@addam
Created September 8, 2020 13:25
Show Gist options
  • Save addam/2deef12fcf5a529fb7de8980d449649d to your computer and use it in GitHub Desktop.
Save addam/2deef12fcf5a529fb7de8980d449649d to your computer and use it in GitHub Desktop.
get world coordinates in Cesium
vec4 world() {
vec4 ndc = vec4(
2.0 * (gl_FragCoord.xy - czm_viewport.xy) / czm_viewport.zw - 1.0,
(czm_readDepth(depthTexture, v_textureCoordinates) - czm_viewportTransformation[3][2]) / czm_viewportTransformation[2][2],
1.0);
vec4 eye = czm_inverseProjection * ndc;
return czm_inverseView * eye;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment