cesium的默认自定义shader总结

一、内置函数(v1.112)

  1.  czm_viewport

  2.  czm_viewportOrthographic

  3.  czm_viewportTransformation

  4.  czm_globeDepthTexture

  5.  czm_model

  6.  czm_inverseModel

  7.  czm_view

  8.  czm_view3D

  9.  czm_viewRotation

  10.  czm_viewRotation3D

  11.  czm_inverseView

  12.  czm_inverseView3D

  13.  czm_inverseViewRotation

  14.  czm_inverseViewRotation3D

  15.  czm_projection

  16.  czm_inverseProjection

  17.  czm_infiniteProjection

  18.  czm_modelView

  19.  czm_modelView3D

  20.  czm_modelViewRelativeToEye

  21.  czm_inverseModelView

  22.  czm_inverseModelView3D

  23.  czm_viewProjection

  24.  czm_inverseViewProjection

  25.  czm_modelViewProjection

  26.  czm_inverseModelViewProjection

  27.  czm_modelViewProjectionRelativeToEye

  28.  czm_modelViewInfiniteProjection

  29.  czm_orthographicIn3D

  30.  czm_normal

  31.  czm_normal3D

  32.  czm_inverseNormal

  33.  czm_inverseNormal3D

  34.  czm_eyeHeight

  35.  czm_eyeHeight2D

  36.  czm_entireFrustum

  37.  czm_currentFrustum

  38.  czm_frustumPlanes

  39.  czm_farDepthFromNearPlusOne

  40.  czm_log2FarDepthFromNearPlusOne

  41.  czm_sunPositionWC

  42.  czm_sunPositionColumbusView

  43.  czm_sunDirectionEC

  44.  czm_sunDirectionWC

  45.  czm_moonDirectionEC

  46.  czm_lightDirectionEC

  47.  czm_lightDirectionWC

  48.  czm_lightColor

  49.  czm_lightColorHdr

  50.  czm_encodedCameraPositionMCHigh

  51.  czm_viewerPositionWC

  52.  czm_frameNumber

  53.  czm_morphTime

  54.  czm_sceneMode

  55.  czm_pass

  56.  czm_backgroundColor

  57.  czm_brdfLut

  58.  czm_environmentMap

  59.  czm_specularEnvironmentMaps

  60.  czm_specularEnvironmentMapSize

  61.  czm_specularEnvironmentMapsMaximumLOD

  62.  czm_sphericalHarmonicCoefficients

  63.  czm_temeToPseudoFixed

  64.  czm_pixelRatio

  65.  czm_fogDensity

  66.  czm_splitPosition

  67.  czm_geometricToleranceOverMeter

  68.  czm_minimumDisableDepthTestDistance

  69.  czm_invertClassificationColor

  70.  czm_gamma

  71.  czm_ellipsoidRadii

  72.  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);
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值