Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix renderQueueType error #2437

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/core/src/RenderPipeline/BasicRenderPipeline.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Vector2 } from "@galacean/engine-math";
import { Background } from "../Background";
import { Camera } from "../Camera";
import { Engine } from "../Engine";
import { BackgroundMode } from "../enums/BackgroundMode";
import { BackgroundTextureFillMode } from "../enums/BackgroundTextureFillMode";
import { CameraClearFlags } from "../enums/CameraClearFlags";
Expand Down Expand Up @@ -270,8 +269,10 @@ export class BasicRenderPipeline {
const shaderPass = shaderPasses[i];
const renderState = shaderPass._renderState;
if (renderState) {
renderState._applyRenderQueueByShaderData(shaderPass._renderStateDataMap, subRenderElement.material.shaderData);
renderQueueType = renderState.renderQueueType;
renderQueueType = renderState._getRenderQueueByShaderData(
shaderPass._renderStateDataMap,
subRenderElement.material.shaderData
);
} else {
renderQueueType = renderStates[i].renderQueueType;
}
Expand Down
12 changes: 10 additions & 2 deletions packages/core/src/RenderPipeline/RenderQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,16 @@ export class RenderQueue {
continue;
}

if ((shaderPass._renderState ?? renderStates[j]).renderQueueType !== renderQueueType) {
let renderState = shaderPass._renderState;
let passQueueType: RenderQueueType;
if (renderState) {
passQueueType = renderState._getRenderQueueByShaderData(shaderPass._renderStateDataMap, materialData);
} else {
renderState = renderStates[j];
passQueueType = renderState.renderQueueType;
}

if (passQueueType !== renderQueueType) {
continue;
}

Expand Down Expand Up @@ -163,7 +172,6 @@ export class RenderQueue {
}
}

const renderState = shaderPass._renderState ?? renderStates[j];
renderState._applyStates(
engine,
renderer.entity.transform._isFrontFaceInvert(),
Expand Down
11 changes: 8 additions & 3 deletions packages/core/src/shader/state/RenderState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,15 @@ export class RenderState {
* @internal
* @todo Should merge when we can delete material render state
*/
_applyRenderQueueByShaderData(renderStateDataMap: Record<number, ShaderProperty>, shaderData: ShaderData): void {
_getRenderQueueByShaderData(
renderStateDataMap: Record<number, ShaderProperty>,
shaderData: ShaderData
): RenderQueueType {
const renderQueueType = renderStateDataMap[RenderStateElementKey.RenderQueueType];
if (renderQueueType !== undefined) {
this.renderQueueType = shaderData.getFloat(renderQueueType) ?? RenderQueueType.Opaque;
if (renderQueueType === undefined) {
return this.renderQueueType;
} else {
return shaderData.getFloat(renderQueueType) ?? RenderQueueType.Opaque;
}
}

Expand Down
Loading