Browse Source

fix lighting for orthographic projection close to camera

Alexander Rose 5 năm trước cách đây
mục cha
commit
ac46317dc6

+ 3 - 0
src/mol-canvas3d/camera.ts

@@ -269,6 +269,9 @@ function updateClip(camera: Camera) {
         // set at least to 5 to avoid slow sphere impostor rendering
         near = Math.max(5, near)
         far = Math.max(5, far)
+    } else {
+        near = Math.max(0, near)
+        far = Math.max(0, far)
     }
 
     camera.near = near;

+ 1 - 1
src/mol-gl/shader/chunks/apply-light-color.glsl.ts

@@ -36,7 +36,7 @@ geometry.normal = normal;
 geometry.viewDir = normalize(vViewPosition);
 
 IncidentLight directLight;
-directLight.direction = geometry.viewDir;
+directLight.direction = vec3(0.0, 0.0, -1.0);
 directLight.color = vec3(uLightIntensity);
 
 RE_Direct_Physical(directLight, geometry, physicalMaterial, reflectedLight);

+ 2 - 2
src/mol-gl/shader/spheres.frag.ts

@@ -124,8 +124,8 @@ void main(void){
     #elif defined(dColorType_depth)
         gl_FragColor = material;
     #else
-        vec3 normal = cameraNormal;
-        vec3 vViewPosition = -cameraPos;
+        vec3 normal = -cameraNormal;
+        vec3 vViewPosition = cameraPos;
         #include apply_light_color
 
         if (interior) {