mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 00:22:43 +08:00
planar shadow depth bias (#5857)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user