From 2c7d5ef489cb82db53e9e67b764a4b04dddde5f5 Mon Sep 17 00:00:00 2001 From: Yun Hsiao Wu Date: Fri, 6 Dec 2019 11:19:07 +0800 Subject: [PATCH] planar shadow depth bias (#5857) --- cocos/core/renderer/scene/planar-shadows.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/core/renderer/scene/planar-shadows.ts b/cocos/core/renderer/scene/planar-shadows.ts index 5552c9ba9a..2b6992de3d 100644 --- a/cocos/core/renderer/scene/planar-shadows.ts +++ b/cocos/core/renderer/scene/planar-shadows.ts @@ -103,7 +103,7 @@ export class PlanarShadows { public updateSphereLight (light: SphereLight) { light.node!.getWorldPosition(_v3); - const n = this._normal; const d = this._distance; + const n = this._normal; const d = this._distance + 0.001; // avoid z-fighting const NdL = Vec3.dot(n, _v3); const lx = _v3.x; const ly = _v3.y; const lz = _v3.z; const nx = n.x; const ny = n.y; const nz = n.z; @@ -131,7 +131,7 @@ export class PlanarShadows { public updateDirLight (light: DirectionalLight) { light.node!.getWorldRotation(_qt); Vec3.transformQuat(_v3, _forward, _qt); - const n = this._normal; const d = this._distance; + const n = this._normal; const d = this._distance + 0.001; // avoid z-fighting const NdL = Vec3.dot(n, _v3); const scale = 1 / NdL; const lx = _v3.x * scale; const ly = _v3.y * scale; const lz = _v3.z * scale; const nx = n.x; const ny = n.y; const nz = n.z;