Files
cocos4/cocos/core/renderer/models/morph-model.ts
T
Yun Hsiao Wu dfc3d141f2 GFX Descriptor Set (#7101)
* gfx: descriptor sets

* gfx: descriptor set, singular

* better structure

* adapt upper layers: first pass

finally all compiler errors cleared.

OKAY IT'S HAPPENING EVERYBODY STAY THE ****ING CALM

* adapt upper layers: second pass

THERE AND BACK AGAIN

* unified light pass & shadow shader

* gfx: descriptor set & pipeline layout

* light pass: better structure

* light pass: dynamic uniform

* even more type checking for memory pools

* Fix particleSystem and lineComponent.

* delete comment

* guard pool init param

* Fix trail module error.

* delete space

* light pass: instancing & batching support

* don't polyfill gfx stuff inside EffectAsset

* better light pass structure

* fix spot light culling

Co-authored-by: caryliu <caryliu1999@gmail.com>
2020-08-13 18:21:15 +08:00

55 lines
1.8 KiB
TypeScript

import { Model } from '../scene/model';
import { MorphRenderingInstance } from '../../assets/morph';
import { Material } from '../../assets/material';
import { RenderingSubMesh } from '../../assets/mesh';
import { GFXDescriptorSet } from '../../gfx';
export class MorphModel extends Model {
private _morphRenderingInstance: MorphRenderingInstance | null = null;
private _usedMaterials = new Set<Material>();
public getMacroPatches (subModelIndex: number) : any {
if (this._morphRenderingInstance) {
return this._morphRenderingInstance.requiredPatches(subModelIndex);
} else {
return undefined;
}
}
public initSubModel (subModelIndex: number, subMeshData: RenderingSubMesh, material: Material) {
return super.initSubModel(
subModelIndex,
subMeshData,
this._launderMaterial(material),
);
}
public setSubModelMaterial (subModelIndex: number, material: Material) {
return super.setSubModelMaterial(subModelIndex, this._launderMaterial(material));
}
protected _updateLocalDescriptors (submodelIdx: number, descriptorSet: GFXDescriptorSet) {
super._updateLocalDescriptors(submodelIdx, descriptorSet);
if (this._morphRenderingInstance) {
this._morphRenderingInstance.adaptPipelineState(submodelIdx, descriptorSet);
}
}
private _launderMaterial (material: Material) {
return material;
// if (this._usedMaterials.has(material)) {
// return new MaterialInstance({
// parent: material,
// });
// } else {
// this._usedMaterials.add(material);
// return material;
// }
}
public setMorphRendering (morphRendering: MorphRenderingInstance) {
this._morphRenderingInstance = morphRendering;
}
}