xzw 2 vuotta sitten
vanhempi
commit
1782ea97d2

+ 9 - 4
libs/three.js/lines/LineMaterial.js

@@ -52,6 +52,7 @@ UniformsLib.line = {
     depthTexture:{ value: null },
     nearPlane:{value: 0.1},
     farPlane:{value: 100000},
+    //uUseOrthographicCamera:{ type: "b", value: false },
 
 };
 
@@ -301,7 +302,7 @@ ShaderLib[ 'line' ] = {
 		uniform vec3 diffuse;
 		uniform float opacity;
 		uniform float lineWidth;
-         
+        uniform bool uUseOrthographicCamera; 
 		#ifdef USE_DASH
 
 			uniform float dashOffset;
@@ -355,8 +356,12 @@ ShaderLib[ 'line' ] = {
         #if defined(GL_EXT_frag_depth) && defined(useDepth)  
             float convertToLinear(float zValue)
             {
-                float z = zValue * 2.0 - 1.0;
-                return (2.0 * nearPlane * farPlane) / (farPlane + nearPlane - z * (farPlane - nearPlane));
+                //if(uUseOrthographicCamera){
+                //    return zValue*(farPlane-nearPlane)+nearPlane;
+                //}else{ 
+                    float z = zValue * 2.0 - 1.0;
+                    return (2.0 * nearPlane * farPlane) / (farPlane + nearPlane - z * (farPlane - nearPlane));
+                //} 
             }
         #endif
 
@@ -937,7 +942,7 @@ class LineMaterial extends ShaderMaterial {
             this.uniforms.nearPlane.value = camera.near;
             this.uniforms.farPlane.value = camera.far;
         }
-           
+        //this.uniforms.uUseOrthographicCamera.value = !camera.isPerspectiveCamera
     }
 
 }

+ 3 - 2
src/custom/materials/DepthBasicMaterial.js

@@ -10,7 +10,8 @@ export default class DepthBasicMaterial extends THREE.ShaderMaterial{
         
         let uniforms = {
 			resolution:    { type: 'v2',  value: new THREE.Vector2(width, height ) },
-            viewportOffset: { type: 'v2',  value: new THREE.Vector2(0, 0 ) }, //left, top    
+            viewportOffset: { type: 'v2',  value: new THREE.Vector2(0, 0 ) }, //left, top 
+            //uUseOrthographicCamera:{ type: "b", value: false },
 			nearPlane:     { type: 'f', 	value: 0.1 },
 			farPlane:      { type: 'f', 	value: 10000 }, 
 			depthTexture:   { type: 't', 	value: null }, 
@@ -174,7 +175,7 @@ export default class DepthBasicMaterial extends THREE.ShaderMaterial{
             this.uniforms.nearPlane.value = camera.near;
             this.uniforms.farPlane.value = camera.far;
         }
-              
+        //this.uniforms.uUseOrthographicCamera.value = !camera.isPerspectiveCamera
     }
 
     

+ 8 - 3
src/materials/shaders/depthBasic.fs

@@ -20,12 +20,17 @@ uniform vec3 baseColor;
     uniform float clipDistance;
     uniform float maxClipFactor;
     uniform float maxOcclusionFactor;
+    //uniform bool uUseOrthographicCamera;                                    
 
     float convertToLinear(float zValue)
     {
-        float z = zValue * 2.0 - 1.0;
-        return (2.0 * nearPlane * farPlane) / (farPlane + nearPlane - z * (farPlane - nearPlane));
-    }
+        //if(uUseOrthographicCamera){
+        //   return zValue*(farPlane-nearPlane)+nearPlane;
+        //}else{ 
+            float z = zValue * 2.0 - 1.0;
+            return (2.0 * nearPlane * farPlane) / (farPlane + nearPlane - z * (farPlane - nearPlane));
+        //}      
+     }
 #endif
   
 void main() {