8000 Fix `ColorWriteMask` property type of `BlendState` in ShaderLab by Sway007 · Pull Request #2651 · galacean/engine · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix ColorWriteMask property type of BlendState in ShaderLab #2651

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion docs/zh/graphics/material/shaderLab/global.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ title: 全局变量声明
SourceAlphaBlendFactor: BlendFactor.XXX;
DestinationColorBlendFactor: BlendFactor.XXX;
DestinationAlphaBlendFactor: BlendFactor.XXX;
ColorWriteMask: float // 0xffffffff
ColorWriteMask: ColorWriteMask.XXX;
BlendColor: vec4;
AlphaToCoverage: bool;
}
Expand Down
1 change: 1 addition & 0 deletions packages/shader-lab/src/common/Keywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,6 @@ export enum EKeyword {
GS_CompareFunction,
GS_StencilOperation,
GS_CullMode,
GS_ColorWriteMask,
GS_UsePass
}
1 change: 1 addition & 0 deletions packages/shader-lab/src/contentParser/KeywordMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ export const KeywordMap = new Map([
["true", EKeyword.TRUE],
["false", EKeyword.FALSE],
["UsePass", EKeyword.GS_UsePass],
["ColorWriteMask", EKeyword.GS_ColorWriteMask],
["Color", EKeyword.GS_Color]
]);
11 changes: 10 additions & 1 deletion packages/shader-lab/src/contentParser/ShaderContentParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
BlendOperation,
BlendFactor,
CullMode,
ColorWriteMask,
Logger
} from "@galacean/engine";
import {
Expand Down Expand Up @@ -52,7 +53,15 @@ const RenderStateType = [
* @internal
*/
export class ShaderContentParser {
static _engineType = { RenderQueueType, CompareFunction, StencilOperation, BlendOperation, BlendFactor, CullMode };
static _engineType = {
RenderQueueType,
CompareFunction,
StencilOperation,
BlendOperation,
BlendFactor,
CullMode,
ColorWriteMask
};

static _errors: GSError[] = [];

Expand Down
3 changes: 2 additions & 1 deletion tests/src/shader-lab/ShaderLab.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
BlendOperation,
ColorWriteMask,
CompareFunction,
CullMode,
RenderStateDataKey,
Expand Down Expand Up @@ -187,7 +188,7 @@ describe("ShaderLab", () => {
[RenderStateDataKey.StencilStateCompareFunctionFront]: CompareFunction.Less,
// Blend State
[RenderStateDataKey.BlendStateEnabled0]: true,
[RenderStateDataKey.BlendStateColorWriteMask0]: 0.8,
[RenderStateDataKey.BlendStateColorWriteMask0]: ColorWriteMask.None,
[RenderStateDataKey.BlendStateAlphaBlendOperation0]: BlendOperation.Max,

// Depth State
Expand Down
2 changes: 1 addition & 1 deletion tests/src/shader-lab/shaders/demo.shader
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ Shader "Water" {
BlendState {
SourceAlphaBlendFactor = material_SrcBlend;
Enabled[0] = true;
ColorWriteMask[0] = 0.8;
BlendColor = Color(1.0, 1.0, 1.0, 1.0);
AlphaBlendOperation = BlendOperation.Max;
ColorWriteMask = ColorWriteMask.None;
}

UsePass "pbr/Default/Forward"
Expand Down
Loading
0