#if defined paraboloid_point_shape #extension GL_EXT_frag_depth : enable #endif #define PI 3.141592653589793 precision highp float; precision highp int; /* #if defined(usePanoMap) uniform samplerCube pano0Map; //随便设置一个samplerCube去使用都会让点云消失 uniform samplerCube pano1Map; uniform float progress; uniform float easeInOutRatio; uniform vec3 pano0Position; uniform mat4 pano0Matrix; uniform vec3 pano1Position; uniform mat4 pano1Matrix; varying vec3 vWorldPosition0; varying vec3 vWorldPosition1; #endif */ //------------ uniform mat4 viewMatrix; uniform mat4 uViewInv; uniform mat4 uProjInv; uniform vec3 cameraPosition; uniform mat4 projectionMatrix; //uniform float uOpacity; varying float vOpacity; //add uniform float blendHardness; uniform float blendDepthSupplement; uniform float fov; uniform float uSpacing; uniform float near; uniform float far; uniform float uPCIndex; uniform float uScreenWidth; uniform float uScreenHeight; varying vec3 vColor; varying float vLogDepth; varying vec3 vViewPosition; varying float vRadius; varying float vPointSize; varying vec3 vPosition; float specularStrength = 1.0; vec2 getSamplerCoord( vec3 direction ) { direction = normalize(direction); float tx=atan(direction.x,-direction.y)/(PI*2.0)+0.5; float ty=acos(direction.z)/PI; return vec2(tx,ty); } void main() { vec3 color = vColor; /*#if defined(usePanoMap) //加 经测试,即使全部写在fragment里也是无论pointsize多大都是一个点一个颜色,所以干脆写在vectex里 vec4 colorFromPano0=textureCube(pano0Map,vWorldPosition0.xyz); vec4 colorFromPano1=textureCube(pano1Map,vWorldPosition1.xyz); color = mix(colorFromPano0,colorFromPano1,progress).xyz; //float easeInOutRatio = 0.0; //缓冲,渐变点云到贴图的颜色 if(progress < easeInOutRatio){ float easeProgress = (easeInOutRatio - progress) / easeInOutRatio; color = mix(color,vColor,easeProgress); }else if(progress > 1.0 - easeInOutRatio){ float easeProgress = (progress - (1.0 - easeInOutRatio) ) / easeInOutRatio; color = mix(color,vColor,easeProgress); } #else color = vColor; #endif*/ float depth = gl_FragCoord.z; #if defined(circle_point_shape) || defined(paraboloid_point_shape) float u = 2.0 * gl_PointCoord.x - 1.0; float v = 2.0 * gl_PointCoord.y - 1.0; #endif #if defined(circle_point_shape) float cc = u*u + v*v; if(cc > 1.0){ discard; } #endif #if defined color_type_indices //pick point recognize gl_FragColor = vec4(color, uPCIndex / 255.0); #else gl_FragColor = vec4(color, vOpacity); #endif #if defined paraboloid_point_shape float wi = 0.0 - ( u*u + v*v); vec4 pos = vec4(vViewPosition, 1.0); pos.z += wi * vRadius; float linearDepth = -pos.z; pos = projectionMatrix * pos; pos = pos / pos.w; float expDepth = pos.z; depth = (pos.z + 1.0) / 2.0; gl_FragDepthEXT = depth; #if defined(color_type_depth) color.r = linearDepth; color.g = expDepth; #endif #if defined(use_edl) gl_FragColor.a = log2(linearDepth); #endif #else #if defined(use_edl) gl_FragColor.a = vLogDepth; #endif #endif #if defined(weighted_splats) float distance = 2.0 * length(gl_PointCoord.xy - 0.5); float weight = max(0.0, 1.0 - distance); weight = pow(weight, 1.5); gl_FragColor.a = weight; gl_FragColor.xyz = gl_FragColor.xyz * weight; #endif //gl_FragColor = vec4(0.0, 0.7, 0.0, 1.0); }