Skip to content

Conversation

@HardyNLee
Copy link
Contributor

介绍

恢复 alphaFilterVal ,即之前的 alpha 滤镜方案。

您可能会注意到我没有恢复 setEffect 以前转化 alpha 的逻辑,因为我实际测试它反而会有点问题,只要保证 updateEffect 之前处理好应该就行。 我检查了所有 updateEffect ,应该是不会出问题的。

fix #829

  • 我排查了很久,最终直到 bevelFilter 里打印属性都是没有问题的,那么问题只可能出在 uSampler 缺失,我有点怀疑又是 pixi container alpha 整活,至少恢复到滤镜方案后,我再没测出类似问题

fix #830

  • pixi container alpha 为 0 时不调用 _render,因此动作表情,还要其他的一些东西都没有得到更新。

fix #831

  • 因为pixi container alpha 在前,影响了泛光滤镜的输入,在最后才应用 alpha 滤镜可以规避这个问题。

@gemini-code-assist
Copy link

Summary of Changes

Hello @HardyNLee, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求旨在通过恢复和优化 alpha 滤镜方案来解决多个与 PIXI.js 容器透明度相关的渲染问题。通过引入一个专用的 PIXI.filters.AlphaFilter 并将其作为内部滤镜管理,本更改规避了 PIXI 容器原生 alpha 属性在特定情况下导致的渲染跳过、滤镜顺序冲突以及其他视觉异常。这一调整确保了透明度控制的稳定性和一致性,尤其是在动画和复杂滤镜效果的应用中。

Highlights

  • 恢复 Alpha 滤镜方案: 重新引入并使用 PIXI.filters.AlphaFilter 来管理容器的透明度,替代直接修改 PIXI.Container 的原生 alpha 属性。
  • 解决渲染问题: 修复了当 PIXI.Containeralpha 属性为 0 时,_render 方法不被调用导致动作表情等内容无法更新的问题(fix alpha 为 0 时,live2d 的动作表情被冻结 #830),以及 uSampler 缺失导致的渲染异常(fix 图片立绘第一次出场时,倒角滤镜高概率出错 #829)。
  • 优化滤镜层级: 确保 alpha 滤镜在所有其他滤镜之后应用,解决了原生 alpha 属性应用过早影响泛光滤镜输入的问题(fix alpha 值影响泛光阈值效果 #831)。
  • 统一动画透明度控制: 所有涉及透明度变化的动画(如时间轴动画、渐入渐出动画)现在都通过新的 alphaFilterVal 属性进行控制,以保持一致性并利用新的滤镜方案。

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

本次 PR 恢复了 alphaFilter 方案来处理透明度,以解决 PIXI.Containeralpha 属性为 0 时导致渲染跳过和子节点更新停止的问题。这个改动方向是正确的,并且解决了相关 issue 中描述的滤镜顺序问题。

代码的整体改动是有效的,但在几个文件中使用了 @ts-ignore 和动态属性赋值,这会影响代码的类型安全和长期可维护性。我在具体的 review comments 中提供了一些建议,通过使用类型断言来改善这些问题,使代码更清晰和健壮。

Comment on lines 23 to 26
// 处理 alphaL
// @ts-ignore
segment['alphaFilterVal'] = segment.alpha;
segment.alpha = 1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

通过 @ts-ignore 和字符串索引 segment['alphaFilterVal'] 来动态添加属性,会绕过 TypeScript 的类型检查,降低了代码的可读性和类型安全性。建议使用类型断言来代替,这样能更清晰地表达代码意图,也便于未来维护。

另外,第23行的注释 // 处理 alphaL 中存在一个拼写错误,应为 // 处理 alpha

Suggested change
// 处理 alphaL
// @ts-ignore
segment['alphaFilterVal'] = segment.alpha;
segment.alpha = 1;
// 处理 alpha
// 通过类型断言来动态添加属性,避免使用 @ts-ignore
(segment as any).alphaFilterVal = segment.alpha;
segment.alpha = 1;

Comment on lines 124 to 126
// @ts-ignore
newTransform['alphaFilterVal'] = effect.transform.alpha;
newTransform.alpha = 1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

timeline.ts 中的情况类似,这里使用 @ts-ignore 和字符串索引来动态添加 alphaFilterVal 属性,这会降低代码的类型安全性和可维护性。为了使代码更健壮和清晰,建议使用类型断言。

Suggested change
// @ts-ignore
newTransform['alphaFilterVal'] = effect.transform.alpha;
newTransform.alpha = 1;
// 通过类型断言来动态添加属性,避免使用 @ts-ignore
(newTransform as any).alphaFilterVal = effect.transform.alpha;
newTransform.alpha = 1;

@MakinoharaShoko
Copy link
Member

https://github.com/HardyNLee/WebGAL/blob/a1d6a702d0ad32030d96ed4e9b50f672e8646229/packages/webgal/src/Stage/MainStage/useSetEffects.ts#L13

此处的恢复 effect 的逻辑,是否对 alphaFilter 做了处理,我似乎没有看到相关变更

@OpenWebGAL OpenWebGAL deleted a comment Jan 17, 2026
@HardyNLee
Copy link
Contributor Author

https://github.com/HardyNLee/WebGAL/blob/a1d6a702d0ad32030d96ed4e9b50f672e8646229/packages/webgal/src/Stage/MainStage/useSetEffects.ts#L13

此处的恢复 effect 的逻辑,是否对 alphaFilter 做了处理,我似乎没有看到相关变更

正如我在上面所说,由于已经从源头,即 updateEffect 前已经处理了 alphaFilterVal, 就没有必要再在useSetEffects里做转换了。

或者换种说法,我已经在 timeline 里预处理了 alphaFilterVal = alpha; alpha = 1; ,并且进行 updateEffect ,这时 useSetEffects 再进行 {...transform, alphaFilterVal: alpha} ,反而会把 alpha:1 给到 alphaFilterVal。同样的,setEndState 那边的 updateEffect 也是一样的,它也是从 timeline 里取的。

所以只要 timeline 处理好了,updateEffect 前就是转换好的,就不需要在 useSetEffects 再处理一次。并且由于存进 state 就是处理后的,存档也肯定是处理后的,resetState 也不需要担心

@MakinoharaShoko
Copy link
Member

image

这种做法会导致存档中直接存储 alphaFilterVal 的数值。我的看法是,我们只在最后应用到 PixiContainer 的时候进行转换,将影响控制在渲染模块。

@HardyNLee HardyNLee force-pushed the fix/resume-alpha-filter branch from a1d6a70 to a42e102 Compare January 18, 2026 08:32
@HardyNLee
Copy link
Contributor Author

这种做法会导致存档中直接存储 alphaFilterVal 的数值。我的看法是,我们只在最后应用到 PixiContainer 的时候进行转换,将影响控制在渲染模块。

已修改

@MakinoharaShoko MakinoharaShoko merged commit f159ed6 into OpenWebGAL:dev Jan 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants