improving interpolation mode

This commit is contained in:
mschuetz 2015-04-12 16:55:14 +02:00
parent aae8bf7c23
commit e2d4499799

View File

@ -618,6 +618,8 @@ Potree.PointCloudMaterial.vs_points = [
"varying vec3 vColor; ",
"varying float vDepth; ",
"varying float vLinearDepth; ",
"varying vec3 viewPos; ",
"varying float vRadius; ",
" ",
" ",
"#if defined(adaptive_point_size) || defined(color_type_octree_depth) ",
@ -716,6 +718,7 @@ Potree.PointCloudMaterial.vs_points = [
"void main() { ",
" ",
" vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); ",
" viewPos = mvPosition.xyz; ",
" gl_Position = projectionMatrix * mvPosition; ",
" //float pw = gl_Position.w; ",
" //float pd = gl_Position.z; ",
@ -766,24 +769,25 @@ Potree.PointCloudMaterial.vs_points = [
" // ",
" // POINT SIZE TYPES ",
" // ",
" float projectionFactor = (1.0 / tan(fov/2.0)) / (-mvPosition.z); ",
" projectionFactor = projectionFactor * screenHeight / 2.0; ",
" float r = spacing * 1.5; ",
" vRadius = r; ",
" #if defined fixed_point_size ",
" gl_PointSize = size; ",
" #elif defined attenuated_point_size ",
" //gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) ); ",
" gl_PointSize = (1.0 / tan(fov/2.0)) * size / (-mvPosition.z); ",
" gl_PointSize = gl_PointSize * screenHeight / 2.0; ",
" gl_PointSize = size * projectionFactor; ",
" #elif defined adaptive_point_size ",
" //gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) ); ",
" //gl_PointSize = (1.0 / tan(fov/2.0)) * r / sqrt( max(0.0, mvPosition.z * mvPosition.z - r * r)); ",
" gl_PointSize = (1.0 / tan(fov/2.0)) * r / (-mvPosition.z); ",
" gl_PointSize = size * gl_PointSize * screenHeight / 2.0; ",
" gl_PointSize = gl_PointSize / pow(1.9, getOctreeDepth()); ",
" float worldSpaceSize = size * r / pow(1.9, getOctreeDepth()); ",
" gl_PointSize = worldSpaceSize * projectionFactor; ",
" #endif ",
" ",
" gl_PointSize = max(minSize, gl_PointSize); ",
" gl_PointSize = min(50.0, gl_PointSize); ",
" ",
" vRadius = gl_PointSize / projectionFactor; ",
" ",
" ",
" // clip box ",
" #if defined use_clip_box ",
" bool insideAny = false; ",
@ -822,17 +826,31 @@ Potree.PointCloudMaterial.fs_points_rgb = [
"precision mediump int; ",
" ",
"//uniform float opacity; ",
"uniform mat4 modelMatrix; ",
"uniform mat4 modelViewMatrix; ",
"uniform mat4 projectionMatrix; ",
"uniform mat4 viewMatrix; ",
"uniform mat3 normalMatrix; ",
"uniform vec3 cameraPosition; ",
"uniform float fov; ",
"uniform float spacing; ",
"uniform float near; ",
"uniform float far; ",
" ",
"uniform float pcIndex; ",
"uniform float screenWidth; ",
"uniform float screenHeight; ",
"uniform float blendDepth; ",
"uniform float blendDepth; ",
" ",
"uniform sampler2D depthMap; ",
"uniform sampler2D depthMap; ",
" ",
"varying vec3 vColor; ",
"varying float vOpacity; ",
"varying float vLinearDepth; ",
"varying float vDepth; ",
"varying float vOpacity; ",
"varying float vLinearDepth; ",
"varying float vDepth; ",
"varying vec3 viewPos; ",
"varying float vRadius; ",
" ",
" ",
"void main() { ",
" ",
@ -845,34 +863,40 @@ Potree.PointCloudMaterial.fs_points_rgb = [
" discard; ",
" } ",
" #endif ",
" ",
" #if defined weighted_splats ",
" vec2 uv = gl_FragCoord.xy / vec2(screenWidth, screenHeight); ",
" ",
" float depth = texture2D(depthMap, uv).r; ",
" if(vLinearDepth > depth + blendDepth){ ",
" discard; ",
" } ",
" #endif ",
" ",
" #if defined weighted_splats ",
" vec2 uv = gl_FragCoord.xy / vec2(screenWidth, screenHeight); ",
" ",
" float depth = texture2D(depthMap, uv).r; ",
" if(vLinearDepth > depth + blendDepth){ ",
" discard; ",
" } ",
" #endif ",
" ",
" #if defined use_interpolation ",
" gl_FragDepthEXT = gl_FragCoord.z + 0.002*(1.0-pow(c, 1.0)) * gl_FragCoord.w; ",
" vec4 cPos = vec4(viewPos, 1.0); ",
" cPos.z = cPos.z + c * vRadius; ",
" vec4 pos = projectionMatrix * cPos; ",
" pos = pos / pos.w; ",
" ",
" gl_FragDepthEXT = (pos.z + 1.0) / 2.0; ",
" ",
" //gl_FragDepthEXT = gl_FragCoord.z + 0.002*(1.0-pow(c, 1.0)) * gl_FragCoord.w; ",
" #endif ",
" ",
" ",
" #if defined color_type_point_index ",
" gl_FragColor = vec4(vColor, pcIndex / 255.0); ",
" #else ",
" gl_FragColor = vec4(vColor, vOpacity); ",
" gl_FragColor = vec4(vColor, vOpacity); ",
" #endif ",
" ",
" ",
" #if defined weighted_splats ",
" float w = pow(c, 2.0); ",
" gl_FragColor.rgb = gl_FragColor.rgb * w; ",
" gl_FragColor.a = w; ",
" #endif ",
" ",
" #if defined weighted_splats ",
" float w = pow(c, 2.0); ",
" gl_FragColor.rgb = gl_FragColor.rgb * w; ",
" gl_FragColor.a = w; ",
" #endif ",
" ",
" ",
"} "];