...
This commit is contained in:
parent
ea973bd8d5
commit
ac3c1883ac
@ -1539,6 +1539,16 @@ Potree.Renderer = class{
|
||||
const lSnapProj = shader.uniformLocations["uSnapProj[0]"];
|
||||
gl.uniformMatrix4fv(lSnapProj, false, flattenedMatrices);
|
||||
}
|
||||
{
|
||||
let flattenedMatrices = [].concat(...material.uniforms.uSnapProjInv.value.map(c => c.elements));
|
||||
const lSnapProjInv = shader.uniformLocations["uSnapProjInv[0]"];
|
||||
gl.uniformMatrix4fv(lSnapProjInv, false, flattenedMatrices);
|
||||
}
|
||||
{
|
||||
let flattenedMatrices = [].concat(...material.uniforms.uSnapViewInv.value.map(c => c.elements));
|
||||
const lSnapViewInv = shader.uniformLocations["uSnapViewInv[0]"];
|
||||
gl.uniformMatrix4fv(lSnapViewInv, false, flattenedMatrices);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,8 +268,11 @@ Potree.PointCloudMaterial = class PointCloudMaterial extends THREE.RawShaderMate
|
||||
orthoRange: { type: "f", value: 10.0 },
|
||||
clipMode: { type: "i", value: 1},
|
||||
uSnapshot: { type: "tv", value: []},
|
||||
uSnapshotDepth: { type: "tv", value: []},
|
||||
uSnapView: { type: "Matrix4fv", value: []},
|
||||
uSnapProj: { type: "Matrix4fv", value: []},
|
||||
uSnapProjInv: { type: "Matrix4fv", value: []},
|
||||
uSnapViewInv: { type: "Matrix4fv", value: []},
|
||||
};
|
||||
|
||||
this.defaultAttributeValues.normal = [0, 0, 0];
|
||||
|
||||
@ -33,8 +33,11 @@ varying float vRadius;
|
||||
#define max_snapshots 5
|
||||
#if defined(snap_enabled)
|
||||
uniform sampler2D uSnapshot[max_snapshots];
|
||||
uniform sampler2D uSnapshotDepth[max_snapshots];
|
||||
uniform mat4 uSnapView[max_snapshots];
|
||||
uniform mat4 uSnapProj[max_snapshots];
|
||||
uniform mat4 uSnapProjInv[max_snapshots];
|
||||
uniform mat4 uSnapViewInv[max_snapshots];
|
||||
#endif
|
||||
|
||||
varying vec4 vSP;
|
||||
@ -53,62 +56,24 @@ void main() {
|
||||
#if defined(snap_enabled)
|
||||
//vec2 uv = 0.5 * (vSP.xy / vSP.w) + 0.5;
|
||||
|
||||
vec2 pc = vec2(
|
||||
gl_PointCoord.x - 0.5,
|
||||
(1.0 - gl_PointCoord.y) - 0.5
|
||||
);
|
||||
vec2 pc = vec2(gl_PointCoord.x - 0.5, (1.0 - gl_PointCoord.y) - 0.5);
|
||||
vec2 offset = (pc * vPointSize) / vec2(screenWidth, screenHeight);
|
||||
|
||||
vec2 uv0 = 0.5 * (vSnapProjected[0].xy /vSnapProjected[0].w) + 0.5 + offset;
|
||||
vec2 uv1 = 0.5 * (vSnapProjected[1].xy /vSnapProjected[1].w) + 0.5 + offset;
|
||||
vec2 uv2 = 0.5 * (vSnapProjected[2].xy /vSnapProjected[2].w) + 0.5 + offset;
|
||||
vec2 uv3 = 0.5 * (vSnapProjected[3].xy /vSnapProjected[3].w) + 0.5 + offset;
|
||||
vec2 uv4 = 0.5 * (vSnapProjected[4].xy /vSnapProjected[4].w) + 0.5 + offset;
|
||||
|
||||
vec4 tc_0 = texture2D(uSnapshot[0], uv0);
|
||||
vec4 tc_1 = texture2D(uSnapshot[1], uv1);
|
||||
vec4 tc_2 = texture2D(uSnapshot[2], uv2);
|
||||
vec4 tc_3 = texture2D(uSnapshot[3], uv3);
|
||||
vec4 tc_4 = texture2D(uSnapshot[4], uv4);
|
||||
|
||||
//color = ((tc_0 + tc_1 + tc_2 + tc_3 + tc_4) / 5.0).rgb;
|
||||
//color = ((tc_0 + tc_1 + tc_2 + tc_3) / 4.0).rgb;
|
||||
//color = (tc_0.rgb + tc_1.rgb + tc_2.rgb + tc_3.rgb + tc_4.rgb) / 5.0;
|
||||
|
||||
vec3 sRGB = vec3(0.0, 0.0, 0.0);
|
||||
float sA = 0.0;
|
||||
|
||||
if(tc_0.a > 0.0){
|
||||
sRGB += tc_0.rgb;
|
||||
sA += tc_0.a;
|
||||
}
|
||||
if(tc_1.a > 0.0){
|
||||
sRGB += tc_1.rgb;
|
||||
sA += tc_1.a;
|
||||
}
|
||||
if(tc_2.a > 0.0){
|
||||
sRGB += tc_2.rgb;
|
||||
sA += tc_2.a;
|
||||
}
|
||||
if(tc_3.a > 0.0){
|
||||
sRGB += tc_3.rgb;
|
||||
sA += tc_3.a;
|
||||
}
|
||||
if(tc_4.a > 0.0){
|
||||
sRGB += tc_4.rgb;
|
||||
sA += tc_4.a;
|
||||
for(int i = 0; i < max_snapshots; i++){
|
||||
vec2 uv = 0.5 * (vSnapProjected[i].xy /vSnapProjected[i].w) + 0.5 + offset;
|
||||
vec4 tc = texture2D(uSnapshot[i], uv);
|
||||
|
||||
if(tc.a > 0.0){
|
||||
sRGB += tc.rgb;
|
||||
sA += tc.a;
|
||||
}
|
||||
}
|
||||
|
||||
//color = sRGB / sA;
|
||||
color = sRGB * 0.5;
|
||||
|
||||
|
||||
//color = tc.rgb;
|
||||
|
||||
//if(tc.a == 0.0){
|
||||
// discard;
|
||||
// return;
|
||||
//}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -81,14 +81,10 @@ uniform mat4 smWorldViewProj;
|
||||
|
||||
#define max_snapshots 5
|
||||
#if defined(snap_enabled)
|
||||
uniform sampler2D uSnapshot_0;
|
||||
uniform sampler2D uSnapshot_1;
|
||||
uniform sampler2D uSnapshot_2;
|
||||
uniform sampler2D uSnapshot_3;
|
||||
uniform sampler2D uSnapshot_4;
|
||||
|
||||
uniform sampler2D uSnapshot[max_snapshots];
|
||||
uniform mat4 uSnapView[max_snapshots];
|
||||
uniform mat4 uSnapProj[max_snapshots];
|
||||
uniform mat4 uSnapScreenToCurrentView[max_snapshots];
|
||||
#endif
|
||||
|
||||
varying float vOpacity;
|
||||
|
||||
@ -65,24 +65,15 @@ class RepRenderer {
|
||||
this.rtShadow.depthTexture = new THREE.DepthTexture();
|
||||
this.rtShadow.depthTexture.type = THREE.UnsignedIntType;
|
||||
|
||||
this.snap.target = new THREE.WebGLRenderTarget(1024, 1024, {
|
||||
minFilter: THREE.NearestFilter,
|
||||
magFilter: THREE.NearestFilter,
|
||||
format: THREE.RGBAFormat,
|
||||
type: THREE.FloatType
|
||||
});
|
||||
this.snap.target.generateMipMaps = false;
|
||||
|
||||
|
||||
{
|
||||
let geometry = new THREE.PlaneBufferGeometry( 20, 20, 32 );
|
||||
let material = new THREE.MeshBasicMaterial( {side: THREE.DoubleSide, map: this.snap.target.texture} );
|
||||
let plane = new THREE.Mesh( geometry, material );
|
||||
plane.position.z = 0.2;
|
||||
plane.position.y = -1;
|
||||
this.viewer.scene.scene.add( plane );
|
||||
this.debugPlane = plane;
|
||||
}
|
||||
//{
|
||||
// let geometry = new THREE.PlaneBufferGeometry( 20, 20, 32 );
|
||||
// let material = new THREE.MeshBasicMaterial( {side: THREE.DoubleSide, map: this.snap.target.texture} );
|
||||
// let plane = new THREE.Mesh( geometry, material );
|
||||
// plane.position.z = 0.2;
|
||||
// plane.position.y = -1;
|
||||
// this.viewer.scene.scene.add( plane );
|
||||
// this.debugPlane = plane;
|
||||
//}
|
||||
};
|
||||
|
||||
resize () {
|
||||
@ -185,20 +176,6 @@ class RepRenderer {
|
||||
|
||||
//viewer.pRenderer.render(viewer.scene.scenePointCloud, viewer.shadowTestCam, this.rtShadow);
|
||||
|
||||
|
||||
//if(this.snapshotRequested || !this.snap.camera){
|
||||
// viewer.renderer.clearTarget(this.snap.target, true, true, true);
|
||||
// viewer.renderer.setRenderTarget(this.snap.target);
|
||||
// camera.updateProjectionMatrix();
|
||||
// this.snap.camera = camera.clone();
|
||||
// for(const octree of viewer.scene.pointclouds){
|
||||
// octree.material.snapEnabled = false;
|
||||
// octree.material.needsUpdate = true;
|
||||
// viewer.pRenderer.renderOctree(octree, octree.visibleNodes, camera, this.snap.target, {});
|
||||
// }
|
||||
// this.snapshotRequested = false;
|
||||
//}
|
||||
|
||||
{ // NEW SNAPSHOT
|
||||
|
||||
let snap;
|
||||
@ -210,6 +187,8 @@ class RepRenderer {
|
||||
format: THREE.RGBAFormat,
|
||||
type: THREE.FloatType
|
||||
});
|
||||
//snap.target.depthTexture = new THREE.DepthTexture();
|
||||
//snap.target.depthTexture.type = THREE.UnsignedIntType;
|
||||
}else{
|
||||
snap = this.history.snapshots.pop();
|
||||
}
|
||||
@ -258,20 +237,15 @@ class RepRenderer {
|
||||
for(const octree of viewer.scene.pointclouds){
|
||||
octree.material.snapEnabled = true;
|
||||
octree.material.needsUpdate = true;
|
||||
//octree.material.uniforms.snapshot.value = this.history.snapshots[0].target.texture;
|
||||
//octree.material.uniforms.snapView.value = this.history.snapshots[0].camera.matrixWorldInverse;
|
||||
//octree.material.uniforms.snapProj.value = this.history.snapshots[0].camera.projectionMatrix;
|
||||
|
||||
let uniforms = octree.material.uniforms;
|
||||
if(this.history.snapshots.length === this.history.maxSnapshots){
|
||||
uniforms[`uSnapshot`].value = this.history.snapshots.map(s => s.target.texture);
|
||||
uniforms[`uSnapshot`].value = this.history.snapshots.map(s => s.target.texture);
|
||||
uniforms[`uSnapView`].value = this.history.snapshots.map(s => s.camera.matrixWorldInverse);
|
||||
uniforms[`uSnapProj`].value = this.history.snapshots.map(s => s.camera.projectionMatrix);
|
||||
|
||||
//for(let i = 0; i < 5; i++){
|
||||
// let snap = this.history.snapshots[i];
|
||||
// uniforms[`uSnapshot_${i}`].value = snap.target.texture;
|
||||
//}
|
||||
uniforms[`uSnapProjInv`].value = this.history.snapshots.map(s => new THREE.Matrix4().getInverse(s.camera.projectionMatrix));
|
||||
uniforms[`uSnapViewInv`].value = this.history.snapshots.map(s => new THREE.Matrix4().getInverse(s.camera.matrixWorld));
|
||||
}
|
||||
|
||||
let nodes = octree.visibleNodes.slice(0, 10);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user