mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
Fix a problem of shadow map. (#7168)
This commit is contained in:
@@ -199,7 +199,7 @@ export class ForwardPipeline extends RenderPipeline {
|
||||
Mat4.invert(matShadowView, mainLight!.node!.worldMatrix);
|
||||
|
||||
// light proj
|
||||
const x = shadowInfo.near * shadowInfo.aspect;
|
||||
const x = shadowInfo.orthoSize * shadowInfo.aspect;
|
||||
const y = shadowInfo.orthoSize;
|
||||
const projectionSignY = device.screenSpaceSignY * device.UVSpaceSignY;
|
||||
Mat4.ortho(matShadowViewProj, -x, x, -y, y, shadowInfo.near, shadowInfo.far,
|
||||
|
||||
@@ -130,19 +130,23 @@ export class PlanarShadows {
|
||||
protected _dirty: boolean = true;
|
||||
|
||||
public activate () {
|
||||
if (!this._enabled) {
|
||||
return;
|
||||
}
|
||||
this._dirty = true;
|
||||
const pipeline = legacyCC.director.root.pipeline;
|
||||
this._globalDescriptorSet = pipeline.descriptorSet;
|
||||
this._data = (pipeline as ForwardPipeline).shadowUBO;
|
||||
Color.toArray(this._data, this._shadowColor, UBOShadow.SHADOW_COLOR_OFFSET);
|
||||
this._globalDescriptorSet!.getBuffer(UBOShadow.BLOCK.binding).update(this.data);
|
||||
this._material = new Material();
|
||||
this._material.initialize({ effectName: 'pipeline/planar-shadow' });
|
||||
this._instancingMaterial = new Material();
|
||||
this._instancingMaterial.initialize({ effectName: 'pipeline/planar-shadow', defines: { USE_INSTANCING: true } });
|
||||
if (!this._enabled) {
|
||||
return;
|
||||
}
|
||||
this._dirty = true;
|
||||
if (!this._material) {
|
||||
this._material = new Material();
|
||||
this._material.initialize({ effectName: 'pipeline/planar-shadow' });
|
||||
}
|
||||
if (!this._instancingMaterial) {
|
||||
this._instancingMaterial = new Material();
|
||||
this._instancingMaterial.initialize({ effectName: 'pipeline/planar-shadow', defines: { USE_INSTANCING: true } });
|
||||
}
|
||||
}
|
||||
|
||||
public updateSphereLight (light: SphereLight) {
|
||||
|
||||
Reference in New Issue
Block a user