Cesium--一些实验过程中的效果记录

1.一种反射效果:

 

片元着色器代码

fragmentShaderSource:`
					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)));
						vec3 positionToEyeEC = -v_positionEC;
						czm_material material = czm_getMaterial(materialInput);
						
						float flowMapOffset0 = 20.0;
						float flowMapOffset1 = 20.0;
						float halfCycle = 0.15 * 0.5;
						float scale = 1.0;
						float reflectivity = 0.02;
						
						vec3 toEye = normalize( positionToEyeEC );
			
						vec2 flow = czm_lightDirectionEC.xy;
						flow.x *= - 1.0;
			
						// sample normal maps (distort uvs with flowdata)
						vec4 normalColor0 = vec4(normalEC,1.0);
						vec4 normalColor1 = vec4(normalEC,1.0);
			
						// linear interpolate to get the final normal color
						float flowLerp = abs( halfCycle - flowMapOffset0 ) / halfCycle;
						vec4 normalColor = mix( normalColor0, normalColor1, flowLerp );
			
						// calculate normal vector
						vec3 normal = normalize( vec3( normalColor.r * 2.0 - 1.0, normalColor.b,  normalColor.g * 2.0 - 1.0 ) );
			
						// calculate the fresnel term to blend reflection and refraction maps
						float theta = max( dot( toEye, normal ), 0.0 );
						float reflectance = reflectivity + ( 1.0 - reflectivity ) * pow( ( 1.0 - theta ), 5.0 );
			
						// calculate final uv coords
						vec3 coord = materialInput.str;
						vec2 uv = v_st;
						out_FragColor = vec4( vec3(51.0/255.0,204.0/255.0,204.0/255.0), 1.0 ) * reflectance ;
						
					}
				`

你可能感兴趣的:(cesium,javascript)