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;

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.

1 participant