瀏覽代碼

Fix mesh visibility for PBR material

Gary Hsu 6 年之前
父節點
當前提交
aa1af535ce

+ 6 - 5
dist/preview release/what's new.md

@@ -192,16 +192,17 @@
 - CannonJS ignores connectedPivot joint parameter ([TrevorDev](https://github.com/TrevorDev))
 - Fix case sensitive paths ([mrdunk](https://github.com))
 - Fix more case sensitive paths ([mrdunk](https://github.com))
-- Attaching a BoundingBoxGizmo on a child should not remove its parent ([TrevorDev](https://github.com/TrevorDev)))
-- AmmoJS fix include issue caused after modules update and use world contact point to be consistent with oimo and cannon ([TrevorDev](https://github.com/TrevorDev)))
-- Warn of motor with maxForce in Oimo plugin and set default force to be consistent with others, cannonJS support no impostor, cannonJS cylinder axis, ammoJS wake up impostor when apply force/impulse ([TrevorDev](https://github.com/TrevorDev)))
+- Attaching a BoundingBoxGizmo on a child should not remove its parent ([TrevorDev](https://github.com/TrevorDev))
+- AmmoJS fix include issue caused after modules update and use world contact point to be consistent with oimo and cannon ([TrevorDev](https://github.com/TrevorDev))
+- Warn of motor with maxForce in Oimo plugin and set default force to be consistent with others, cannonJS support no impostor, cannonJS cylinder axis, ammoJS wake up impostor when apply force/impulse ([TrevorDev](https://github.com/TrevorDev))
 - Utility layer should render on last active camera ([TrevorDev](https://github.com/TrevorDev))
 - PointerDragBehavior should not let the drag plane get out of sync when rotating the object during dragging ([TrevorDev](https://github.com/TrevorDev))
 - Do not crash the application if webVR submitFrame fails ([TrevorDev](https://github.com/TrevorDev))
 - Fix pinch action on FollowCameraPointersInput ([mrdunk](https://github.com))
 - Tools.CreateScreenshot stopped working ([TrevorDev](https://github.com/TrevorDev))
-- Inspector showing duplicate nodes when attached to gizmo ([TrevorDev](https://github.com/TrevorDev)))
-- Add missing dependencies for files to support including them from a direct path (eg. import "@babylonjs/core/Helpers/sceneHelpers";) ([TrevorDev](https://github.com/TrevorDev)))
+- Inspector showing duplicate nodes when attached to gizmo ([TrevorDev](https://github.com/TrevorDev))
+- Add missing dependencies for files to support including them from a direct path (eg. import "@babylonjs/core/Helpers/sceneHelpers";) ([TrevorDev](https://github.com/TrevorDev))
+- Fix a bug with mesh visibility in PBR materials ([bghgary](https://github.com/bghgary))
 
 ### Core Engine
 - Fixed a bug with `mesh.alwaysSelectAsActiveMesh` preventing layerMask to be taken in account ([Deltakosh](https://github.com/deltakosh))

+ 4 - 2
src/Materials/PBR/pbrBaseMaterial.ts

@@ -845,7 +845,7 @@ export abstract class PBRBaseMaterial extends PushMaterial {
      * @param mesh - BJS mesh.
      */
     public needAlphaBlendingForMesh(mesh: AbstractMesh): boolean {
-        if (this._disableAlphaBlending) {
+        if (this._disableAlphaBlending && mesh.visibility >= 1.0) {
             return false;
         }
 
@@ -1763,7 +1763,9 @@ export abstract class PBRBaseMaterial extends PushMaterial {
 
                 this._uniformBuffer.updateColor3("vEmissiveColor", MaterialFlags.EmissiveTextureEnabled ? this._emissiveColor : Color3.BlackReadOnly);
                 this._uniformBuffer.updateColor3("vReflectionColor", this._reflectionColor);
-                this._uniformBuffer.updateColor4("vAlbedoColor", this._albedoColor, this.alpha * mesh.visibility);
+
+                const alpha = this._disableAlphaBlending ? mesh.visibility : this.alpha * mesh.visibility;
+                this._uniformBuffer.updateColor4("vAlbedoColor", this._albedoColor, alpha);
 
                 // Misc
                 this._lightingInfos.x = this._directIntensity;

二進制
tests/validation/ReferenceImages/visibility.png


+ 5 - 0
tests/validation/config.json

@@ -606,6 +606,11 @@
       "title": "Outline",
       "playgroundId": "#10WJ5S#6",
       "referenceImage": "outline.png"
+    },
+    {
+      "title": "Visibility",
+      "playgroundId": "#PXC9CF#2",
+      "referenceImage": "visibility.png"
     }
   ]
 }