add a switch for planar shadow

This commit is contained in:
jerrywwl
2019-04-22 19:51:16 +08:00
parent 5687862c87
commit 50b263f0f3
3 changed files with 24 additions and 2 deletions
+4 -2
View File
@@ -983,8 +983,10 @@ export abstract class RenderPipeline {
this._globalBindings.get(UBOGlobal.BLOCK.name)!.buffer!.update(this._defaultUboGlobal.view.buffer);
const planarShadow = scene.planarShadow;
planarShadow.updateDirLight(scene.mainLight);
this._globalBindings.get(UBOShadow.BLOCK.name)!.buffer!.update(planarShadow.data);
if (planarShadow.enabled) {
planarShadow.updateDirLight(scene.mainLight);
this._globalBindings.get(UBOShadow.BLOCK.name)!.buffer!.update(planarShadow.data);
}
}
protected sceneCulling (view: RenderView) {
+9
View File
@@ -11,6 +11,14 @@ const _qt = new Quat();
export class PlanarShadow {
set enabled (enable: boolean) {
this._enabled = enable;
}
get enabled (): boolean {
return this._enabled;
}
set normal (val: Vec3) {
vec3.copy(this._normal, val);
}
@@ -38,6 +46,7 @@ export class PlanarShadow {
}
protected _scene: RenderScene;
protected _enabled: boolean = false;
protected _normal = new Vec3(0, 1, 0);
protected _distance = 0;
protected _matLight = new Mat4();
+11
View File
@@ -133,6 +133,8 @@ cc.SkyboxInfo = SkyboxInfo;
@ccclass('cc.PlanarShadowInfo')
export class PlanarShadowInfo {
@property
protected _enabled = false;
@property
protected _normal = new Vec3(0, 1, 0);
@property
@@ -142,6 +144,15 @@ export class PlanarShadowInfo {
protected _resource: PlanarShadow | null = null;
@property({ type: Boolean })
set enabled (val: boolean) {
this._enabled = val;
if (this._resource) { this._resource.enabled = val; }
}
get enabled () {
return this._enabled;
}
@property({ type: Vec3 })
set normal (val: Vec3) {
vec3.copy(this._normal, val);