modify ui global uniform (#3932)

This commit is contained in:
zxg0622
2019-02-28 18:49:54 +08:00
committed by Weiliang Wang
parent 1b2edaec93
commit 3c009f1f99
4 changed files with 21 additions and 22 deletions
+10 -15
View File
@@ -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;
}
}
-3
View File
@@ -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) {
+9 -3
View File
@@ -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);
}
}
+2 -1
View File
@@ -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);