finialize oct16 normals; fix normals bugs; use camera light source
This commit is contained in:
parent
3658a7f4be
commit
80c09623ca
File diff suppressed because one or more lines are too long
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
@ -224,7 +224,7 @@ Potree.Shaders["pointcloud.vs"] = [
|
||||
" vOpacity = opacity;",
|
||||
" vLinearDepth = -mvPosition.z;",
|
||||
" vDepth = mvPosition.z / gl_Position.w;",
|
||||
" vNormal = normalMatrix * normal;",
|
||||
" vNormal = normalize(normalMatrix * normal);",
|
||||
"",
|
||||
"",
|
||||
" // ---------------------",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -30,13 +30,32 @@ Potree.Features = function(){
|
||||
SHADER_INTERPOLATION: {
|
||||
isSupported: function(){
|
||||
|
||||
//if(typeof this.shaderInterpolationSupported === "undefined"){
|
||||
// var material = new Potree.PointCloudMaterial();
|
||||
// material.interpolate = true;
|
||||
//
|
||||
// var vs = gl.createShader(gl.VERTEX_SHADER);
|
||||
// var fs = gl.createShader(gl.FRAGMENT_SHADER);
|
||||
// gl.shaderSource(vs, material.vertexShader);
|
||||
// gl.shaderSource(fs, material.fragmentShader);
|
||||
//
|
||||
// gl.compileShader(vs);
|
||||
// gl.compileShader(fs);
|
||||
//
|
||||
// var successVS = gl.getShaderParameter(vs, gl.COMPILE_STATUS);
|
||||
// var successFS = gl.getShaderParameter(fs, gl.COMPILE_STATUS);
|
||||
// this.shaderInterpolationSupported = successVS && successFS;
|
||||
//}
|
||||
//
|
||||
//return this.shaderInterpolationSupported;
|
||||
|
||||
|
||||
var supported = true;
|
||||
|
||||
supported = supported && gl.getExtension("EXT_frag_depth");
|
||||
supported = supported && gl.getParameter(gl.MAX_VARYING_VECTORS) >= 8;
|
||||
|
||||
return supported;
|
||||
|
||||
}
|
||||
},
|
||||
SHADER_SPLATS: {
|
||||
|
||||
@ -81,7 +81,6 @@ Potree.PointCloudOctree = function(geometry, material){
|
||||
this.visibleNodes = [];
|
||||
this.visibleGeometry = [];
|
||||
this.pickTarget;
|
||||
this.pickMaterial;
|
||||
this.maxLevel = 0;
|
||||
this.generateDEM = false;
|
||||
|
||||
@ -1011,44 +1010,15 @@ Potree.PointCloudOctree.prototype.pick = function(renderer, camera, ray, params)
|
||||
);
|
||||
}
|
||||
this.pickTarget.setSize(width, height);
|
||||
|
||||
// setup pick material.
|
||||
// use the same point size functions as the main material to get the same point sizes.
|
||||
if(!this.pickMaterial){
|
||||
this.pickMaterial = new Potree.PointCloudMaterial();
|
||||
this.pickMaterial.pointColorType = Potree.PointColorType.POINT_INDEX;
|
||||
this.pickMaterial.pointSizeType = Potree.PointSizeType.FIXED;
|
||||
}
|
||||
|
||||
this.pickMaterial.pointSizeType = this.material.pointSizeType;
|
||||
this.pickMaterial.size = this.material.size;
|
||||
|
||||
if(this.pickMaterial.pointSizeType === Potree.PointSizeType.ADAPTIVE){
|
||||
this.updateVisibilityTexture(this.pickMaterial, nodes);
|
||||
}
|
||||
|
||||
this.pickMaterial.fov = this.material.fov;
|
||||
this.pickMaterial.screenWidth = this.material.screenWidth;
|
||||
this.pickMaterial.screenHeight = this.material.screenHeight;
|
||||
this.pickMaterial.spacing = this.material.spacing;
|
||||
this.pickMaterial.near = this.material.near;
|
||||
this.pickMaterial.far = this.material.far;
|
||||
this.pickMaterial.pointShape = this.material.pointShape;
|
||||
|
||||
|
||||
|
||||
var _gl = renderer.context;
|
||||
|
||||
_gl.enable(_gl.SCISSOR_TEST);
|
||||
_gl.scissor(pixelPos.x - (pickWindowSize - 1) / 2, pixelPos.y - (pickWindowSize - 1) / 2,pickWindowSize,pickWindowSize);
|
||||
_gl.disable(_gl.SCISSOR_TEST);
|
||||
|
||||
var material = this.pickMaterial;
|
||||
|
||||
renderer.setRenderTarget( this.pickTarget );
|
||||
|
||||
renderer.setDepthTest( material.depthTest );
|
||||
renderer.setDepthWrite( material.depthWrite )
|
||||
renderer.setBlending( THREE.NoBlending );
|
||||
|
||||
renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
|
||||
@ -1066,10 +1036,33 @@ Potree.PointCloudOctree.prototype.pick = function(renderer, camera, ray, params)
|
||||
continue;
|
||||
}
|
||||
|
||||
material.pcIndex = i;
|
||||
if(!object.pickMaterial){
|
||||
object.pickMaterial = new Potree.PointCloudMaterial();
|
||||
}
|
||||
|
||||
if(material.program){
|
||||
var program = material.program.program;
|
||||
object.pickMaterial.pointColorType = Potree.PointColorType.POINT_INDEX;
|
||||
object.pickMaterial.pointSizeType = this.material.pointSizeType;
|
||||
object.pickMaterial.size = this.material.size;
|
||||
object.pickMaterial.fov = this.material.fov;
|
||||
object.pickMaterial.screenWidth = this.material.screenWidth;
|
||||
object.pickMaterial.screenHeight = this.material.screenHeight;
|
||||
object.pickMaterial.spacing = this.material.spacing;
|
||||
object.pickMaterial.near = this.material.near;
|
||||
object.pickMaterial.far = this.material.far;
|
||||
object.pickMaterial.pointShape = this.material.pointShape;
|
||||
object.pickMaterial.uniforms.level.value = object.level;
|
||||
|
||||
object.pickMaterial.uniforms.octreeSize.value = this.pcoGeometry.boundingBox.size().x;
|
||||
object.pickMaterial.uniforms.nodeSize.value = object.pcoGeometry.boundingBox.size().x;
|
||||
object.pickMaterial.uniforms.bbMin.value = object.pcoGeometry.boundingBox.min.toArray();
|
||||
|
||||
object.pickMaterial.uniforms.visibleNodesTexture = this.material.visibleNodesTexture;
|
||||
object.pickMaterial.uniforms.visibleNodes.value = this.material.visibleNodesTexture;
|
||||
|
||||
object.pickMaterial.uniforms.pcIndex.value = i;
|
||||
|
||||
if(object.pickMaterial.program){
|
||||
var program = object.pickMaterial.program.program;
|
||||
_gl.useProgram( program );
|
||||
//_gl.disable( _gl.BLEND );
|
||||
|
||||
@ -1082,11 +1075,20 @@ Potree.PointCloudOctree.prototype.pick = function(renderer, camera, ray, params)
|
||||
//}
|
||||
_gl.enableVertexAttribArray( attributePointer );
|
||||
_gl.vertexAttribPointer( attributePointer, attributeSize, _gl.UNSIGNED_BYTE, true, 0, 0 );
|
||||
|
||||
_gl.uniform1f(material.program.uniforms.pcIndex, material.pcIndex);
|
||||
//
|
||||
// _gl.uniform1f(object.pickMaterial.program.uniforms.pcIndex, object.pickMaterial.pcIndex);
|
||||
}
|
||||
|
||||
renderer.renderBufferDirect(camera, [], null, material, geometry, object);
|
||||
renderer.renderBufferDirect(camera, [], null, object.pickMaterial, geometry, object);
|
||||
|
||||
if(object.pickMaterial.program){
|
||||
var program = object.pickMaterial.program.program;
|
||||
_gl.useProgram( program );
|
||||
var attributePointer = _gl.getAttribLocation(program, "indices");
|
||||
var attributeSize = 4;
|
||||
_gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.attributes.indices.buffer );
|
||||
_gl.disableVertexAttribArray( attributePointer );
|
||||
}
|
||||
}
|
||||
|
||||
var pixelCount = pickWindowSize * pickWindowSize;
|
||||
|
||||
@ -80,6 +80,8 @@ Potree.BinaryLoader.prototype.parse = function(node, buffer){
|
||||
geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(buffer), 3));
|
||||
}else if(parseInt(property) === PointAttributeNames.NORMAL_OCT16){
|
||||
geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(buffer), 3));
|
||||
}else if(parseInt(property) === PointAttributeNames.NORMAL){
|
||||
geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(buffer), 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ PointAttributeNames.INTENSITY = 6;
|
||||
PointAttributeNames.CLASSIFICATION = 7;
|
||||
PointAttributeNames.NORMAL_SPHEREMAPPED = 8;
|
||||
PointAttributeNames.NORMAL_OCT16 = 9;
|
||||
PointAttributeNames.NORMAL = 10;
|
||||
|
||||
/**
|
||||
* Some types of possible point attribute data formats
|
||||
@ -95,6 +96,10 @@ PointAttribute.NORMAL_SPHEREMAPPED = new PointAttribute(
|
||||
PointAttribute.NORMAL_OCT16 = new PointAttribute(
|
||||
PointAttributeNames.NORMAL_OCT16,
|
||||
PointAttributeTypes.DATA_TYPE_UINT8, 2);
|
||||
|
||||
PointAttribute.NORMAL = new PointAttribute(
|
||||
PointAttributeNames.NORMAL,
|
||||
PointAttributeTypes.DATA_TYPE_FLOAT, 3);
|
||||
|
||||
/**
|
||||
* Ordered list of PointAttributes used to identify how points are aligned in a buffer.
|
||||
@ -148,6 +153,7 @@ PointAttributes.prototype.hasNormals = function(){
|
||||
if(
|
||||
pointAttribute === PointAttribute.NORMAL_SPHEREMAPPED ||
|
||||
pointAttribute === PointAttribute.NORMAL_FLOATS ||
|
||||
pointAttribute === PointAttribute.NORMAL ||
|
||||
pointAttribute === PointAttribute.NORMAL_OCT16){
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ void main() {
|
||||
vOpacity = opacity;
|
||||
vLinearDepth = -mvPosition.z;
|
||||
vDepth = mvPosition.z / gl_Position.w;
|
||||
vNormal = normalMatrix * normal;
|
||||
vNormal = normalize(normalMatrix * normal);
|
||||
|
||||
|
||||
// ---------------------
|
||||
|
||||
@ -168,6 +168,20 @@ onmessage = function(event){
|
||||
normals[3*j + 2] = z;
|
||||
}
|
||||
attributeBuffers[pointAttribute.name] = { buffer: buff, attribute: pointAttribute};
|
||||
}else if(pointAttribute.name === PointAttribute.NORMAL.name){
|
||||
|
||||
var buff = new ArrayBuffer(numPoints*4*3);
|
||||
var normals = new Float32Array(buff);
|
||||
for(var j = 0; j < numPoints; j++){
|
||||
var x = cv.getFloat(offset + j * pointAttributes.byteSize + 0);
|
||||
var y = cv.getFloat(offset + j * pointAttributes.byteSize + 4);
|
||||
var z = cv.getFloat(offset + j * pointAttributes.byteSize + 8);
|
||||
|
||||
normals[3*j + 0] = x;
|
||||
normals[3*j + 1] = y;
|
||||
normals[3*j + 2] = z;
|
||||
}
|
||||
attributeBuffers[pointAttribute.name] = { buffer: buff, attribute: pointAttribute};
|
||||
}
|
||||
|
||||
offset += pointAttribute.byteSize;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user