Fix a problem of shadow map. (#7168)

This commit is contained in:
cary
2020-08-19 11:20:54 +08:00
committed by GitHub
parent a3b3782aaa
commit c24f5a77f3
2 changed files with 13 additions and 9 deletions
@@ -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,
+12 -8
View File
@@ -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) {