mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-06 03:22:39 +08:00
fix planar reflection update submodel macro patches (#15316)
This commit is contained in:
@@ -515,7 +515,7 @@ export class Pass {
|
||||
* @zh 结合指定的编译宏组合获取当前 Pass 的 Shader Variant
|
||||
* @param patches The macro patches
|
||||
*/
|
||||
public getShaderVariant (patches: IMacroPatch[] | null = null): Shader | null {
|
||||
public getShaderVariant (patches: Readonly<IMacroPatch[] | null> = null): Shader | null {
|
||||
if (!this._shader && !this.tryCompile()) {
|
||||
console.warn('pass resources incomplete');
|
||||
return null;
|
||||
|
||||
@@ -337,7 +337,7 @@ export class Shadows {
|
||||
* @param patches The macro patches for the shader
|
||||
* @returns The shader for the planar shadow
|
||||
*/
|
||||
public getPlanarShader (patches: IMacroPatch[] | null): Shader | null {
|
||||
public getPlanarShader (patches: Readonly<IMacroPatch[] | null>): Shader | null {
|
||||
if (!this._material) {
|
||||
this._material = new Material();
|
||||
this._material.initialize({ effectName: 'pipeline/planar-shadow' });
|
||||
|
||||
@@ -159,7 +159,7 @@ export class SubModel {
|
||||
* @en The macro patches for the shaders
|
||||
* @zh 着色器程序所用的宏定义组合
|
||||
*/
|
||||
get patches (): IMacroPatch[] | null {
|
||||
get patches (): Readonly<IMacroPatch[] | null> {
|
||||
return this._patches;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ export class RenderReflectionProbeQueue {
|
||||
private _shaderArray: Shader[] = [];
|
||||
private _rgbeSubModelsArray: SubModel[]=[]
|
||||
private _instancedQueue: RenderInstancedQueue;
|
||||
private _patches: IMacroPatch[] = [];
|
||||
|
||||
public constructor (pipeline: PipelineRuntime) {
|
||||
this._pipeline = pipeline;
|
||||
@@ -151,12 +152,13 @@ export class RenderReflectionProbeQueue {
|
||||
const batchingScheme = pass.batchingScheme;
|
||||
|
||||
if (!bUseReflectPass) {
|
||||
let patches: IMacroPatch[] | null = subModel.patches;
|
||||
this._patches = [];
|
||||
this._patches = this._patches.concat(subModel.patches!);
|
||||
const useRGBEPatchs: IMacroPatch[] = [
|
||||
{ name: CC_USE_RGBE_OUTPUT, value: true },
|
||||
];
|
||||
patches = patches ? patches.concat(useRGBEPatchs) : useRGBEPatchs;
|
||||
subModel.onMacroPatchesStateChanged(patches);
|
||||
this._patches = this._patches.concat(useRGBEPatchs);
|
||||
subModel.onMacroPatchesStateChanged(this._patches);
|
||||
this._rgbeSubModelsArray.push(subModel);
|
||||
}
|
||||
|
||||
@@ -199,18 +201,19 @@ export class RenderReflectionProbeQueue {
|
||||
}
|
||||
public resetRGBEMacro () {
|
||||
for (let i = 0; i < this._rgbeSubModelsArray.length; i++) {
|
||||
this._patches = [];
|
||||
const subModel = this._rgbeSubModelsArray[i];
|
||||
// eslint-disable-next-line prefer-const
|
||||
let patches: IMacroPatch[] | null = subModel.patches;
|
||||
if (!patches) continue;
|
||||
for (let j = 0; j < patches.length; j++) {
|
||||
const patch = patches[j];
|
||||
this._patches = this._patches.concat(subModel.patches!);
|
||||
if (!this._patches) continue;
|
||||
for (let j = 0; j < this._patches.length; j++) {
|
||||
const patch = this._patches[j];
|
||||
if (patch.name === CC_USE_RGBE_OUTPUT) {
|
||||
patches.splice(j, 1);
|
||||
this._patches.splice(j, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
subModel.onMacroPatchesStateChanged(patches);
|
||||
subModel.onMacroPatchesStateChanged(this._patches);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user