|
@@ -76,7 +76,14 @@ let shader = {
|
|
|
type: "f",
|
|
|
value: 1
|
|
|
},
|
|
|
-
|
|
|
+ ceilHeight0:{
|
|
|
+ type: "f",
|
|
|
+ value: 2
|
|
|
+ },
|
|
|
+ ceilHeight1:{
|
|
|
+ type: "f",
|
|
|
+ value: 2
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
vertexShader: prefixVertex + `
|
|
@@ -149,9 +156,6 @@ let shader = {
|
|
|
uniform float minDistance;
|
|
|
uniform float minOpa;
|
|
|
|
|
|
- uniform float cameraHeight0;
|
|
|
- uniform float cameraHeight1;
|
|
|
-
|
|
|
|
|
|
|
|
|
/* uniform sampler2D pano0Map;
|
|
@@ -190,8 +194,12 @@ let shader = {
|
|
|
uniform mat4 inverseProjectionMatrix;
|
|
|
uniform mat4 projectionMatrix;
|
|
|
uniform vec4 viewport;
|
|
|
-
|
|
|
- vec2 getDepth(vec3 dir, sampler2D depthMap, float height, vec4 eyePos){
|
|
|
+ uniform float cameraHeight0;
|
|
|
+ uniform float cameraHeight1;
|
|
|
+ uniform float ceilHeight0;
|
|
|
+ uniform float ceilHeight1;
|
|
|
+
|
|
|
+ vec2 getDepth(vec3 dir, sampler2D depthMap, float heightDown, float heightUp, vec4 eyePos){
|
|
|
vec2 depthValue = vec2(0.0, 0.0);
|
|
|
vec2 uv2 = getSamplerCoord2(/* vWorldPosition12 */dir.xyz); //暂时只用基于目标漫游点的方向
|
|
|
uv2.x -= 0.25; //全景图和Cube的水平采样起始坐标相差90度,这里矫正 0.25 个采样偏移
|
|
@@ -203,7 +211,8 @@ let shader = {
|
|
|
float distance = (depth.g + depth.r / 256.) * 255.; //为什么要乘以255
|
|
|
|
|
|
if(distance == 0.0){//漫游点底部识别不到的区域,给一个地板高度
|
|
|
- if(uv2.y > 0.75) distance = height / -dir.y;
|
|
|
+ if(uv2.y < 0.25) distance = heightUp / dir.y;
|
|
|
+ else if(uv2.y > 0.75) distance = heightDown / -dir.y;
|
|
|
else distance = 100000.0;//给个超级远的值
|
|
|
}
|
|
|
|
|
@@ -259,9 +268,9 @@ let shader = {
|
|
|
vec4 eyePos = inverseProjectionMatrix * clipPos;
|
|
|
vec2 depth0 = vec2(0.0,0.0);
|
|
|
if(progress < 1.0){
|
|
|
- depth0 = getDepth(vWorldPosition0N, depthMap0, cameraHeight0, eyePos);
|
|
|
+ depth0 = getDepth(vWorldPosition0N, depthMap0, cameraHeight0, ceilHeight0, eyePos);
|
|
|
}
|
|
|
- vec2 depth1 = getDepth(vWorldPosition1N, depthMap1, cameraHeight1, eyePos);
|
|
|
+ vec2 depth1 = getDepth(vWorldPosition1N, depthMap1, cameraHeight1, ceilHeight1, eyePos);
|
|
|
|
|
|
/* if(progress < 1.0 && depth1.x == 0.0 && depth0.x > 0.0){
|
|
|
gl_FragDepthEXT = depth0.y;
|
|
@@ -355,9 +364,7 @@ export default class ModelTextureMaterial extends THREE.RawShaderMaterial {
|
|
|
if(pano0){
|
|
|
this.uniforms.pano0Map.value = pano0.getSkyboxTexture();//pano0.texture
|
|
|
this.uniforms.pano0Position.value.copy(pano0.position)
|
|
|
- this.uniforms.pano0Matrix.value.copy(pano0.panoMatrix/* pano0.mesh.matrixWorld */ );
|
|
|
- this.uniforms.cameraHeight0.value = pano0.floorPosition.distanceTo(pano0.position)
|
|
|
-
|
|
|
+ this.uniforms.pano0Matrix.value.copy(pano0.panoMatrix/* pano0.mesh.matrixWorld */ );
|
|
|
//pano1.ensureSkyboxReadyForRender();
|
|
|
}
|
|
|
|
|
@@ -365,7 +372,9 @@ export default class ModelTextureMaterial extends THREE.RawShaderMaterial {
|
|
|
this.uniforms.pano1Map.value = pano1.getSkyboxTexture()//pano1.texture;
|
|
|
this.uniforms.pano1Position.value.copy(pano1.position)
|
|
|
this.uniforms.pano1Matrix.value.copy(pano1.panoMatrix /* pano1.mesh.matrixWorld */ );
|
|
|
- this.uniforms.cameraHeight1.value = pano1.floorPosition.distanceTo(pano1.position)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
this.pano0 = pano0
|
|
|
this.pano1 = pano1
|
|
|
|
|
@@ -382,8 +391,18 @@ export default class ModelTextureMaterial extends THREE.RawShaderMaterial {
|
|
|
updateDepthTex(pano){
|
|
|
if( !Potree.settings.useDepthTex || !pano || !pano.depthTex || pano!=this.pano0 && pano!=this.pano1)return
|
|
|
//console.log('updateDepthTex', pano.id, this.pano0 && this.pano0.id, this.pano1 && this.pano1.id)
|
|
|
- this.uniforms.depthMap0.value = this.pano0 && this.pano0.depthTex
|
|
|
- this.uniforms.depthMap1.value = this.pano1 && this.pano1.depthTex
|
|
|
+
|
|
|
+
|
|
|
+ if(this.pano0){
|
|
|
+ this.uniforms.depthMap0.value = this.pano0.depthTex
|
|
|
+ this.uniforms.cameraHeight0.value = this.pano0.floorPosition.distanceTo(this.pano0.position)
|
|
|
+ this.uniforms.ceilHeight0.value = this.pano0.getCeilHeight() - this.pano0.position.z
|
|
|
+ }
|
|
|
+ if(this.pano1){
|
|
|
+ this.uniforms.depthMap1.value = this.pano1.depthTex
|
|
|
+ this.uniforms.cameraHeight1.value = this.pano1.floorPosition.distanceTo(this.pano1.position)
|
|
|
+ this.uniforms.ceilHeight1.value = this.pano1.getCeilHeight() - this.pano1.position.z
|
|
|
+ }
|
|
|
this.updateDepthTexEnable()
|
|
|
}
|
|
|
|