一、内置函数(v1.112)
-
czm_viewport
-
czm_viewportOrthographic
-
czm_viewportTransformation
-
czm_globeDepthTexture
-
czm_model
-
czm_inverseModel
-
czm_view
-
czm_view3D
-
czm_viewRotation
-
czm_viewRotation3D
-
czm_inverseView
-
czm_inverseView3D
-
czm_inverseViewRotation
-
czm_inverseViewRotation3D
-
czm_projection
-
czm_inverseProjection
-
czm_infiniteProjection
-
czm_modelView
-
czm_modelView3D
-
czm_modelViewRelativeToEye
-
czm_inverseModelView
-
czm_inverseModelView3D
-
czm_viewProjection
-
czm_inverseViewProjection
-
czm_modelViewProjection
-
czm_inverseModelViewProjection
-
czm_modelViewProjectionRelativeToEye
-
czm_modelViewInfiniteProjection
-
czm_orthographicIn3D
-
czm_normal
-
czm_normal3D
-
czm_inverseNormal
-
czm_inverseNormal3D
-
czm_eyeHeight
-
czm_eyeHeight2D
-
czm_entireFrustum
-
czm_currentFrustum
-
czm_frustumPlanes
-
czm_farDepthFromNearPlusOne
-
czm_log2FarDepthFromNearPlusOne
-
czm_sunPositionWC
-
czm_sunPositionColumbusView
-
czm_sunDirectionEC
-
czm_sunDirectionWC
-
czm_moonDirectionEC
-
czm_lightDirectionEC
-
czm_lightDirectionWC
-
czm_lightColor
-
czm_lightColorHdr
-
czm_encodedCameraPositionMCHigh
-
czm_viewerPositionWC
-
czm_frameNumber
-
czm_morphTime
-
czm_sceneMode
-
czm_pass
-
czm_backgroundColor
-
czm_brdfLut
-
czm_environmentMap
-
czm_specularEnvironmentMaps
-
czm_specularEnvironmentMapSize
-
czm_specularEnvironmentMapsMaximumLOD
-
czm_sphericalHarmonicCoefficients
-
czm_temeToPseudoFixed
-
czm_pixelRatio
-
czm_fogDensity
-
czm_splitPosition
-
czm_geometricToleranceOverMeter
-
czm_minimumDisableDepthTestDistance
-
czm_invertClassificationColor
-
czm_gamma
-
czm_ellipsoidRadii
-
czm_ellipsoidInverseRadii
二、MaterialAppearance
(1)BasicMaterialAppearanceVS_default
# BasicMaterialAppearanceVS_default
in vec3 position3DHigh;
in vec3 position3DLow;
in vec3 normal;
in float batchId;
out vec3 v_positionEC;
out vec3 v_normalEC;
void main(){
vec4 p = czm_computePosition();
v_positionEC = (czm_modelViewRelativeToEye * p).xyz;
// position in eye coordinates
v_normalEC = czm_normal * normal;
// normal in eye coordinates
gl_Position = czm_modelViewProjectionRelativeToEye * p;
}
(2)BasicMaterialAppearanceFS_default
# BasicMaterialAppearanceFS_default
in vec3 v_positionEC;
in vec3 v_normalEC;
void main(){
vec3 positionToEyeEC = -v_positionEC;
vec3 normalEC = normalize(v_normalEC);
#ifdef FACE_FORWARD
normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
#endif
czm_materialInput materialInput;
materialInput.normalEC = normalEC;
materialInput.positionToEyeEC = positionToEyeEC;
czm_material material = czm_getMaterial(materialInput);
#ifdef FLAT
out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
else
out_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
endif
}
(3)AllMaterialAppearanceVS_default
# AllMaterialAppearanceVS_default
in vec3 position3DHigh;
in vec3 position3DLow;
in vec3 normal;
in vec3 tangent;
in vec3 bitangent;
in vec2 st;
in float batchId;
out vec3 v_positionEC;
out vec3 v_normalEC;
out vec3 v_tangentEC;
out vec3 v_bitangentEC;
out vec2 v_st;
void main()
{
vec4 p = czm_computePosition();
v_positionEC = (czm_modelViewRelativeToEye * p).xyz;
// position in eye coordinates
v_normalEC = czm_normal * normal;
// normal in eye coordinates
v_tangentEC = czm_normal * tangent;
// tangent in eye coordinates
v_bitangentEC = czm_normal * bitangent;
// bitangent in eye coordinates
v_st = st;
gl_Position = czm_modelViewProjectionRelativeToEye * p;
}
(4)AllMaterialAppearanceFS_default
# AllMaterialAppearanceFS_default
in vec3 v_positionEC;
in vec3 v_normalEC;
in vec3 v_tangentEC;
in vec3 v_bitangentEC;
in vec2 v_st;
void main()
{
vec3 positionToEyeEC = -v_positionEC;
mat3 tangentToEyeMatrix = czm_tangentToEyeSpaceMatrix(v_normalEC, v_tangentEC, v_bitangentEC);
vec3 normalEC = normalize(v_normalEC);
#ifdef FACE_FORWARD
normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
#endif
czm_materialInput materialInput;
materialInput.normalEC = normalEC;
materialInput.tangentToEyeMatrix = tangentToEyeMatrix;
materialInput.positionToEyeEC = positionToEyeEC;
materialInput.st = v_st;
czm_material material = czm_getMaterial(materialInput);
#ifdef FLAT
out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
#else
out_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
#endif
}
三、EllipsoidSurfaceAppearance
(1)EllipsoidSurfaceAppearanceVS_default
# EllipsoidSurfaceAppearanceVS_default
in vec3 position3DHigh;
in vec3 position3DLow;
in vec2 st;
in float batchId;
out vec3 v_positionMC;
out vec3 v_positionEC;
out vec2 v_st;
void main(){
vec4 p = czm_computePosition();
v_positionMC = position3DHigh + position3DLow;
// position in model coordinates
v_positionEC = (czm_modelViewRelativeToEye * p).xyz;
// position in eye coordinates
v_st = st;
gl_Position = czm_modelViewProjectionRelativeToEye * p;\n
}
(2)EllipsoidSurfaceAppearanceFS_default
# EllipsoidSurfaceAppearanceFS_default
in vec3 v_positionMC;
in vec3 v_positionEC;
in vec2 v_st;
void main(){
czm_materialInput materialInput;
vec3 normalEC = normalize(czm_normal3D * czm_geodeticSurfaceNormal(v_positionMC, vec3(0.0), vec3(1.0)));
#ifdef FACE_FORWARD
normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
#endif
materialInput.s = v_st.s;
materialInput.st = v_st;
materialInput.str = vec3(v_st, 0.0);
// Convert tangent space material normal to eye space
materialInput.normalEC = normalEC;
materialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(v_positionMC, materialInput.normalEC);
// Convert view vector to world space
vec3 positionToEyeEC = -v_positionEC;
materialInput.positionToEyeEC = positionToEyeEC;
czm_material material = czm_getMaterial(materialInput);
#ifdef FLAT
out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
#else
out_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
#endif
}
四、PerInstanceColorAppearance
(2)PerInstanceColorAppearanceVS_default
# PerInstanceColorAppearanceVS_default
in vec3 position3DHigh;
in vec3 position3DLow;
in vec3 normal;
in vec4 color;
in float batchId;
out vec3 v_positionEC;
out vec3 v_normalEC;
out vec4 v_color;
void main(){
vec4 p = czm_computePosition();
v_positionEC = (czm_modelViewRelativeToEye * p).xyz;
// position in eye coordinates
v_normalEC = czm_normal * normal;
// normal in eye coordinates
v_color = color;
gl_Position = czm_modelViewProjectionRelativeToEye * p;
}
(2)PerInstanceColorAppearanceFS_default
# PerInstanceColorAppearanceFS_default
in vec3 v_positionEC;
in vec3 v_normalEC;
in vec4 v_color;
void main(){
vec3 positionToEyeEC = -v_positionEC;
vec3 normalEC = normalize(v_normalEC);
#ifdef FACE_FORWARD
normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
#endif
vec4 color = czm_gammaCorrect(v_color);
czm_materialInput materialInput;
materialInput.normalEC = normalEC;
materialInput.positionToEyeEC = positionToEyeEC;
czm_material material = czm_getDefaultMaterial(materialInput);
material.diffuse = color.rgb;
material.alpha = color.a;
out_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
}
(3)PerInstanceFlatColorAppearanceVS_default
# PerInstanceFlatColorAppearanceVS_default
in vec3 position3DHigh;
in vec3 position3DLow;
in vec4 color;
in float batchId;
out vec4 v_color;
void main(){
vec4 p = czm_computePosition();
v_color = color;
gl_Position = czm_modelViewProjectionRelativeToEye * p;
}
(4)PerInstanceFlatColorAppearanceFS_default
# PerInstanceFlatColorAppearanceFS_default
in vec4 v_color;
void main(){
out_FragColor = czm_gammaCorrect(v_color);
}