Merge pull request #167 from potree/occlusion_shaders
Occlusion shaders
This commit is contained in:
commit
869eb51092
@ -85,7 +85,6 @@ Potree.Shaders["pointcloud.vs"] = [
|
||||
"",
|
||||
"#define max_clip_boxes 30",
|
||||
"",
|
||||
"",
|
||||
"attribute float intensity;",
|
||||
"attribute float classification;",
|
||||
"attribute float returnNumber;",
|
||||
@ -125,8 +124,8 @@ Potree.Shaders["pointcloud.vs"] = [
|
||||
"",
|
||||
"varying float vOpacity;",
|
||||
"varying vec3 vColor;",
|
||||
"varying float vDepth;",
|
||||
"varying float vLinearDepth;",
|
||||
"varying float vLogDepth;",
|
||||
"varying vec3 vViewPosition;",
|
||||
"varying float vRadius;",
|
||||
"varying vec3 vWorldPosition;",
|
||||
@ -280,9 +279,16 @@ Potree.Shaders["pointcloud.vs"] = [
|
||||
" gl_Position = projectionMatrix * mvPosition;",
|
||||
" vOpacity = opacity;",
|
||||
" vLinearDepth = -mvPosition.z;",
|
||||
" vDepth = mvPosition.z / gl_Position.w;",
|
||||
" vNormal = normalize(normalMatrix * normal);",
|
||||
"",
|
||||
" ",
|
||||
" #if defined(use_edl)",
|
||||
" vLogDepth = log2(gl_Position.w + 1.0) / log2(far + 1.0);",
|
||||
" #endif",
|
||||
" ",
|
||||
" //#if defined(use_logarithmic_depth_buffer)",
|
||||
" // float logarithmicZ = (2.0 * log2(gl_Position.w + 1.0) / log2(far + 1.0) - 1.0) * gl_Position.w;",
|
||||
" // gl_Position.z = logarithmicZ;",
|
||||
" //#endif",
|
||||
"",
|
||||
" // ---------------------",
|
||||
" // POINT COLOR",
|
||||
@ -295,8 +301,9 @@ Potree.Shaders["pointcloud.vs"] = [
|
||||
" float w = (world.y - heightMin) / (heightMax-heightMin);",
|
||||
" vColor = texture2D(gradient, vec2(w,1.0-w)).rgb;",
|
||||
" #elif defined color_type_depth",
|
||||
" float d = -mvPosition.z ;",
|
||||
" vColor = vec3(d, vDepth, 0.0);",
|
||||
" float linearDepth = -mvPosition.z ;",
|
||||
" float expDepth = (gl_Position.z / gl_Position.w) * 0.5 + 0.5;",
|
||||
" vColor = vec3(linearDepth, expDepth, 0.0);",
|
||||
" #elif defined color_type_intensity",
|
||||
" float w = (intensity - intensityMin) / (intensityMax - intensityMin);",
|
||||
" vColor = vec3(w, w, w);",
|
||||
@ -315,6 +322,11 @@ Potree.Shaders["pointcloud.vs"] = [
|
||||
" float c = mod(classification, 16.0);",
|
||||
" vec2 uv = vec2(c / 255.0, 0.5);",
|
||||
" vColor = texture2D(classificationLUT, uv).rgb;",
|
||||
" ",
|
||||
" // TODO only for testing - removing points with class 7",
|
||||
" if(classification == 7.0){",
|
||||
" gl_Position = vec4(100.0, 100.0, 100.0, 0.0);",
|
||||
" }",
|
||||
" #elif defined color_type_return_number",
|
||||
" float w = (returnNumber - 1.0) / 4.0 + 0.1;",
|
||||
" vColor = texture2D(gradient, vec2(w, 1.0 - w)).rgb;",
|
||||
@ -465,7 +477,7 @@ Potree.Shaders["pointcloud.fs"] = [
|
||||
"varying vec3 vColor;",
|
||||
"varying float vOpacity;",
|
||||
"varying float vLinearDepth;",
|
||||
"varying float vDepth;",
|
||||
"varying float vLogDepth;",
|
||||
"varying vec3 vViewPosition;",
|
||||
"varying float vRadius;",
|
||||
"varying vec3 vWorldPosition;",
|
||||
@ -475,6 +487,9 @@ Potree.Shaders["pointcloud.fs"] = [
|
||||
"",
|
||||
"void main() {",
|
||||
"",
|
||||
" vec3 color = vColor;",
|
||||
" float depth = gl_FragCoord.z;",
|
||||
"",
|
||||
" #if defined(circle_point_shape) || defined(use_interpolation) || defined (weighted_splats)",
|
||||
" float u = 2.0 * gl_PointCoord.x - 1.0;",
|
||||
" float v = 2.0 * gl_PointCoord.y - 1.0;",
|
||||
@ -489,25 +504,34 @@ Potree.Shaders["pointcloud.fs"] = [
|
||||
" ",
|
||||
" #if defined weighted_splats",
|
||||
" vec2 uv = gl_FragCoord.xy / vec2(screenWidth, screenHeight);",
|
||||
" float depth = texture2D(depthMap, uv).r;",
|
||||
" if(vLinearDepth > depth + vRadius){",
|
||||
" float sDepth = texture2D(depthMap, uv).r;",
|
||||
" if(vLinearDepth > sDepth + vRadius){",
|
||||
" discard;",
|
||||
" }",
|
||||
" #endif",
|
||||
" ",
|
||||
" #if defined use_interpolation",
|
||||
" float w = 1.0 - ( u*u + v*v);",
|
||||
" float wi = 0.0 - ( u*u + v*v);",
|
||||
" vec4 pos = vec4(-vViewPosition, 1.0);",
|
||||
" pos.z += w * vRadius;",
|
||||
" pos.z += wi * vRadius;",
|
||||
" float linearDepth = pos.z;",
|
||||
" pos = projectionMatrix * pos;",
|
||||
" pos = pos / pos.w;",
|
||||
" gl_FragDepthEXT = (pos.z + 1.0) / 2.0;",
|
||||
" 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",
|
||||
" ",
|
||||
" #endif",
|
||||
" ",
|
||||
" #if defined color_type_point_index",
|
||||
" gl_FragColor = vec4(vColor, pcIndex / 255.0);",
|
||||
" gl_FragColor = vec4(color, pcIndex / 255.0);",
|
||||
" #else",
|
||||
" gl_FragColor = vec4(vColor, vOpacity);",
|
||||
" gl_FragColor = vec4(color, vOpacity);",
|
||||
" #endif",
|
||||
" ",
|
||||
" #if defined weighted_splats",
|
||||
@ -638,6 +662,11 @@ Potree.Shaders["pointcloud.fs"] = [
|
||||
"",
|
||||
" #endif",
|
||||
" ",
|
||||
" ",
|
||||
" #if defined(use_edl)",
|
||||
" gl_FragColor.a = vLogDepth;",
|
||||
" #endif",
|
||||
" ",
|
||||
"}",
|
||||
"",
|
||||
"",
|
||||
@ -665,15 +694,177 @@ Potree.Shaders["normalize.fs"] = [
|
||||
"varying vec2 vUv;",
|
||||
"",
|
||||
"void main() {",
|
||||
" vec4 color = texture2D(texture, vUv); ",
|
||||
" float depth = texture2D(depthMap, vUv).g; ",
|
||||
" ",
|
||||
" if(depth <= 0.0){",
|
||||
" discard;",
|
||||
" }",
|
||||
" ",
|
||||
" vec4 color = texture2D(texture, vUv); ",
|
||||
" color = color / color.w;",
|
||||
" gl_FragColor = color; ",
|
||||
" ",
|
||||
" gl_FragColor = vec4(color.xyz, 1.0); ",
|
||||
" ",
|
||||
" gl_FragDepthEXT = depth;",
|
||||
"}",
|
||||
].join("\n");
|
||||
|
||||
Potree.Shaders["edl.vs"] = [
|
||||
"",
|
||||
"",
|
||||
"varying vec2 vUv;",
|
||||
"varying vec3 vViewRay;",
|
||||
"",
|
||||
"void main() {",
|
||||
" vUv = uv;",
|
||||
" ",
|
||||
" vec4 mvPosition = modelViewMatrix * vec4(position,1.0);",
|
||||
" vViewRay = mvPosition.xyz;",
|
||||
"",
|
||||
" gl_Position = projectionMatrix * mvPosition;",
|
||||
" ",
|
||||
" ",
|
||||
"}",
|
||||
].join("\n");
|
||||
|
||||
Potree.Shaders["edl.fs"] = [
|
||||
"",
|
||||
"// ",
|
||||
"// adapted from the EDL shader code from Christian Boucheny in cloud compare:",
|
||||
"// https://github.com/cloudcompare/trunk/tree/master/plugins/qEDL/shaders/EDL",
|
||||
"//",
|
||||
"",
|
||||
"#define NEIGHBOUR_COUNT 8",
|
||||
"",
|
||||
"uniform mat4 projectionMatrix;",
|
||||
"",
|
||||
"uniform float screenWidth;",
|
||||
"uniform float screenHeight;",
|
||||
"uniform float near;",
|
||||
"uniform float far;",
|
||||
"uniform vec2 neighbours[NEIGHBOUR_COUNT];",
|
||||
"uniform vec3 lightDir;",
|
||||
"uniform float zoom;",
|
||||
"uniform float pixScale;",
|
||||
"uniform float expScale;",
|
||||
"",
|
||||
"//uniform sampler2D depthMap;",
|
||||
"uniform sampler2D colorMap;",
|
||||
"",
|
||||
"varying vec2 vUv;",
|
||||
"varying vec3 vViewRay;",
|
||||
"",
|
||||
"/**",
|
||||
" * transform linear depth to [0,1] interval with 1 beeing closest to the camera.",
|
||||
" */",
|
||||
"float ztransform(float linearDepth){",
|
||||
" return 1.0 - (linearDepth - near) / (far - near);",
|
||||
"}",
|
||||
"",
|
||||
"float expToLinear(float z){",
|
||||
" z = 2.0 * z - 1.0;",
|
||||
" float linear = (2.0 * near * far) / (far + near - z * (far - near));",
|
||||
"",
|
||||
" return linear;",
|
||||
"}",
|
||||
"",
|
||||
"// this actually only returns linear depth values if LOG_BIAS is 1.0",
|
||||
"// lower values work out more nicely, though.",
|
||||
"#define LOG_BIAS 0.01",
|
||||
"float logToLinear(float z){",
|
||||
" return (pow((1.0 + LOG_BIAS * far), z) - 1.0) / LOG_BIAS;",
|
||||
"}",
|
||||
"",
|
||||
"float obscurance(float z, float dist){",
|
||||
" return max(0.0, z) / dist;",
|
||||
"}",
|
||||
"",
|
||||
"float computeObscurance(float linearDepth, float scale){",
|
||||
" vec4 P = vec4(lightDir, -dot(lightDir, vec3(0.0, 0.0, ztransform(linearDepth)) ) );",
|
||||
" ",
|
||||
" float sum = 0.0;",
|
||||
" ",
|
||||
" for(int c = 0; c < NEIGHBOUR_COUNT; c++){",
|
||||
" vec2 N_rel_pos = scale * zoom / vec2(screenWidth, screenHeight) * neighbours[c];",
|
||||
" vec2 N_abs_pos = vUv + N_rel_pos;",
|
||||
" ",
|
||||
" float neighbourDepth = logToLinear(texture2D(colorMap, N_abs_pos).a);",
|
||||
" ",
|
||||
" if(neighbourDepth != 0.0){",
|
||||
" float Zn = ztransform(neighbourDepth);",
|
||||
" float Znp = dot( vec4( N_rel_pos, Zn, 1.0), P );",
|
||||
" ",
|
||||
" sum += obscurance( Znp, 0.05 * linearDepth );",
|
||||
" }",
|
||||
" }",
|
||||
" ",
|
||||
" return sum;",
|
||||
"}",
|
||||
"",
|
||||
"void main(){",
|
||||
" float linearDepth = logToLinear(texture2D(colorMap, vUv).a);",
|
||||
" ",
|
||||
" float f = computeObscurance(linearDepth, pixScale);",
|
||||
" f = exp(-expScale * f);",
|
||||
" ",
|
||||
" vec4 color = texture2D(colorMap, vUv);",
|
||||
" if(color.a == 0.0 && f >= 1.0){",
|
||||
" discard;",
|
||||
" }",
|
||||
" ",
|
||||
" gl_FragColor = vec4(color.rgb * f, 1.0);",
|
||||
"}",
|
||||
"",
|
||||
].join("\n");
|
||||
|
||||
Potree.Shaders["blur.vs"] = [
|
||||
"",
|
||||
"varying vec2 vUv;",
|
||||
"",
|
||||
"void main() {",
|
||||
" vUv = uv;",
|
||||
"",
|
||||
" gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);",
|
||||
"}",
|
||||
].join("\n");
|
||||
|
||||
Potree.Shaders["blur.fs"] = [
|
||||
"",
|
||||
"uniform mat4 projectionMatrix;",
|
||||
"",
|
||||
"uniform float screenWidth;",
|
||||
"uniform float screenHeight;",
|
||||
"uniform float near;",
|
||||
"uniform float far;",
|
||||
"",
|
||||
"uniform sampler2D map;",
|
||||
"",
|
||||
"varying vec2 vUv;",
|
||||
"",
|
||||
"void main() {",
|
||||
"",
|
||||
" float dx = 1.0 / screenWidth;",
|
||||
" float dy = 1.0 / screenHeight;",
|
||||
"",
|
||||
" vec3 color = vec3(0.0, 0.0, 0.0);",
|
||||
" color += texture2D(map, vUv + vec2(-dx, -dy)).rgb;",
|
||||
" color += texture2D(map, vUv + vec2( 0, -dy)).rgb;",
|
||||
" color += texture2D(map, vUv + vec2(+dx, -dy)).rgb;",
|
||||
" color += texture2D(map, vUv + vec2(-dx, 0)).rgb;",
|
||||
" color += texture2D(map, vUv + vec2( 0, 0)).rgb;",
|
||||
" color += texture2D(map, vUv + vec2(+dx, 0)).rgb;",
|
||||
" color += texture2D(map, vUv + vec2(-dx, dy)).rgb;",
|
||||
" color += texture2D(map, vUv + vec2( 0, dy)).rgb;",
|
||||
" color += texture2D(map, vUv + vec2(+dx, dy)).rgb;",
|
||||
" ",
|
||||
" color = color / 9.0;",
|
||||
" ",
|
||||
" gl_FragColor = vec4(color, 1.0);",
|
||||
" ",
|
||||
" ",
|
||||
"}",
|
||||
].join("\n");
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1502,6 +1693,7 @@ Potree.Classification = {
|
||||
};
|
||||
|
||||
|
||||
|
||||
Potree.PointSizeType = {
|
||||
FIXED: 0,
|
||||
ATTENUATED: 1,
|
||||
@ -1546,7 +1738,7 @@ Potree.PointCloudMaterial = function(parameters){
|
||||
|
||||
parameters = parameters || {};
|
||||
|
||||
var color = new THREE.Color( 0x000000 );
|
||||
var color = new THREE.Color( 0xffffff );
|
||||
var map = THREE.ImageUtils.generateDataTexture( 2048, 1, color );
|
||||
map.magFilter = THREE.NearestFilter;
|
||||
this.visibleNodesTexture = map;
|
||||
@ -1572,6 +1764,8 @@ Potree.PointCloudMaterial = function(parameters){
|
||||
this.classificationTexture = Potree.PointCloudMaterial.generateClassificationTexture(this._classification);
|
||||
this.lights = true;
|
||||
this._treeType = treeType;
|
||||
this._useLogarithmicDepthBuffer = false;
|
||||
this._useEDL = false;
|
||||
|
||||
|
||||
|
||||
@ -1584,7 +1778,7 @@ Potree.PointCloudMaterial = function(parameters){
|
||||
screenHeight: { type: "f", value: 1.0 },
|
||||
near: { type: "f", value: 0.1 },
|
||||
far: { type: "f", value: 1.0 },
|
||||
uColor: { type: "c", value: new THREE.Color( 0xff0000 ) },
|
||||
uColor: { type: "c", value: new THREE.Color( 0xffffff ) },
|
||||
opacity: { type: "f", value: 1.0 },
|
||||
size: { type: "f", value: 10 },
|
||||
minSize: { type: "f", value: 2 },
|
||||
@ -1725,6 +1919,14 @@ Potree.PointCloudMaterial.prototype.getDefines = function(){
|
||||
defines += "#define use_interpolation\n";
|
||||
}
|
||||
|
||||
if(this._useLogarithmicDepthBuffer){
|
||||
defines += "#define use_logarithmic_depth_buffer\n";
|
||||
}
|
||||
|
||||
if(this._useEDL){
|
||||
defines += "#define use_edl\n";
|
||||
}
|
||||
|
||||
if(this._pointColorType === Potree.PointColorType.RGB){
|
||||
defines += "#define color_type_rgb\n";
|
||||
}else if(this._pointColorType === Potree.PointColorType.COLOR){
|
||||
@ -1997,6 +2199,30 @@ Object.defineProperty(Potree.PointCloudMaterial.prototype, "interpolate", {
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(Potree.PointCloudMaterial.prototype, "useEDL", {
|
||||
get: function(){
|
||||
return this._useEDL;
|
||||
},
|
||||
set: function(value){
|
||||
if(this._useEDL !== value){
|
||||
this._useEDL = value;
|
||||
this.updateShaderSource();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(Potree.PointCloudMaterial.prototype, "useLogarithmicDepthBuffer", {
|
||||
get: function(){
|
||||
return this._useLogarithmicDepthBuffer;
|
||||
},
|
||||
set: function(value){
|
||||
if(this._useLogarithmicDepthBuffer !== value){
|
||||
this._useLogarithmicDepthBuffer = value;
|
||||
this.updateShaderSource();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(Potree.PointCloudMaterial.prototype, "color", {
|
||||
get: function(){
|
||||
return this.uniforms.uColor.value;
|
||||
@ -2185,6 +2411,118 @@ Potree.PointCloudMaterial.generateClassificationTexture = function(classificati
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
// Algorithm by Christian Boucheny
|
||||
// shader code taken and adapted from CloudCompare
|
||||
//
|
||||
// see
|
||||
// https://github.com/cloudcompare/trunk/tree/master/plugins/qEDL/shaders/EDL
|
||||
// http://www.kitware.com/source/home/post/9
|
||||
// https://tel.archives-ouvertes.fr/tel-00438464/document p. 115+ (french)
|
||||
|
||||
|
||||
|
||||
|
||||
Potree.EyeDomeLightingMaterial = function(parameters){
|
||||
THREE.Material.call( this );
|
||||
|
||||
parameters = parameters || {};
|
||||
|
||||
var neighbourCount = 8;
|
||||
var neighbours = new Float32Array(neighbourCount*2);
|
||||
for(var c = 0; c < neighbourCount; c++){
|
||||
neighbours[2*c+0] = Math.cos(2 * c * Math.PI / neighbourCount);
|
||||
neighbours[2*c+1] = Math.sin(2 * c * Math.PI / neighbourCount);
|
||||
}
|
||||
|
||||
//var neighbourCount = 32;
|
||||
//var neighbours = new Float32Array(neighbourCount*2);
|
||||
//for(var c = 0; c < neighbourCount; c++){
|
||||
// var r = (c / neighbourCount) * 4 + 0.1;
|
||||
// neighbours[2*c+0] = Math.cos(2 * c * Math.PI / neighbourCount) * r;
|
||||
// neighbours[2*c+1] = Math.sin(2 * c * Math.PI / neighbourCount) * r;
|
||||
//}
|
||||
|
||||
var lightDir = new THREE.Vector3(0.0, 0.0, 1.0).normalize();
|
||||
|
||||
var uniforms = {
|
||||
screenWidth: { type: "f", value: 0 },
|
||||
screenHeight: { type: "f", value: 0 },
|
||||
near: { type: "f", value: 0 },
|
||||
far: { type: "f", value: 0 },
|
||||
pixScale: { type: "f", value: 1.0 },
|
||||
expScale: { type: "f", value: 100.0 },
|
||||
zoom: { type: "f", value: 3.0 },
|
||||
lightDir: { type: "v3", value: lightDir },
|
||||
neighbours: { type: "2fv", value: neighbours },
|
||||
depthMap: { type: "t", value: null },
|
||||
colorMap: { type: "t", value: null }
|
||||
};
|
||||
|
||||
this.setValues({
|
||||
uniforms: uniforms,
|
||||
vertexShader: Potree.Shaders["edl.vs"],
|
||||
fragmentShader: Potree.Shaders["edl.fs"],
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
Potree.EyeDomeLightingMaterial.prototype = new THREE.ShaderMaterial();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// see http://john-chapman-graphics.blogspot.co.at/2013/01/ssao-tutorial.html
|
||||
|
||||
|
||||
|
||||
Potree.BlurMaterial = function(parameters){
|
||||
THREE.Material.call( this );
|
||||
|
||||
parameters = parameters || {};
|
||||
|
||||
var uniforms = {
|
||||
near: { type: "f", value: 0 },
|
||||
far: { type: "f", value: 0 },
|
||||
screenWidth: { type: "f", value: 0 },
|
||||
screenHeight: { type: "f", value: 0 },
|
||||
map: { type: "t", value: null }
|
||||
};
|
||||
|
||||
this.setValues({
|
||||
uniforms: uniforms,
|
||||
vertexShader: Potree.Shaders["blur.vs"],
|
||||
fragmentShader: Potree.Shaders["blur.fs"],
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
Potree.BlurMaterial.prototype = new THREE.ShaderMaterial();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author mschuetz / http://mschuetz.at
|
||||
@ -5702,6 +6040,28 @@ Potree.utils.frustumSphereIntersection = function(frustum, sphere){
|
||||
};
|
||||
|
||||
|
||||
Potree.utils.screenPass = new function(){
|
||||
|
||||
this.screenScene = new THREE.Scene();
|
||||
this.screenQuad = new THREE.Mesh(new THREE.PlaneBufferGeometry(2, 2, 0));
|
||||
this.screenQuad.material.depthTest = true;
|
||||
this.screenQuad.material.depthWrite = true;
|
||||
this.screenQuad.material.transparent = true;
|
||||
this.screenScene.add(this.screenQuad);
|
||||
this.camera = new THREE.Camera();
|
||||
|
||||
this.render = function(renderer, material, target){
|
||||
this.screenQuad.material = material;
|
||||
|
||||
if(typeof target === undefined){
|
||||
renderer.render(this.screenScene, this.camera);
|
||||
}else{
|
||||
renderer.render(this.screenScene, this.camera, target);
|
||||
}
|
||||
}
|
||||
}();
|
||||
|
||||
|
||||
|
||||
|
||||
Potree.Features = function(){
|
||||
@ -5776,6 +6136,20 @@ Potree.Features = function(){
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
SHADER_EDL: {
|
||||
isSupported: function(){
|
||||
|
||||
var supported = true;
|
||||
|
||||
supported = supported && gl.getExtension("EXT_frag_depth");
|
||||
supported = supported && gl.getExtension("OES_texture_float");
|
||||
supported = supported && gl.getParameter(gl.MAX_VARYING_VECTORS) >= 8;
|
||||
|
||||
return supported;
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
precision: precision
|
||||
}
|
||||
|
||||
12
build/js/potree.min.js
vendored
12
build/js/potree.min.js
vendored
File diff suppressed because one or more lines are too long
@ -23,7 +23,6 @@ Potree.Shaders["pointcloud.vs"] = [
|
||||
"",
|
||||
"#define max_clip_boxes 30",
|
||||
"",
|
||||
"",
|
||||
"attribute float intensity;",
|
||||
"attribute float classification;",
|
||||
"attribute float returnNumber;",
|
||||
@ -63,8 +62,8 @@ Potree.Shaders["pointcloud.vs"] = [
|
||||
"",
|
||||
"varying float vOpacity;",
|
||||
"varying vec3 vColor;",
|
||||
"varying float vDepth;",
|
||||
"varying float vLinearDepth;",
|
||||
"varying float vLogDepth;",
|
||||
"varying vec3 vViewPosition;",
|
||||
"varying float vRadius;",
|
||||
"varying vec3 vWorldPosition;",
|
||||
@ -218,9 +217,16 @@ Potree.Shaders["pointcloud.vs"] = [
|
||||
" gl_Position = projectionMatrix * mvPosition;",
|
||||
" vOpacity = opacity;",
|
||||
" vLinearDepth = -mvPosition.z;",
|
||||
" vDepth = mvPosition.z / gl_Position.w;",
|
||||
" vNormal = normalize(normalMatrix * normal);",
|
||||
"",
|
||||
" ",
|
||||
" #if defined(use_edl)",
|
||||
" vLogDepth = log2(gl_Position.w + 1.0) / log2(far + 1.0);",
|
||||
" #endif",
|
||||
" ",
|
||||
" //#if defined(use_logarithmic_depth_buffer)",
|
||||
" // float logarithmicZ = (2.0 * log2(gl_Position.w + 1.0) / log2(far + 1.0) - 1.0) * gl_Position.w;",
|
||||
" // gl_Position.z = logarithmicZ;",
|
||||
" //#endif",
|
||||
"",
|
||||
" // ---------------------",
|
||||
" // POINT COLOR",
|
||||
@ -233,8 +239,9 @@ Potree.Shaders["pointcloud.vs"] = [
|
||||
" float w = (world.y - heightMin) / (heightMax-heightMin);",
|
||||
" vColor = texture2D(gradient, vec2(w,1.0-w)).rgb;",
|
||||
" #elif defined color_type_depth",
|
||||
" float d = -mvPosition.z ;",
|
||||
" vColor = vec3(d, vDepth, 0.0);",
|
||||
" float linearDepth = -mvPosition.z ;",
|
||||
" float expDepth = (gl_Position.z / gl_Position.w) * 0.5 + 0.5;",
|
||||
" vColor = vec3(linearDepth, expDepth, 0.0);",
|
||||
" #elif defined color_type_intensity",
|
||||
" float w = (intensity - intensityMin) / (intensityMax - intensityMin);",
|
||||
" vColor = vec3(w, w, w);",
|
||||
@ -253,6 +260,11 @@ Potree.Shaders["pointcloud.vs"] = [
|
||||
" float c = mod(classification, 16.0);",
|
||||
" vec2 uv = vec2(c / 255.0, 0.5);",
|
||||
" vColor = texture2D(classificationLUT, uv).rgb;",
|
||||
" ",
|
||||
" // TODO only for testing - removing points with class 7",
|
||||
" if(classification == 7.0){",
|
||||
" gl_Position = vec4(100.0, 100.0, 100.0, 0.0);",
|
||||
" }",
|
||||
" #elif defined color_type_return_number",
|
||||
" float w = (returnNumber - 1.0) / 4.0 + 0.1;",
|
||||
" vColor = texture2D(gradient, vec2(w, 1.0 - w)).rgb;",
|
||||
@ -403,7 +415,7 @@ Potree.Shaders["pointcloud.fs"] = [
|
||||
"varying vec3 vColor;",
|
||||
"varying float vOpacity;",
|
||||
"varying float vLinearDepth;",
|
||||
"varying float vDepth;",
|
||||
"varying float vLogDepth;",
|
||||
"varying vec3 vViewPosition;",
|
||||
"varying float vRadius;",
|
||||
"varying vec3 vWorldPosition;",
|
||||
@ -413,6 +425,9 @@ Potree.Shaders["pointcloud.fs"] = [
|
||||
"",
|
||||
"void main() {",
|
||||
"",
|
||||
" vec3 color = vColor;",
|
||||
" float depth = gl_FragCoord.z;",
|
||||
"",
|
||||
" #if defined(circle_point_shape) || defined(use_interpolation) || defined (weighted_splats)",
|
||||
" float u = 2.0 * gl_PointCoord.x - 1.0;",
|
||||
" float v = 2.0 * gl_PointCoord.y - 1.0;",
|
||||
@ -427,25 +442,34 @@ Potree.Shaders["pointcloud.fs"] = [
|
||||
" ",
|
||||
" #if defined weighted_splats",
|
||||
" vec2 uv = gl_FragCoord.xy / vec2(screenWidth, screenHeight);",
|
||||
" float depth = texture2D(depthMap, uv).r;",
|
||||
" if(vLinearDepth > depth + vRadius){",
|
||||
" float sDepth = texture2D(depthMap, uv).r;",
|
||||
" if(vLinearDepth > sDepth + vRadius){",
|
||||
" discard;",
|
||||
" }",
|
||||
" #endif",
|
||||
" ",
|
||||
" #if defined use_interpolation",
|
||||
" float w = 1.0 - ( u*u + v*v);",
|
||||
" float wi = 0.0 - ( u*u + v*v);",
|
||||
" vec4 pos = vec4(-vViewPosition, 1.0);",
|
||||
" pos.z += w * vRadius;",
|
||||
" pos.z += wi * vRadius;",
|
||||
" float linearDepth = pos.z;",
|
||||
" pos = projectionMatrix * pos;",
|
||||
" pos = pos / pos.w;",
|
||||
" gl_FragDepthEXT = (pos.z + 1.0) / 2.0;",
|
||||
" 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",
|
||||
" ",
|
||||
" #endif",
|
||||
" ",
|
||||
" #if defined color_type_point_index",
|
||||
" gl_FragColor = vec4(vColor, pcIndex / 255.0);",
|
||||
" gl_FragColor = vec4(color, pcIndex / 255.0);",
|
||||
" #else",
|
||||
" gl_FragColor = vec4(vColor, vOpacity);",
|
||||
" gl_FragColor = vec4(color, vOpacity);",
|
||||
" #endif",
|
||||
" ",
|
||||
" #if defined weighted_splats",
|
||||
@ -576,6 +600,11 @@ Potree.Shaders["pointcloud.fs"] = [
|
||||
"",
|
||||
" #endif",
|
||||
" ",
|
||||
" ",
|
||||
" #if defined(use_edl)",
|
||||
" gl_FragColor.a = vLogDepth;",
|
||||
" #endif",
|
||||
" ",
|
||||
"}",
|
||||
"",
|
||||
"",
|
||||
@ -603,12 +632,174 @@ Potree.Shaders["normalize.fs"] = [
|
||||
"varying vec2 vUv;",
|
||||
"",
|
||||
"void main() {",
|
||||
" vec4 color = texture2D(texture, vUv); ",
|
||||
" float depth = texture2D(depthMap, vUv).g; ",
|
||||
" ",
|
||||
" if(depth <= 0.0){",
|
||||
" discard;",
|
||||
" }",
|
||||
" ",
|
||||
" vec4 color = texture2D(texture, vUv); ",
|
||||
" color = color / color.w;",
|
||||
" gl_FragColor = color; ",
|
||||
" ",
|
||||
" gl_FragColor = vec4(color.xyz, 1.0); ",
|
||||
" ",
|
||||
" gl_FragDepthEXT = depth;",
|
||||
"}",
|
||||
].join("\n");
|
||||
|
||||
Potree.Shaders["edl.vs"] = [
|
||||
"",
|
||||
"",
|
||||
"varying vec2 vUv;",
|
||||
"varying vec3 vViewRay;",
|
||||
"",
|
||||
"void main() {",
|
||||
" vUv = uv;",
|
||||
" ",
|
||||
" vec4 mvPosition = modelViewMatrix * vec4(position,1.0);",
|
||||
" vViewRay = mvPosition.xyz;",
|
||||
"",
|
||||
" gl_Position = projectionMatrix * mvPosition;",
|
||||
" ",
|
||||
" ",
|
||||
"}",
|
||||
].join("\n");
|
||||
|
||||
Potree.Shaders["edl.fs"] = [
|
||||
"",
|
||||
"// ",
|
||||
"// adapted from the EDL shader code from Christian Boucheny in cloud compare:",
|
||||
"// https://github.com/cloudcompare/trunk/tree/master/plugins/qEDL/shaders/EDL",
|
||||
"//",
|
||||
"",
|
||||
"#define NEIGHBOUR_COUNT 8",
|
||||
"",
|
||||
"uniform mat4 projectionMatrix;",
|
||||
"",
|
||||
"uniform float screenWidth;",
|
||||
"uniform float screenHeight;",
|
||||
"uniform float near;",
|
||||
"uniform float far;",
|
||||
"uniform vec2 neighbours[NEIGHBOUR_COUNT];",
|
||||
"uniform vec3 lightDir;",
|
||||
"uniform float zoom;",
|
||||
"uniform float pixScale;",
|
||||
"uniform float expScale;",
|
||||
"",
|
||||
"//uniform sampler2D depthMap;",
|
||||
"uniform sampler2D colorMap;",
|
||||
"",
|
||||
"varying vec2 vUv;",
|
||||
"varying vec3 vViewRay;",
|
||||
"",
|
||||
"/**",
|
||||
" * transform linear depth to [0,1] interval with 1 beeing closest to the camera.",
|
||||
" */",
|
||||
"float ztransform(float linearDepth){",
|
||||
" return 1.0 - (linearDepth - near) / (far - near);",
|
||||
"}",
|
||||
"",
|
||||
"float expToLinear(float z){",
|
||||
" z = 2.0 * z - 1.0;",
|
||||
" float linear = (2.0 * near * far) / (far + near - z * (far - near));",
|
||||
"",
|
||||
" return linear;",
|
||||
"}",
|
||||
"",
|
||||
"// this actually only returns linear depth values if LOG_BIAS is 1.0",
|
||||
"// lower values work out more nicely, though.",
|
||||
"#define LOG_BIAS 0.01",
|
||||
"float logToLinear(float z){",
|
||||
" return (pow((1.0 + LOG_BIAS * far), z) - 1.0) / LOG_BIAS;",
|
||||
"}",
|
||||
"",
|
||||
"float obscurance(float z, float dist){",
|
||||
" return max(0.0, z) / dist;",
|
||||
"}",
|
||||
"",
|
||||
"float computeObscurance(float linearDepth, float scale){",
|
||||
" vec4 P = vec4(lightDir, -dot(lightDir, vec3(0.0, 0.0, ztransform(linearDepth)) ) );",
|
||||
" ",
|
||||
" float sum = 0.0;",
|
||||
" ",
|
||||
" for(int c = 0; c < NEIGHBOUR_COUNT; c++){",
|
||||
" vec2 N_rel_pos = scale * zoom / vec2(screenWidth, screenHeight) * neighbours[c];",
|
||||
" vec2 N_abs_pos = vUv + N_rel_pos;",
|
||||
" ",
|
||||
" float neighbourDepth = logToLinear(texture2D(colorMap, N_abs_pos).a);",
|
||||
" ",
|
||||
" if(neighbourDepth != 0.0){",
|
||||
" float Zn = ztransform(neighbourDepth);",
|
||||
" float Znp = dot( vec4( N_rel_pos, Zn, 1.0), P );",
|
||||
" ",
|
||||
" sum += obscurance( Znp, 0.05 * linearDepth );",
|
||||
" }",
|
||||
" }",
|
||||
" ",
|
||||
" return sum;",
|
||||
"}",
|
||||
"",
|
||||
"void main(){",
|
||||
" float linearDepth = logToLinear(texture2D(colorMap, vUv).a);",
|
||||
" ",
|
||||
" float f = computeObscurance(linearDepth, pixScale);",
|
||||
" f = exp(-expScale * f);",
|
||||
" ",
|
||||
" vec4 color = texture2D(colorMap, vUv);",
|
||||
" if(color.a == 0.0 && f >= 1.0){",
|
||||
" discard;",
|
||||
" }",
|
||||
" ",
|
||||
" gl_FragColor = vec4(color.rgb * f, 1.0);",
|
||||
"}",
|
||||
"",
|
||||
].join("\n");
|
||||
|
||||
Potree.Shaders["blur.vs"] = [
|
||||
"",
|
||||
"varying vec2 vUv;",
|
||||
"",
|
||||
"void main() {",
|
||||
" vUv = uv;",
|
||||
"",
|
||||
" gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);",
|
||||
"}",
|
||||
].join("\n");
|
||||
|
||||
Potree.Shaders["blur.fs"] = [
|
||||
"",
|
||||
"uniform mat4 projectionMatrix;",
|
||||
"",
|
||||
"uniform float screenWidth;",
|
||||
"uniform float screenHeight;",
|
||||
"uniform float near;",
|
||||
"uniform float far;",
|
||||
"",
|
||||
"uniform sampler2D map;",
|
||||
"",
|
||||
"varying vec2 vUv;",
|
||||
"",
|
||||
"void main() {",
|
||||
"",
|
||||
" float dx = 1.0 / screenWidth;",
|
||||
" float dy = 1.0 / screenHeight;",
|
||||
"",
|
||||
" vec3 color = vec3(0.0, 0.0, 0.0);",
|
||||
" color += texture2D(map, vUv + vec2(-dx, -dy)).rgb;",
|
||||
" color += texture2D(map, vUv + vec2( 0, -dy)).rgb;",
|
||||
" color += texture2D(map, vUv + vec2(+dx, -dy)).rgb;",
|
||||
" color += texture2D(map, vUv + vec2(-dx, 0)).rgb;",
|
||||
" color += texture2D(map, vUv + vec2( 0, 0)).rgb;",
|
||||
" color += texture2D(map, vUv + vec2(+dx, 0)).rgb;",
|
||||
" color += texture2D(map, vUv + vec2(-dx, dy)).rgb;",
|
||||
" color += texture2D(map, vUv + vec2( 0, dy)).rgb;",
|
||||
" color += texture2D(map, vUv + vec2(+dx, dy)).rgb;",
|
||||
" ",
|
||||
" color = color / 9.0;",
|
||||
" ",
|
||||
" gl_FragColor = vec4(color, 1.0);",
|
||||
" ",
|
||||
" ",
|
||||
"}",
|
||||
].join("\n");
|
||||
|
||||
|
||||
@ -161,7 +161,8 @@ void main() {
|
||||
material: "RGB", // other options: "Height", "Intensity", "Classification"
|
||||
pointLimit: 1, // max number of points in millions
|
||||
navigation: "Orbit", // other options: "Earth", "Orbit", "Flight"
|
||||
pointSize: 2.0
|
||||
pointSize: 2.0,
|
||||
useEDL: false
|
||||
};
|
||||
</script>
|
||||
<script src="./js/viewer.js"></script>
|
||||
|
||||
@ -22,7 +22,7 @@ var clipMode = Potree.ClipMode.HIGHLIGHT_INSIDE;
|
||||
var quality = null;
|
||||
var isFlipYZ = false;
|
||||
var useDEMCollisions = false;
|
||||
var minNodeSize = 150;
|
||||
var minNodeSize = 0;
|
||||
var directionalLight;
|
||||
|
||||
var showStats = false;
|
||||
@ -127,6 +127,7 @@ function initGUI(){
|
||||
"Materials" : sceneProperties.material,
|
||||
"Clip Mode": "Highlight Inside",
|
||||
"quality": sceneProperties.quality,
|
||||
"EDL": sceneProperties.useEDL,
|
||||
"skybox": false,
|
||||
"stats": showStats,
|
||||
"BoundingBox": showBoundingBox,
|
||||
@ -135,7 +136,7 @@ function initGUI(){
|
||||
"freeze": freeze
|
||||
};
|
||||
|
||||
var pPoints = gui.add(params, 'points(m)', 0, 2);
|
||||
var pPoints = gui.add(params, 'points(m)', 0, 4);
|
||||
pPoints.onChange(function(value){
|
||||
pointCountTarget = value ;
|
||||
});
|
||||
@ -188,6 +189,7 @@ function initGUI(){
|
||||
}
|
||||
|
||||
options.push("Height");
|
||||
options.push("Color");
|
||||
options.push("Tree Depth");
|
||||
}
|
||||
|
||||
@ -216,6 +218,13 @@ function initGUI(){
|
||||
quality = value;
|
||||
});
|
||||
|
||||
if(Potree.Features.SHADER_EDL.isSupported()){
|
||||
var pEDL = fAppearance.add(params, 'EDL');
|
||||
pEDL.onChange(function(value){
|
||||
sceneProperties.useEDL = value;
|
||||
});
|
||||
}
|
||||
|
||||
var pSykbox = fAppearance.add(params, 'skybox');
|
||||
pSykbox.onChange(function(value){
|
||||
showSkybox = value;
|
||||
@ -278,7 +287,7 @@ function initThree(){
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
var near = 0.1;
|
||||
var far = 1000000;
|
||||
var far = 1000*1000;
|
||||
|
||||
scene = new THREE.Scene();
|
||||
scenePointCloud = new THREE.Scene();
|
||||
@ -358,6 +367,18 @@ function initThree(){
|
||||
useOrbitControls();
|
||||
}
|
||||
|
||||
if(sceneProperties.cameraPosition != null){
|
||||
var cp = new THREE.Vector3(sceneProperties.cameraPosition[0], sceneProperties.cameraPosition[1], sceneProperties.cameraPosition[2]);
|
||||
camera.position.copy(cp);
|
||||
}
|
||||
if(sceneProperties.cameraTarget != null){
|
||||
var cp = new THREE.Vector3(sceneProperties.cameraPosition[0], sceneProperties.cameraPosition[1], sceneProperties.cameraPosition[2]);
|
||||
var ct = new THREE.Vector3(sceneProperties.cameraTarget[0], sceneProperties.cameraTarget[1], sceneProperties.cameraTarget[2]);
|
||||
|
||||
camera.lookAt(new THREE.Vector3().addVectors(cp, ct));
|
||||
orbitControls.target.copy(ct);
|
||||
}
|
||||
|
||||
if(sceneProperties.cameraPosition){
|
||||
camera.position.set(sceneProperties.cameraPosition[0], sceneProperties.cameraPosition[1], sceneProperties.cameraPosition[2]);
|
||||
}
|
||||
@ -701,234 +722,402 @@ function useOrbitControls(){
|
||||
}
|
||||
}
|
||||
|
||||
function render(){
|
||||
// resize
|
||||
var width = elRenderArea.clientWidth;
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
|
||||
camera.aspect = aspect;
|
||||
camera.updateProjectionMatrix();
|
||||
|
||||
renderer.setSize(width, height);
|
||||
|
||||
var PotreeRenderer = function(){
|
||||
|
||||
// render skybox
|
||||
if(showSkybox){
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
}else{
|
||||
renderer.render(sceneBG, cameraBG);
|
||||
}
|
||||
|
||||
if(pointcloud){
|
||||
if(pointcloud.originalMaterial){
|
||||
pointcloud.material = pointcloud.originalMaterial;
|
||||
this.render = function(){
|
||||
{// resize
|
||||
var width = elRenderArea.clientWidth;
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
|
||||
camera.aspect = aspect;
|
||||
camera.updateProjectionMatrix();
|
||||
|
||||
renderer.setSize(width, height);
|
||||
}
|
||||
|
||||
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
|
||||
|
||||
// render skybox
|
||||
if(showSkybox){
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
}else{
|
||||
renderer.render(sceneBG, cameraBG);
|
||||
}
|
||||
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.material.opacity = opacity;
|
||||
pointcloud.material.pointColorType = pointColorType;
|
||||
pointcloud.material.pointSizeType = pointSizeType;
|
||||
pointcloud.material.pointShape = (quality === "Circles") ? Potree.PointShape.CIRCLE : Potree.PointShape.SQUARE;
|
||||
pointcloud.material.interpolate = (quality === "Interpolation");
|
||||
pointcloud.material.weighted = false;
|
||||
}
|
||||
|
||||
// render scene
|
||||
renderer.render(scene, camera);
|
||||
renderer.render(scenePointCloud, camera);
|
||||
|
||||
profileTool.render();
|
||||
volumeTool.render();
|
||||
|
||||
renderer.clearDepth();
|
||||
measuringTool.render();
|
||||
transformationTool.render();
|
||||
}
|
||||
if(pointcloud){
|
||||
if(pointcloud.originalMaterial){
|
||||
pointcloud.material = pointcloud.originalMaterial;
|
||||
}
|
||||
|
||||
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
|
||||
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.material.opacity = opacity;
|
||||
pointcloud.material.pointColorType = pointColorType;
|
||||
pointcloud.material.pointSizeType = pointSizeType;
|
||||
pointcloud.material.pointShape = (quality === "Circles") ? Potree.PointShape.CIRCLE : Potree.PointShape.SQUARE;
|
||||
pointcloud.material.interpolate = (quality === "Interpolation");
|
||||
pointcloud.material.weighted = false;
|
||||
}
|
||||
|
||||
// render scene
|
||||
renderer.render(scene, camera);
|
||||
renderer.render(scenePointCloud, camera);
|
||||
|
||||
profileTool.render();
|
||||
volumeTool.render();
|
||||
|
||||
renderer.clearDepth();
|
||||
measuringTool.render();
|
||||
transformationTool.render();
|
||||
};
|
||||
};
|
||||
var potreeRenderer = new PotreeRenderer();
|
||||
|
||||
// high quality rendering using splats
|
||||
//
|
||||
var rtDepth = new THREE.WebGLRenderTarget( 1024, 1024, {
|
||||
minFilter: THREE.NearestFilter,
|
||||
magFilter: THREE.NearestFilter,
|
||||
format: THREE.RGBAFormat,
|
||||
type: THREE.FloatType
|
||||
} );
|
||||
var rtNormalize = new THREE.WebGLRenderTarget( 1024, 1024, {
|
||||
minFilter: THREE.LinearFilter,
|
||||
magFilter: THREE.NearestFilter,
|
||||
format: THREE.RGBAFormat,
|
||||
type: THREE.FloatType
|
||||
} );
|
||||
var highQualityRenderer = null;
|
||||
var HighQualityRenderer = function(){
|
||||
|
||||
var sceneNormalize;
|
||||
var depthMaterial = null;
|
||||
var attributeMaterial = null;
|
||||
var normalizationMaterial = null;
|
||||
|
||||
var rtDepth;
|
||||
var rtNormalize;
|
||||
|
||||
var initHQSPlats = function(){
|
||||
if(depthMaterial != null){
|
||||
return;
|
||||
}
|
||||
|
||||
depthMaterial = new Potree.PointCloudMaterial();
|
||||
attributeMaterial = new Potree.PointCloudMaterial();
|
||||
|
||||
depthMaterial.pointColorType = Potree.PointColorType.DEPTH;
|
||||
depthMaterial.pointShape = Potree.PointShape.CIRCLE;
|
||||
depthMaterial.interpolate = false;
|
||||
depthMaterial.weighted = false;
|
||||
depthMaterial.minSize = 2;
|
||||
|
||||
attributeMaterial.pointShape = Potree.PointShape.CIRCLE;
|
||||
attributeMaterial.interpolate = false;
|
||||
attributeMaterial.weighted = true;
|
||||
attributeMaterial.minSize = 2;
|
||||
|
||||
var depthMaterial, weightedMaterial;
|
||||
rtDepth = new THREE.WebGLRenderTarget( 1024, 1024, {
|
||||
minFilter: THREE.NearestFilter,
|
||||
magFilter: THREE.NearestFilter,
|
||||
format: THREE.RGBAFormat,
|
||||
type: THREE.FloatType
|
||||
} );
|
||||
|
||||
// render with splats
|
||||
function renderHighQuality(){
|
||||
|
||||
if(!sceneNormalize){
|
||||
sceneNormalize = new THREE.Scene();
|
||||
|
||||
var vsNormalize = Potree.Shaders["normalize.vs"];
|
||||
var fsNormalize = Potree.Shaders["normalize.fs"];
|
||||
rtNormalize = new THREE.WebGLRenderTarget( 1024, 1024, {
|
||||
minFilter: THREE.LinearFilter,
|
||||
magFilter: THREE.NearestFilter,
|
||||
format: THREE.RGBAFormat,
|
||||
type: THREE.FloatType
|
||||
} );
|
||||
|
||||
var uniformsNormalize = {
|
||||
depthMap: { type: "t", value: rtDepth },
|
||||
texture: { type: "t", value: rtNormalize }
|
||||
};
|
||||
|
||||
var materialNormalize = new THREE.ShaderMaterial({
|
||||
normalizationMaterial = new THREE.ShaderMaterial({
|
||||
uniforms: uniformsNormalize,
|
||||
vertexShader: vsNormalize,
|
||||
fragmentShader: fsNormalize
|
||||
vertexShader: Potree.Shaders["normalize.vs"],
|
||||
fragmentShader: Potree.Shaders["normalize.fs"]
|
||||
});
|
||||
|
||||
var quad = new THREE.Mesh( new THREE.PlaneBufferGeometry(2, 2, 0), materialNormalize);
|
||||
quad.material.depthTest = true;
|
||||
quad.material.depthWrite = true;
|
||||
quad.material.transparent = true;
|
||||
sceneNormalize.add(quad);
|
||||
sceneNormalize.screenQuad = quad;
|
||||
}
|
||||
|
||||
// resize
|
||||
if(rtDepth){
|
||||
if(rtDepth.width != elRenderArea.clientWidth || rtDepth.height != elRenderArea.clientHeight){
|
||||
rtDepth.dispose();
|
||||
rtNormalize.dispose();
|
||||
|
||||
rtDepth = new THREE.WebGLRenderTarget( 1024, 1024, {
|
||||
minFilter: THREE.NearestFilter,
|
||||
magFilter: THREE.NearestFilter,
|
||||
format: THREE.RGBAFormat,
|
||||
type: THREE.FloatType
|
||||
} );
|
||||
rtNormalize = new THREE.WebGLRenderTarget( 1024, 1024, {
|
||||
minFilter: THREE.LinearFilter,
|
||||
magFilter: THREE.NearestFilter,
|
||||
format: THREE.RGBAFormat,
|
||||
type: THREE.FloatType
|
||||
} );
|
||||
|
||||
sceneNormalize.screenQuad.material.uniforms.depthMap.value = rtDepth;
|
||||
sceneNormalize.screenQuad.material.uniforms.texture.value = rtNormalize;
|
||||
var resize = function(width, height){
|
||||
if(rtDepth.width == width && rtDepth.height == height){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var width = elRenderArea.clientWidth;
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
|
||||
camera.aspect = aspect;
|
||||
camera.updateProjectionMatrix();
|
||||
|
||||
renderer.setSize(width, height);
|
||||
rtDepth.setSize(width, height);
|
||||
rtNormalize.setSize(width, height);
|
||||
|
||||
renderer.clear();
|
||||
//renderer.render(sceneBG, cameraBG);
|
||||
// render skybox
|
||||
if(showSkybox){
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
}else{
|
||||
renderer.render(sceneBG, cameraBG);
|
||||
}
|
||||
renderer.render(scene, camera);
|
||||
|
||||
if(pointcloud){
|
||||
|
||||
if(typeof pointcloud._hqsplats === "undefined"){
|
||||
var hq = {
|
||||
originalMaterial: pointcloud.material,
|
||||
depthMaterial: new Potree.PointCloudMaterial(),
|
||||
attributeMaterial: new Potree.PointCloudMaterial()
|
||||
rtDepth.dispose();
|
||||
rtNormalize.dispose();
|
||||
|
||||
camera.aspect = width / height;
|
||||
camera.updateProjectionMatrix();
|
||||
|
||||
renderer.setSize(width, height);
|
||||
rtDepth.setSize(width, height);
|
||||
rtNormalize.setSize(width, height);
|
||||
};
|
||||
|
||||
// render with splats
|
||||
this.render = function(renderer){
|
||||
|
||||
var width = elRenderArea.clientWidth;
|
||||
var height = elRenderArea.clientHeight;
|
||||
|
||||
initHQSPlats();
|
||||
|
||||
resize(width, height);
|
||||
|
||||
|
||||
renderer.clear();
|
||||
if(showSkybox){
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
}else{
|
||||
renderer.render(sceneBG, cameraBG);
|
||||
}
|
||||
renderer.render(scene, camera);
|
||||
|
||||
if(pointcloud){
|
||||
|
||||
depthMaterial.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
|
||||
attributeMaterial.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
|
||||
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
var originalMaterial = pointcloud.material;
|
||||
|
||||
var vn = [];
|
||||
for(var i = 0; i < pointcloud.visibleNodes.length; i++){
|
||||
vn.push(pointcloud.visibleNodes[i].node);
|
||||
}
|
||||
|
||||
hq.depthMaterial.pointColorType = Potree.PointColorType.DEPTH;
|
||||
hq.depthMaterial.pointShape = Potree.PointShape.CIRCLE;
|
||||
hq.depthMaterial.interpolate = false;
|
||||
hq.depthMaterial.weighted = false;
|
||||
hq.depthMaterial.minSize = 2;
|
||||
hq.depthMaterial.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
|
||||
{// DEPTH PASS
|
||||
depthMaterial.size = pointSize;
|
||||
depthMaterial.pointSizeType = pointSizeType;
|
||||
depthMaterial.screenWidth = width;
|
||||
depthMaterial.screenHeight = height;
|
||||
depthMaterial.uniforms.visibleNodes.value = pointcloud.material.visibleNodesTexture;
|
||||
depthMaterial.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
|
||||
depthMaterial.fov = camera.fov * (Math.PI / 180);
|
||||
depthMaterial.spacing = pointcloud.pcoGeometry.spacing;
|
||||
depthMaterial.near = camera.near;
|
||||
depthMaterial.far = camera.far;
|
||||
depthMaterial.heightMin = heightMin;
|
||||
depthMaterial.heightMax = heightMax;
|
||||
pointcloud.updateVisibilityTexture(depthMaterial, vn);
|
||||
|
||||
scenePointCloud.overrideMaterial = depthMaterial;
|
||||
renderer.clearTarget( rtDepth, true, true, true );
|
||||
renderer.render(scenePointCloud, camera, rtDepth);
|
||||
scenePointCloud.overrideMaterial = null;
|
||||
}
|
||||
|
||||
hq.attributeMaterial.pointShape = Potree.PointShape.CIRCLE;
|
||||
hq.attributeMaterial.interpolate = false;
|
||||
hq.attributeMaterial.weighted = true;
|
||||
hq.attributeMaterial.minSize = 2;
|
||||
hq.attributeMaterial.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
|
||||
{// ATTRIBUTE PASS
|
||||
attributeMaterial.size = pointSize;
|
||||
attributeMaterial.pointSizeType = pointSizeType;
|
||||
attributeMaterial.screenWidth = width;
|
||||
attributeMaterial.screenHeight = height;
|
||||
attributeMaterial.pointColorType = pointColorType;
|
||||
attributeMaterial.depthMap = rtDepth;
|
||||
attributeMaterial.uniforms.visibleNodes.value = pointcloud.material.visibleNodesTexture;
|
||||
attributeMaterial.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
|
||||
attributeMaterial.fov = camera.fov * (Math.PI / 180);
|
||||
attributeMaterial.spacing = pointcloud.pcoGeometry.spacing;
|
||||
attributeMaterial.near = camera.near;
|
||||
attributeMaterial.far = camera.far;
|
||||
attributeMaterial.heightMin = heightMin;
|
||||
attributeMaterial.heightMax = heightMax;
|
||||
attributeMaterial.intensityMin = pointcloud.material.intensityMin;
|
||||
attributeMaterial.intensityMax = pointcloud.material.intensityMax;
|
||||
pointcloud.updateVisibilityTexture(depthMaterial, vn);
|
||||
|
||||
scenePointCloud.overrideMaterial = attributeMaterial;
|
||||
renderer.clearTarget( rtNormalize, true, true, true );
|
||||
renderer.render(scenePointCloud, camera, rtNormalize);
|
||||
scenePointCloud.overrideMaterial = null;
|
||||
}
|
||||
|
||||
pointcloud._hqsplats = hq;
|
||||
{// NORMALIZATION PASS
|
||||
normalizationMaterial.uniforms.depthMap.value = rtDepth;
|
||||
normalizationMaterial.uniforms.texture.value = rtNormalize;
|
||||
Potree.utils.screenPass.render(renderer, normalizationMaterial);
|
||||
}
|
||||
|
||||
pointcloud.material = originalMaterial;
|
||||
|
||||
volumeTool.render();
|
||||
renderer.clearDepth();
|
||||
profileTool.render();
|
||||
measuringTool.render();
|
||||
transformationTool.render();
|
||||
}
|
||||
|
||||
{// DEPTH PASS
|
||||
var material = pointcloud._hqsplats.depthMaterial;
|
||||
|
||||
material.size = pointSize;
|
||||
material.pointSizeType = pointSizeType;
|
||||
material.screenWidth = width;
|
||||
material.screenHeight = height;
|
||||
material.uniforms.visibleNodes.value = pointcloud.material.visibleNodesTexture;
|
||||
material.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
|
||||
material.fov = camera.fov * (Math.PI / 180);
|
||||
material.spacing = pointcloud.pcoGeometry.spacing;
|
||||
material.near = camera.near;
|
||||
material.far = camera.far;
|
||||
|
||||
pointcloud.material = material;
|
||||
|
||||
pointcloud.update(camera, renderer);
|
||||
|
||||
renderer.clearTarget( rtDepth, true, true, true );
|
||||
renderer.clearTarget( rtNormalize, true, true, true );
|
||||
renderer.render(scenePointCloud, camera, rtDepth);
|
||||
}
|
||||
|
||||
|
||||
{// ATTRIBUTE PASS
|
||||
var material = pointcloud._hqsplats.attributeMaterial;
|
||||
|
||||
material.size = pointSize;
|
||||
material.pointSizeType = pointSizeType;
|
||||
material.screenWidth = width;
|
||||
material.screenHeight = height;
|
||||
material.pointColorType = pointColorType;
|
||||
material.depthMap = rtDepth;
|
||||
material.uniforms.visibleNodes.value = pointcloud.material.visibleNodesTexture;
|
||||
material.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
|
||||
material.fov = camera.fov * (Math.PI / 180);
|
||||
material.spacing = pointcloud.pcoGeometry.spacing;
|
||||
material.near = camera.near;
|
||||
material.far = camera.far;
|
||||
|
||||
pointcloud.material = material;
|
||||
|
||||
pointcloud.update(camera, renderer);
|
||||
renderer.render(scenePointCloud, camera, rtNormalize);
|
||||
}
|
||||
|
||||
// NORMALIZATION PASS
|
||||
renderer.render(sceneNormalize, cameraBG);
|
||||
|
||||
pointcloud.material = pointcloud._hqsplats.originalMaterial;
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
var edlRenderer = null;
|
||||
var EDLRenderer = function(){
|
||||
|
||||
var edlMaterial = null;
|
||||
var attributeMaterial = null;
|
||||
|
||||
volumeTool.render();
|
||||
renderer.clearDepth();
|
||||
profileTool.render();
|
||||
measuringTool.render();
|
||||
transformationTool.render();
|
||||
|
||||
//var depthTexture = null;
|
||||
|
||||
var rtColor = null;
|
||||
var gl = renderer.context;
|
||||
|
||||
var initEDL = function(){
|
||||
if(edlMaterial != null){
|
||||
return;
|
||||
}
|
||||
|
||||
//var depthTextureExt = gl.getExtension("WEBGL_depth_texture");
|
||||
|
||||
edlMaterial = new Potree.EyeDomeLightingMaterial();
|
||||
attributeMaterial = new Potree.PointCloudMaterial();
|
||||
|
||||
attributeMaterial.pointShape = Potree.PointShape.CIRCLE;
|
||||
attributeMaterial.interpolate = false;
|
||||
attributeMaterial.weighted = false;
|
||||
attributeMaterial.minSize = 2;
|
||||
attributeMaterial.useLogarithmicDepthBuffer = false;
|
||||
attributeMaterial.useEDL = true;
|
||||
|
||||
rtColor = new THREE.WebGLRenderTarget( 1024, 1024, {
|
||||
minFilter: THREE.LinearFilter,
|
||||
magFilter: THREE.NearestFilter,
|
||||
format: THREE.RGBAFormat,
|
||||
type: THREE.FloatType,
|
||||
//type: THREE.UnsignedByteType,
|
||||
//depthBuffer: false,
|
||||
//stencilBuffer: false
|
||||
} );
|
||||
|
||||
//depthTexture = new THREE.Texture();
|
||||
//depthTexture.__webglInit = true;
|
||||
//depthTexture.__webglTexture = gl.createTexture();;
|
||||
//gl.bindTexture(gl.TEXTURE_2D, depthTexture.__webglTexture);
|
||||
//gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
||||
//gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
||||
//gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
||||
//gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
||||
//gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, 1024, 1024, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_SHORT, null);
|
||||
};
|
||||
|
||||
var resize = function(){
|
||||
var width = elRenderArea.clientWidth;
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
|
||||
var needsResize = (rtColor.width != width || rtColor.height != height);
|
||||
|
||||
// disposal will be unnecessary once this fix made it into three.js master:
|
||||
// https://github.com/mrdoob/three.js/pull/6355
|
||||
if(needsResize){
|
||||
rtColor.dispose();
|
||||
}
|
||||
|
||||
camera.aspect = aspect;
|
||||
camera.updateProjectionMatrix();
|
||||
|
||||
renderer.setSize(width, height);
|
||||
rtColor.setSize(width, height);
|
||||
|
||||
//if(needsResize){
|
||||
// renderer.setRenderTarget(rtColor);
|
||||
// var framebuffer = rtColor.__webglFramebuffer;
|
||||
// gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
|
||||
//
|
||||
//
|
||||
// gl.bindRenderbuffer( gl.RENDERBUFFER, rtColor.__webglRenderbuffer );
|
||||
// gl.renderbufferStorage( gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, rtColor.width, rtColor.height );
|
||||
// gl.framebufferRenderbuffer( gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, null );
|
||||
//
|
||||
// gl.bindTexture(gl.TEXTURE_2D, depthTexture.__webglTexture);
|
||||
// gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
||||
// gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
||||
// gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
||||
// gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
||||
// gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, width, height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
|
||||
//
|
||||
// gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture.__webglTexture, 0);
|
||||
//
|
||||
// renderer.setRenderTarget(null);
|
||||
//}
|
||||
}
|
||||
|
||||
this.render = function(){
|
||||
|
||||
initEDL();
|
||||
|
||||
resize();
|
||||
|
||||
renderer.clear();
|
||||
if(showSkybox){
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
}else{
|
||||
renderer.render(sceneBG, cameraBG);
|
||||
}
|
||||
renderer.render(scene, camera);
|
||||
|
||||
if(pointcloud){
|
||||
var width = elRenderArea.clientWidth;
|
||||
var height = elRenderArea.clientHeight;
|
||||
|
||||
var octreeSize = pointcloud.pcoGeometry.boundingBox.size().x;
|
||||
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
var originalMaterial = pointcloud.material;
|
||||
|
||||
var vn = [];
|
||||
for(var i = 0; i < pointcloud.visibleNodes.length; i++){
|
||||
vn.push(pointcloud.visibleNodes[i].node);
|
||||
}
|
||||
|
||||
{// COLOR & DEPTH PASS
|
||||
attributeMaterial.size = pointSize;
|
||||
attributeMaterial.pointSizeType = pointSizeType;
|
||||
attributeMaterial.screenWidth = width;
|
||||
attributeMaterial.screenHeight = height;
|
||||
attributeMaterial.pointColorType = pointColorType;
|
||||
attributeMaterial.uniforms.octreeSize.value = octreeSize;
|
||||
attributeMaterial.fov = camera.fov * (Math.PI / 180);
|
||||
attributeMaterial.spacing = pointcloud.pcoGeometry.spacing;
|
||||
attributeMaterial.near = camera.near;
|
||||
attributeMaterial.far = camera.far;
|
||||
attributeMaterial.heightMin = heightMin;
|
||||
attributeMaterial.heightMax = heightMax;
|
||||
attributeMaterial.intensityMin = pointcloud.material.intensityMin;
|
||||
attributeMaterial.intensityMax = pointcloud.material.intensityMax;
|
||||
attributeMaterial.setClipBoxes(pointcloud.material.clipBoxes);
|
||||
attributeMaterial.clipMode = pointcloud.material.clipMode;
|
||||
pointcloud.updateVisibilityTexture(attributeMaterial, vn);
|
||||
|
||||
scenePointCloud.overrideMaterial = attributeMaterial;
|
||||
renderer.clearTarget( rtColor, true, true, true );
|
||||
renderer.render(scenePointCloud, camera, rtColor);
|
||||
scenePointCloud.overrideMaterial = null;
|
||||
}
|
||||
|
||||
{ // EDL OCCLUSION PASS
|
||||
edlMaterial.uniforms.screenWidth.value = width;
|
||||
edlMaterial.uniforms.screenHeight.value = height;
|
||||
edlMaterial.uniforms.near.value = camera.near;
|
||||
edlMaterial.uniforms.far.value = camera.far;
|
||||
edlMaterial.uniforms.colorMap.value = rtColor;
|
||||
edlMaterial.uniforms.expScale.value = camera.far;
|
||||
|
||||
//edlMaterial.uniforms.depthMap.value = depthTexture;
|
||||
|
||||
Potree.utils.screenPass.render(renderer, edlMaterial);
|
||||
}
|
||||
|
||||
renderer.render(scene, camera);
|
||||
|
||||
profileTool.render();
|
||||
volumeTool.render();
|
||||
renderer.clearDepth();
|
||||
measuringTool.render();
|
||||
transformationTool.render();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -937,12 +1126,19 @@ function loop() {
|
||||
|
||||
update();
|
||||
|
||||
if(quality === "Splats"){
|
||||
renderHighQuality();
|
||||
if(sceneProperties.useEDL){
|
||||
if(!edlRenderer){
|
||||
edlRenderer = new EDLRenderer();
|
||||
}
|
||||
edlRenderer.render(renderer);
|
||||
}else if(quality === "Splats"){
|
||||
if(!highQualityRenderer){
|
||||
highQualityRenderer = new HighQualityRenderer();
|
||||
}
|
||||
highQualityRenderer.render(renderer);
|
||||
}else{
|
||||
render();
|
||||
potreeRenderer.render();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
<script src="../src/loader/POCLoader.js"></script>
|
||||
<script src="../src/loader/BinaryLoader.js"></script>
|
||||
<script src="../src/materials/PointCloudMaterial.js"></script>
|
||||
<script src="../src/materials/EyeDomeLightingMaterial.js"></script>
|
||||
<script src="../src/EarthControls.js"></script>
|
||||
<script src="../src/OrbitControls.js"></script>
|
||||
<script src="../src/FirstPersonControls.js"></script>
|
||||
@ -73,17 +74,19 @@
|
||||
<div id="renderArea"></div>
|
||||
|
||||
<script>
|
||||
|
||||
var sceneProperties = {
|
||||
path: "../resources/pointclouds/lion_takanawa/cloud.js",
|
||||
cameraPosition: [3.6, 4.367, 4],// other options: cameraPosition: [10,10,10],
|
||||
cameraTarget: null, // other options: cameraTarget: [0,0,0],
|
||||
sizeType: "Adaptive", // other options: "Fixed", "Attenuated"
|
||||
quality: null, // other options: "Circles", "Interpolation", "Splats"
|
||||
fov: 75, // other options: "Circles", "Interpolation", "Splats"
|
||||
material: "RGB", // other options: "Height", "Intensity", "Classification"
|
||||
pointLimit: 1, // max number of points in millions
|
||||
navigation: "Orbit", // other options: "Earth", "Orbit", "Flight"
|
||||
pointSize: 1.0
|
||||
path: "../resources/pointclouds/lion_takanawa/cloud.js",
|
||||
cameraPosition: null,
|
||||
cameraTarget: null,
|
||||
sizeType: "Adaptive", // options: "Fixed", "Attenuated", "Adaptive"
|
||||
quality: "Interpolation", // options: "Squares", "Circles", "Interpolation", "Splats"
|
||||
fov: 75, // field of view in degree
|
||||
material: "RGB", // options: "RGB", "Height", "Intensity", "Classification"
|
||||
pointLimit: 1, // max number of points in millions
|
||||
navigation: "Orbit", // options: "Earth", "Orbit", "Flight"
|
||||
pointSize: 1.2,
|
||||
useEDL: false, // eye-dome-lighting, especially usefull for point clouds without normals
|
||||
};
|
||||
</script>
|
||||
<script src="./js/viewer.js"></script>
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
<script src="../src/loader/POCLoader.js"></script>
|
||||
<script src="../src/loader/BinaryLoader.js"></script>
|
||||
<script src="../src/materials/PointCloudMaterial.js"></script>
|
||||
<script src="../src/materials/EyeDomeLightingMaterial.js"></script>
|
||||
<script src="../src/EarthControls.js"></script>
|
||||
<script src="../src/OrbitControls.js"></script>
|
||||
<script src="../src/FirstPersonControls.js"></script>
|
||||
@ -73,17 +74,19 @@
|
||||
<div id="renderArea"></div>
|
||||
|
||||
<script>
|
||||
|
||||
var sceneProperties = {
|
||||
path: "../resources/pointclouds/lion_takanawa_las/cloud.js",
|
||||
cameraPosition: [3.6, 4.367, 4],// other options: cameraPosition: [10,10,10],
|
||||
cameraTarget: null, // other options: cameraTarget: [0,0,0],
|
||||
sizeType: "Adaptive", // other options: "Fixed", "Attenuated"
|
||||
quality: null, // other options: "Circles", "Interpolation", "Splats"
|
||||
fov: 75, // other options: "Circles", "Interpolation", "Splats"
|
||||
material: "RGB", // other options: "Height", "Intensity", "Classification"
|
||||
pointLimit: 1, // max number of points in millions
|
||||
navigation: "Orbit", // other options: "Earth", "Orbit", "Flight"
|
||||
pointSize: 1.0
|
||||
path: "../resources/pointclouds/lion_takanawa_las/cloud.js",
|
||||
cameraPosition: null,
|
||||
cameraTarget: null,
|
||||
sizeType: "Adaptive", // options: "Fixed", "Attenuated", "Adaptive"
|
||||
quality: "Interpolation", // options: "Squares", "Circles", "Interpolation", "Splats"
|
||||
fov: 75, // field of view in degree
|
||||
material: "RGB", // options: "RGB", "Height", "Intensity", "Classification"
|
||||
pointLimit: 1, // max number of points in millions
|
||||
navigation: "Orbit", // options: "Earth", "Orbit", "Flight"
|
||||
pointSize: 1.2,
|
||||
useEDL: false, // eye-dome-lighting, especially usefull for point clouds without normals
|
||||
};
|
||||
</script>
|
||||
<script src="./js/viewer.js"></script>
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
<script src="../src/loader/POCLoader.js"></script>
|
||||
<script src="../src/loader/BinaryLoader.js"></script>
|
||||
<script src="../src/materials/PointCloudMaterial.js"></script>
|
||||
<script src="../src/materials/EyeDomeLightingMaterial.js"></script>
|
||||
<script src="../src/EarthControls.js"></script>
|
||||
<script src="../src/OrbitControls.js"></script>
|
||||
<script src="../src/FirstPersonControls.js"></script>
|
||||
@ -73,17 +74,19 @@
|
||||
<div id="renderArea"></div>
|
||||
|
||||
<script>
|
||||
|
||||
var sceneProperties = {
|
||||
path: "../resources/pointclouds/lion_takanawa_laz/cloud.js",
|
||||
cameraPosition: [3.6, 4.367, 4],// other options: cameraPosition: [10,10,10],
|
||||
cameraTarget: null, // other options: cameraTarget: [0,0,0],
|
||||
sizeType: "Adaptive", // other options: "Fixed", "Attenuated"
|
||||
quality: null, // other options: "Circles", "Interpolation", "Splats"
|
||||
fov: 75, // other options: "Circles", "Interpolation", "Splats"
|
||||
material: "RGB", // other options: "Height", "Intensity", "Classification"
|
||||
pointLimit: 1, // max number of points in millions
|
||||
navigation: "Orbit", // other options: "Earth", "Orbit", "Flight"
|
||||
pointSize: 1.0
|
||||
path: "../resources/pointclouds/lion_takanawa_laz/cloud.js",
|
||||
cameraPosition: null,
|
||||
cameraTarget: null,
|
||||
sizeType: "Adaptive", // options: "Fixed", "Attenuated", "Adaptive"
|
||||
quality: "Interpolation", // options: "Squares", "Circles", "Interpolation", "Splats"
|
||||
fov: 75, // field of view in degree
|
||||
material: "RGB", // options: "RGB", "Height", "Intensity", "Classification"
|
||||
pointLimit: 1, // max number of points in millions
|
||||
navigation: "Orbit", // options: "Earth", "Orbit", "Flight"
|
||||
pointSize: 1.2,
|
||||
useEDL: false, // eye-dome-lighting, especially usefull for point clouds without normals
|
||||
};
|
||||
</script>
|
||||
<script src="./js/viewer.js"></script>
|
||||
|
||||
@ -15,12 +15,13 @@
|
||||
|
||||
|
||||
<!-- uncomment this to debug changes to the individual js files -->
|
||||
<!--
|
||||
|
||||
<script src="../src/PointCloudOctree.js"></script>
|
||||
<script src="../src/PointCloudOctreeGeometry.js"></script>
|
||||
<script src="../src/loader/POCLoader.js"></script>
|
||||
<script src="../src/loader/BinaryLoader.js"></script>
|
||||
<script src="../src/materials/PointCloudMaterial.js"></script>
|
||||
<script src="../src/materials/EyeDomeLightingMaterial.js"></script>
|
||||
<script src="../src/EarthControls.js"></script>
|
||||
<script src="../src/OrbitControls.js"></script>
|
||||
<script src="../src/FirstPersonControls.js"></script>
|
||||
@ -34,7 +35,7 @@
|
||||
<script src="../src/Features.js"></script>
|
||||
<script src="../src/arena4d/PointCloudArena4D.js"></script>
|
||||
<script src="../src/arena4d/PointCloudArena4DGeometry.js"></script>
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
@ -74,17 +75,19 @@
|
||||
<div id="renderArea"></div>
|
||||
|
||||
<script>
|
||||
|
||||
var sceneProperties = {
|
||||
path: "../resources/pointclouds/vol_total/cloud.js",
|
||||
cameraPosition: null, // options: cameraPosition: [10,10,10],
|
||||
cameraTarget: null, // options: cameraTarget: [0,0,0],
|
||||
cameraPosition: null,
|
||||
cameraTarget: null,
|
||||
sizeType: "Adaptive", // options: "Fixed", "Attenuated", "Adaptive"
|
||||
quality: null, // options: "Squares", "Circles", "Interpolation", "Splats"
|
||||
quality: "Interpolation", // options: "Squares", "Circles", "Interpolation", "Splats"
|
||||
fov: 75, // field of view in degree
|
||||
material: "RGB", // options: "RGB", "Height", "Intensity", "Classification"
|
||||
pointLimit: 1, // max number of points in millions
|
||||
navigation: "Orbit", // options: "Earth", "Orbit", "Flight"
|
||||
pointSize: 1.0
|
||||
pointSize: 1,
|
||||
useEDL: false, // eye-dome-lighting, especially usefull for point clouds without normals
|
||||
};
|
||||
</script>
|
||||
<script src="./js/viewer.js"></script>
|
||||
|
||||
@ -25,6 +25,8 @@ var paths = {
|
||||
"src/loader/BinaryLoader.js",
|
||||
"src/loader/LasLazLoader.js",
|
||||
"src/materials/PointCloudMaterial.js",
|
||||
"src/materials/EyeDomeLightingMaterial.js",
|
||||
"src/materials/BlurMaterial.js",
|
||||
"src/FirstPersonControls.js",
|
||||
"src/OrbitControls.js",
|
||||
"src/EarthControls.js",
|
||||
@ -67,7 +69,11 @@ var shaders = [
|
||||
"src/materials/shaders/pointcloud.vs",
|
||||
"src/materials/shaders/pointcloud.fs",
|
||||
"src/materials/shaders/normalize.vs",
|
||||
"src/materials/shaders/normalize.fs"
|
||||
"src/materials/shaders/normalize.fs",
|
||||
"src/materials/shaders/edl.vs",
|
||||
"src/materials/shaders/edl.fs",
|
||||
"src/materials/shaders/blur.vs",
|
||||
"src/materials/shaders/blur.fs"
|
||||
];
|
||||
|
||||
|
||||
|
||||
@ -71,6 +71,20 @@ Potree.Features = function(){
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
SHADER_EDL: {
|
||||
isSupported: function(){
|
||||
|
||||
var supported = true;
|
||||
|
||||
supported = supported && gl.getExtension("EXT_frag_depth");
|
||||
supported = supported && gl.getExtension("OES_texture_float");
|
||||
supported = supported && gl.getParameter(gl.MAX_VARYING_VECTORS) >= 8;
|
||||
|
||||
return supported;
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
precision: precision
|
||||
}
|
||||
|
||||
37
src/materials/BlurMaterial.js
Normal file
37
src/materials/BlurMaterial.js
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
// see http://john-chapman-graphics.blogspot.co.at/2013/01/ssao-tutorial.html
|
||||
|
||||
|
||||
|
||||
Potree.BlurMaterial = function(parameters){
|
||||
THREE.Material.call( this );
|
||||
|
||||
parameters = parameters || {};
|
||||
|
||||
var uniforms = {
|
||||
near: { type: "f", value: 0 },
|
||||
far: { type: "f", value: 0 },
|
||||
screenWidth: { type: "f", value: 0 },
|
||||
screenHeight: { type: "f", value: 0 },
|
||||
map: { type: "t", value: null }
|
||||
};
|
||||
|
||||
this.setValues({
|
||||
uniforms: uniforms,
|
||||
vertexShader: Potree.Shaders["blur.vs"],
|
||||
fragmentShader: Potree.Shaders["blur.fs"],
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
Potree.BlurMaterial.prototype = new THREE.ShaderMaterial();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
73
src/materials/EyeDomeLightingMaterial.js
Normal file
73
src/materials/EyeDomeLightingMaterial.js
Normal file
@ -0,0 +1,73 @@
|
||||
|
||||
//
|
||||
// Algorithm by Christian Boucheny
|
||||
// shader code taken and adapted from CloudCompare
|
||||
//
|
||||
// see
|
||||
// https://github.com/cloudcompare/trunk/tree/master/plugins/qEDL/shaders/EDL
|
||||
// http://www.kitware.com/source/home/post/9
|
||||
// https://tel.archives-ouvertes.fr/tel-00438464/document p. 115+ (french)
|
||||
|
||||
|
||||
|
||||
|
||||
Potree.EyeDomeLightingMaterial = function(parameters){
|
||||
THREE.Material.call( this );
|
||||
|
||||
parameters = parameters || {};
|
||||
|
||||
var neighbourCount = 8;
|
||||
var neighbours = new Float32Array(neighbourCount*2);
|
||||
for(var c = 0; c < neighbourCount; c++){
|
||||
neighbours[2*c+0] = Math.cos(2 * c * Math.PI / neighbourCount);
|
||||
neighbours[2*c+1] = Math.sin(2 * c * Math.PI / neighbourCount);
|
||||
}
|
||||
|
||||
//var neighbourCount = 32;
|
||||
//var neighbours = new Float32Array(neighbourCount*2);
|
||||
//for(var c = 0; c < neighbourCount; c++){
|
||||
// var r = (c / neighbourCount) * 4 + 0.1;
|
||||
// neighbours[2*c+0] = Math.cos(2 * c * Math.PI / neighbourCount) * r;
|
||||
// neighbours[2*c+1] = Math.sin(2 * c * Math.PI / neighbourCount) * r;
|
||||
//}
|
||||
|
||||
var lightDir = new THREE.Vector3(0.0, 0.0, 1.0).normalize();
|
||||
|
||||
var uniforms = {
|
||||
screenWidth: { type: "f", value: 0 },
|
||||
screenHeight: { type: "f", value: 0 },
|
||||
near: { type: "f", value: 0 },
|
||||
far: { type: "f", value: 0 },
|
||||
pixScale: { type: "f", value: 1.0 },
|
||||
expScale: { type: "f", value: 100.0 },
|
||||
zoom: { type: "f", value: 3.0 },
|
||||
lightDir: { type: "v3", value: lightDir },
|
||||
neighbours: { type: "2fv", value: neighbours },
|
||||
depthMap: { type: "t", value: null },
|
||||
colorMap: { type: "t", value: null }
|
||||
};
|
||||
|
||||
this.setValues({
|
||||
uniforms: uniforms,
|
||||
vertexShader: Potree.Shaders["edl.vs"],
|
||||
fragmentShader: Potree.Shaders["edl.fs"],
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
Potree.EyeDomeLightingMaterial.prototype = new THREE.ShaderMaterial();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -42,6 +42,7 @@ Potree.Classification = {
|
||||
};
|
||||
|
||||
|
||||
|
||||
Potree.PointSizeType = {
|
||||
FIXED: 0,
|
||||
ATTENUATED: 1,
|
||||
@ -86,7 +87,7 @@ Potree.PointCloudMaterial = function(parameters){
|
||||
|
||||
parameters = parameters || {};
|
||||
|
||||
var color = new THREE.Color( 0x000000 );
|
||||
var color = new THREE.Color( 0xffffff );
|
||||
var map = THREE.ImageUtils.generateDataTexture( 2048, 1, color );
|
||||
map.magFilter = THREE.NearestFilter;
|
||||
this.visibleNodesTexture = map;
|
||||
@ -112,6 +113,8 @@ Potree.PointCloudMaterial = function(parameters){
|
||||
this.classificationTexture = Potree.PointCloudMaterial.generateClassificationTexture(this._classification);
|
||||
this.lights = true;
|
||||
this._treeType = treeType;
|
||||
this._useLogarithmicDepthBuffer = false;
|
||||
this._useEDL = false;
|
||||
|
||||
|
||||
|
||||
@ -124,7 +127,7 @@ Potree.PointCloudMaterial = function(parameters){
|
||||
screenHeight: { type: "f", value: 1.0 },
|
||||
near: { type: "f", value: 0.1 },
|
||||
far: { type: "f", value: 1.0 },
|
||||
uColor: { type: "c", value: new THREE.Color( 0xff0000 ) },
|
||||
uColor: { type: "c", value: new THREE.Color( 0xffffff ) },
|
||||
opacity: { type: "f", value: 1.0 },
|
||||
size: { type: "f", value: 10 },
|
||||
minSize: { type: "f", value: 2 },
|
||||
@ -265,6 +268,14 @@ Potree.PointCloudMaterial.prototype.getDefines = function(){
|
||||
defines += "#define use_interpolation\n";
|
||||
}
|
||||
|
||||
if(this._useLogarithmicDepthBuffer){
|
||||
defines += "#define use_logarithmic_depth_buffer\n";
|
||||
}
|
||||
|
||||
if(this._useEDL){
|
||||
defines += "#define use_edl\n";
|
||||
}
|
||||
|
||||
if(this._pointColorType === Potree.PointColorType.RGB){
|
||||
defines += "#define color_type_rgb\n";
|
||||
}else if(this._pointColorType === Potree.PointColorType.COLOR){
|
||||
@ -537,6 +548,30 @@ Object.defineProperty(Potree.PointCloudMaterial.prototype, "interpolate", {
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(Potree.PointCloudMaterial.prototype, "useEDL", {
|
||||
get: function(){
|
||||
return this._useEDL;
|
||||
},
|
||||
set: function(value){
|
||||
if(this._useEDL !== value){
|
||||
this._useEDL = value;
|
||||
this.updateShaderSource();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(Potree.PointCloudMaterial.prototype, "useLogarithmicDepthBuffer", {
|
||||
get: function(){
|
||||
return this._useLogarithmicDepthBuffer;
|
||||
},
|
||||
set: function(value){
|
||||
if(this._useLogarithmicDepthBuffer !== value){
|
||||
this._useLogarithmicDepthBuffer = value;
|
||||
this.updateShaderSource();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(Potree.PointCloudMaterial.prototype, "color", {
|
||||
get: function(){
|
||||
return this.uniforms.uColor.value;
|
||||
|
||||
34
src/materials/shaders/blur.fs
Normal file
34
src/materials/shaders/blur.fs
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
uniform mat4 projectionMatrix;
|
||||
|
||||
uniform float screenWidth;
|
||||
uniform float screenHeight;
|
||||
uniform float near;
|
||||
uniform float far;
|
||||
|
||||
uniform sampler2D map;
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
|
||||
float dx = 1.0 / screenWidth;
|
||||
float dy = 1.0 / screenHeight;
|
||||
|
||||
vec3 color = vec3(0.0, 0.0, 0.0);
|
||||
color += texture2D(map, vUv + vec2(-dx, -dy)).rgb;
|
||||
color += texture2D(map, vUv + vec2( 0, -dy)).rgb;
|
||||
color += texture2D(map, vUv + vec2(+dx, -dy)).rgb;
|
||||
color += texture2D(map, vUv + vec2(-dx, 0)).rgb;
|
||||
color += texture2D(map, vUv + vec2( 0, 0)).rgb;
|
||||
color += texture2D(map, vUv + vec2(+dx, 0)).rgb;
|
||||
color += texture2D(map, vUv + vec2(-dx, dy)).rgb;
|
||||
color += texture2D(map, vUv + vec2( 0, dy)).rgb;
|
||||
color += texture2D(map, vUv + vec2(+dx, dy)).rgb;
|
||||
|
||||
color = color / 9.0;
|
||||
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
|
||||
|
||||
}
|
||||
8
src/materials/shaders/blur.vs
Normal file
8
src/materials/shaders/blur.vs
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
vUv = uv;
|
||||
|
||||
gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);
|
||||
}
|
||||
86
src/materials/shaders/edl.fs
Normal file
86
src/materials/shaders/edl.fs
Normal file
@ -0,0 +1,86 @@
|
||||
|
||||
//
|
||||
// adapted from the EDL shader code from Christian Boucheny in cloud compare:
|
||||
// https://github.com/cloudcompare/trunk/tree/master/plugins/qEDL/shaders/EDL
|
||||
//
|
||||
|
||||
#define NEIGHBOUR_COUNT 8
|
||||
|
||||
uniform mat4 projectionMatrix;
|
||||
|
||||
uniform float screenWidth;
|
||||
uniform float screenHeight;
|
||||
uniform float near;
|
||||
uniform float far;
|
||||
uniform vec2 neighbours[NEIGHBOUR_COUNT];
|
||||
uniform vec3 lightDir;
|
||||
uniform float zoom;
|
||||
uniform float pixScale;
|
||||
uniform float expScale;
|
||||
|
||||
//uniform sampler2D depthMap;
|
||||
uniform sampler2D colorMap;
|
||||
|
||||
varying vec2 vUv;
|
||||
varying vec3 vViewRay;
|
||||
|
||||
/**
|
||||
* transform linear depth to [0,1] interval with 1 beeing closest to the camera.
|
||||
*/
|
||||
float ztransform(float linearDepth){
|
||||
return 1.0 - (linearDepth - near) / (far - near);
|
||||
}
|
||||
|
||||
float expToLinear(float z){
|
||||
z = 2.0 * z - 1.0;
|
||||
float linear = (2.0 * near * far) / (far + near - z * (far - near));
|
||||
|
||||
return linear;
|
||||
}
|
||||
|
||||
// this actually only returns linear depth values if LOG_BIAS is 1.0
|
||||
// lower values work out more nicely, though.
|
||||
#define LOG_BIAS 0.01
|
||||
float logToLinear(float z){
|
||||
return (pow((1.0 + LOG_BIAS * far), z) - 1.0) / LOG_BIAS;
|
||||
}
|
||||
|
||||
float obscurance(float z, float dist){
|
||||
return max(0.0, z) / dist;
|
||||
}
|
||||
|
||||
float computeObscurance(float linearDepth, float scale){
|
||||
vec4 P = vec4(lightDir, -dot(lightDir, vec3(0.0, 0.0, ztransform(linearDepth)) ) );
|
||||
|
||||
float sum = 0.0;
|
||||
|
||||
for(int c = 0; c < NEIGHBOUR_COUNT; c++){
|
||||
vec2 N_rel_pos = scale * zoom / vec2(screenWidth, screenHeight) * neighbours[c];
|
||||
vec2 N_abs_pos = vUv + N_rel_pos;
|
||||
|
||||
float neighbourDepth = logToLinear(texture2D(colorMap, N_abs_pos).a);
|
||||
|
||||
if(neighbourDepth != 0.0){
|
||||
float Zn = ztransform(neighbourDepth);
|
||||
float Znp = dot( vec4( N_rel_pos, Zn, 1.0), P );
|
||||
|
||||
sum += obscurance( Znp, 0.05 * linearDepth );
|
||||
}
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
void main(){
|
||||
float linearDepth = logToLinear(texture2D(colorMap, vUv).a);
|
||||
|
||||
float f = computeObscurance(linearDepth, pixScale);
|
||||
f = exp(-expScale * f);
|
||||
|
||||
vec4 color = texture2D(colorMap, vUv);
|
||||
if(color.a == 0.0 && f >= 1.0){
|
||||
discard;
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(color.rgb * f, 1.0);
|
||||
}
|
||||
15
src/materials/shaders/edl.vs
Normal file
15
src/materials/shaders/edl.vs
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
varying vec2 vUv;
|
||||
varying vec3 vViewRay;
|
||||
|
||||
void main() {
|
||||
vUv = uv;
|
||||
|
||||
vec4 mvPosition = modelViewMatrix * vec4(position,1.0);
|
||||
vViewRay = mvPosition.xyz;
|
||||
|
||||
gl_Position = projectionMatrix * mvPosition;
|
||||
|
||||
|
||||
}
|
||||
@ -7,10 +7,16 @@ uniform sampler2D texture;
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture2D(texture, vUv);
|
||||
float depth = texture2D(depthMap, vUv).g;
|
||||
|
||||
if(depth <= 0.0){
|
||||
discard;
|
||||
}
|
||||
|
||||
vec4 color = texture2D(texture, vUv);
|
||||
color = color / color.w;
|
||||
gl_FragColor = color;
|
||||
|
||||
gl_FragColor = vec4(color.xyz, 1.0);
|
||||
|
||||
gl_FragDepthEXT = depth;
|
||||
}
|
||||
@ -68,7 +68,7 @@ uniform sampler2D depthMap;
|
||||
varying vec3 vColor;
|
||||
varying float vOpacity;
|
||||
varying float vLinearDepth;
|
||||
varying float vDepth;
|
||||
varying float vLogDepth;
|
||||
varying vec3 vViewPosition;
|
||||
varying float vRadius;
|
||||
varying vec3 vWorldPosition;
|
||||
@ -78,6 +78,9 @@ float specularStrength = 1.0;
|
||||
|
||||
void main() {
|
||||
|
||||
vec3 color = vColor;
|
||||
float depth = gl_FragCoord.z;
|
||||
|
||||
#if defined(circle_point_shape) || defined(use_interpolation) || defined (weighted_splats)
|
||||
float u = 2.0 * gl_PointCoord.x - 1.0;
|
||||
float v = 2.0 * gl_PointCoord.y - 1.0;
|
||||
@ -92,25 +95,34 @@ void main() {
|
||||
|
||||
#if defined weighted_splats
|
||||
vec2 uv = gl_FragCoord.xy / vec2(screenWidth, screenHeight);
|
||||
float depth = texture2D(depthMap, uv).r;
|
||||
if(vLinearDepth > depth + vRadius){
|
||||
float sDepth = texture2D(depthMap, uv).r;
|
||||
if(vLinearDepth > sDepth + vRadius){
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined use_interpolation
|
||||
float w = 1.0 - ( u*u + v*v);
|
||||
float wi = 0.0 - ( u*u + v*v);
|
||||
vec4 pos = vec4(-vViewPosition, 1.0);
|
||||
pos.z += w * vRadius;
|
||||
pos.z += wi * vRadius;
|
||||
float linearDepth = pos.z;
|
||||
pos = projectionMatrix * pos;
|
||||
pos = pos / pos.w;
|
||||
gl_FragDepthEXT = (pos.z + 1.0) / 2.0;
|
||||
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
|
||||
|
||||
#endif
|
||||
|
||||
#if defined color_type_point_index
|
||||
gl_FragColor = vec4(vColor, pcIndex / 255.0);
|
||||
gl_FragColor = vec4(color, pcIndex / 255.0);
|
||||
#else
|
||||
gl_FragColor = vec4(vColor, vOpacity);
|
||||
gl_FragColor = vec4(color, vOpacity);
|
||||
#endif
|
||||
|
||||
#if defined weighted_splats
|
||||
@ -241,6 +253,11 @@ void main() {
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(use_edl)
|
||||
gl_FragColor.a = vLogDepth;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -22,7 +22,6 @@
|
||||
|
||||
#define max_clip_boxes 30
|
||||
|
||||
|
||||
attribute float intensity;
|
||||
attribute float classification;
|
||||
attribute float returnNumber;
|
||||
@ -62,8 +61,8 @@ uniform sampler2D depthMap;
|
||||
|
||||
varying float vOpacity;
|
||||
varying vec3 vColor;
|
||||
varying float vDepth;
|
||||
varying float vLinearDepth;
|
||||
varying float vLogDepth;
|
||||
varying vec3 vViewPosition;
|
||||
varying float vRadius;
|
||||
varying vec3 vWorldPosition;
|
||||
@ -217,9 +216,16 @@ void main() {
|
||||
gl_Position = projectionMatrix * mvPosition;
|
||||
vOpacity = opacity;
|
||||
vLinearDepth = -mvPosition.z;
|
||||
vDepth = mvPosition.z / gl_Position.w;
|
||||
vNormal = normalize(normalMatrix * normal);
|
||||
|
||||
|
||||
#if defined(use_edl)
|
||||
vLogDepth = log2(gl_Position.w + 1.0) / log2(far + 1.0);
|
||||
#endif
|
||||
|
||||
//#if defined(use_logarithmic_depth_buffer)
|
||||
// float logarithmicZ = (2.0 * log2(gl_Position.w + 1.0) / log2(far + 1.0) - 1.0) * gl_Position.w;
|
||||
// gl_Position.z = logarithmicZ;
|
||||
//#endif
|
||||
|
||||
// ---------------------
|
||||
// POINT COLOR
|
||||
@ -232,8 +238,9 @@ void main() {
|
||||
float w = (world.y - heightMin) / (heightMax-heightMin);
|
||||
vColor = texture2D(gradient, vec2(w,1.0-w)).rgb;
|
||||
#elif defined color_type_depth
|
||||
float d = -mvPosition.z ;
|
||||
vColor = vec3(d, vDepth, 0.0);
|
||||
float linearDepth = -mvPosition.z ;
|
||||
float expDepth = (gl_Position.z / gl_Position.w) * 0.5 + 0.5;
|
||||
vColor = vec3(linearDepth, expDepth, 0.0);
|
||||
#elif defined color_type_intensity
|
||||
float w = (intensity - intensityMin) / (intensityMax - intensityMin);
|
||||
vColor = vec3(w, w, w);
|
||||
@ -252,6 +259,11 @@ void main() {
|
||||
float c = mod(classification, 16.0);
|
||||
vec2 uv = vec2(c / 255.0, 0.5);
|
||||
vColor = texture2D(classificationLUT, uv).rgb;
|
||||
|
||||
// TODO only for testing - removing points with class 7
|
||||
if(classification == 7.0){
|
||||
gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
|
||||
}
|
||||
#elif defined color_type_return_number
|
||||
float w = (returnNumber - 1.0) / 4.0 + 0.1;
|
||||
vColor = texture2D(gradient, vec2(w, 1.0 - w)).rgb;
|
||||
|
||||
22
src/utils.js
22
src/utils.js
@ -306,4 +306,26 @@ Potree.utils.frustumSphereIntersection = function(frustum, sphere){
|
||||
};
|
||||
|
||||
|
||||
Potree.utils.screenPass = new function(){
|
||||
|
||||
this.screenScene = new THREE.Scene();
|
||||
this.screenQuad = new THREE.Mesh(new THREE.PlaneBufferGeometry(2, 2, 0));
|
||||
this.screenQuad.material.depthTest = true;
|
||||
this.screenQuad.material.depthWrite = true;
|
||||
this.screenQuad.material.transparent = true;
|
||||
this.screenScene.add(this.screenQuad);
|
||||
this.camera = new THREE.Camera();
|
||||
|
||||
this.render = function(renderer, material, target){
|
||||
this.screenQuad.material = material;
|
||||
|
||||
if(typeof target === undefined){
|
||||
renderer.render(this.screenScene, this.camera);
|
||||
}else{
|
||||
renderer.render(this.screenScene, this.camera, target);
|
||||
}
|
||||
}
|
||||
}();
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user