diff --git a/cocos/core/root.ts b/cocos/core/root.ts index fc3691c2f5..28b4004d49 100644 --- a/cocos/core/root.ts +++ b/cocos/core/root.ts @@ -151,7 +151,7 @@ export class Root { } for (const view of this._views) { - if (view.camera.isWindowSize && view.priority < 1 << 30) { + if (view.camera.isWindowSize) { view.camera.resize(width, height); } } @@ -238,25 +238,20 @@ export class Root { view.initialize(info); view.camera.resize(cc.game.canvas.width, cc.game.canvas.height); - if (!view.isUI) { - this._views.push(view); - this._views.sort((a: RenderView, b: RenderView) => { - return a.priority - b.priority; - }); - } else { - this._uiViews.push(view); - this._uiViews.sort((a: RenderView, b: RenderView) => { - return a.priority - b.priority; - }); - } + const views = view.isUI ? this._uiViews : this._views; + views.push(view); + views.sort((a: RenderView, b: RenderView) => { + return a.priority - b.priority; + }); return view; } public destroyView (view: RenderView) { - for (let i = 0; i < this._views.length; ++i) { - if (this._views[i] === view) { - this._views.splice(i, 1); + const views = view.isUI ? this._uiViews : this._views; + for (let i = 0; i < views.length; ++i) { + if (views[i] === view) { + views.splice(i, 1); return; } } diff --git a/cocos/pipeline/render-view.ts b/cocos/pipeline/render-view.ts index 55c724f794..fd93b1543d 100644 --- a/cocos/pipeline/render-view.ts +++ b/cocos/pipeline/render-view.ts @@ -33,9 +33,6 @@ export class RenderView { public set priority (val: number) { this._priority = val; - if (this._isUI) { - this._priority |= 1 << 30; - } } public set visibility (vis) { diff --git a/cocos/pipeline/ui/ui-pipeline.ts b/cocos/pipeline/ui/ui-pipeline.ts index 18aa599a62..d334dd295a 100644 --- a/cocos/pipeline/ui/ui-pipeline.ts +++ b/cocos/pipeline/ui/ui-pipeline.ts @@ -1,8 +1,11 @@ import { Root } from '../../core/root'; -import { RenderPassStage } from '../define'; +import { RenderPassStage, UBOGlobal } from '../define'; import { RenderPipeline } from '../render-pipeline'; import { RenderView } from '../render-view'; import { UIFlow } from './ui-flow'; +import { mat4 } from '../../core/vmath'; + +const _mat4Array = new Float32Array(16); export class UIPipeline extends RenderPipeline { @@ -33,7 +36,10 @@ export class UIPipeline extends RenderPipeline { } protected updateUBOs (view: RenderView) { - // view.camera.matViewProj.m14=1E-100; - super.updateUBOs(view); + const camera = view.camera; + mat4.array(_mat4Array, camera.matViewProj); + this._defaultUboGlobal!.view.set(_mat4Array, UBOGlobal.MAT_VIEW_PROJ_OFFSET); + // update ubos + this._globalBindings.get(UBOGlobal.BLOCK.name)!.buffer!.update(this._defaultUboGlobal!.view.buffer); } } diff --git a/cocos/renderer/ui/ui-material.ts b/cocos/renderer/ui/ui-material.ts index 959d64f9f1..be58a65f4f 100644 --- a/cocos/renderer/ui/ui-material.ts +++ b/cocos/renderer/ui/ui-material.ts @@ -39,7 +39,8 @@ export class UIMaterial { this._psos = new Pool(() => { const pso = this._pass!.createPipelineState()!; if (!CC_EDITOR) { - pso.pipelineLayout.layouts[0].bindBuffer(UBOGlobal.BLOCK.binding, cc.director.root.uiPipeline.globalUBO); + pso.pipelineLayout.layouts[0].bindBuffer(UBOGlobal.BLOCK.binding, + cc.director.root.uiPipeline.globalBindings.get(UBOGlobal.BLOCK.name).buffer); } return pso; }, 1);