浏览代码

only cache and restore stencil state with transparency

Trevor Baron 6 年之前
父节点
当前提交
e93b3915fc
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      src/Rendering/outlineRenderer.ts

+ 4 - 3
src/Rendering/outlineRenderer.ts

@@ -278,10 +278,9 @@ export class OutlineRenderer implements ISceneComponent {
         // Outline - step 1
         this._savedDepthWrite = this._engine.getDepthWrite();
         if (mesh.renderOutline) {
-            this._engine.cacheStencilState();
-
             var material = subMesh.getMaterial();
             if (material && material.needAlphaBlending) {
+                this._engine.cacheStencilState();
                 // Draw only to stencil buffer for the original mesh
                 // The resulting stencil buffer will be used so the outline is not visible inside the mesh when the mesh is transparent
                 this._engine.setDepthWrite(false);
@@ -302,7 +301,9 @@ export class OutlineRenderer implements ISceneComponent {
             this.render(subMesh, batch);
             this._engine.setDepthWrite(this._savedDepthWrite);
 
-            this._engine.restoreStencilState();
+            if (material && material.needAlphaBlending) {
+                this._engine.restoreStencilState();
+            }
         }
     }