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

[Document] enhance material document #2546

Merged
merged 3 commits into from
Mar 31, 2025

Conversation

zhuxudong
Copy link
Member

@zhuxudong zhuxudong commented Feb 10, 2025

enhance #2540

Summary by CodeRabbit

  • Documentation
    • Reorganized Chinese graphics guides for improved clarity.
    • Added new pages covering material overview, built-in shaders, material creation examples, custom shaders, shader data, ShaderLab syntax, SubShaders, and built-in variables.
    • Updated hyperlinks and cross-references to enhance navigation.
    • Removed outdated documentation sections to streamline the user experience.

@zhuxudong zhuxudong added documentation Improvements or additions to documentation rendering Rendering related functions labels Feb 10, 2025
@zhuxudong zhuxudong requested review from Sway007 and hhhhkrx February 10, 2025 09:42
Copy link

coderabbitai bot commented Feb 10, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request updates the Chinese graphics documentation by modifying JSON metadata, removing outdated documentation files, and adding new guides. Modifications include the removal of obsolete keys and files, the replacement of metadata keys for materials, and updates to hyperlinks and titles. Additionally, a minor code change in the post-process module now disables depth testing and writing in the constructor.

Changes

File(s) Change Summary
docs/zh/graphics/_meta.json, docs/zh/graphics/material/_meta.json, docs/zh/graphics/material/builtinShaders/_meta.json JSON Metadata updates: Removed the "shader" entry and outdated keys (e.g., "material", "composition", "editor", "script", "intro") and added new keys such as "overview", "examples", "builtinShaders", "shaderLab", and "variables".
docs/zh/graphics/material/composition.md, docs/zh/graphics/material/editor.md, docs/zh/graphics/material/material.md, docs/zh/graphics/material/script.md, docs/zh/graphics/shader/_meta.json, docs/zh/graphics/shader/assets.mdx, docs/zh/graphics/shader/builtins/intro.mdx, docs/zh/graphics/shader/class.mdx, docs/zh/graphics/shader/custom.md, docs/zh/graphics/shader/intro.mdx, docs/zh/graphics/shader/shaderLab/_meta.json, docs/zh/graphics/shader/shaderLab/create.mdx, docs/zh/graphics/shader/shaderLab/intro.md, docs/zh/graphics/shader/shaderLab/syntax/intro.mdx, docs/zh/graphics/shader/shaderLab/syntax/subShader.mdx, docs/zh/graphics/shader/shaderLab/usage.md Documentation Removal: Deleted multiple outdated files in the material and shader sections.
docs/zh/graphics/material/examples/_meta.json, docs/zh/graphics/material/examples/builtin.mdx, docs/zh/graphics/material/examples/create.mdx, docs/zh/graphics/material/examples/custom.mdx, docs/zh/graphics/material/examples/shaderData.mdx, docs/zh/graphics/material/overview.mdx, docs/zh/graphics/material/shaderLab/intro.mdx, docs/zh/graphics/material/shaderLab/subShader.mdx, docs/zh/graphics/material/variables.mdx New Documentation Additions: Introduced new metadata and content pages for material examples, a material overview, ShaderLab syntax, SubShader details, and built-in shader variables.
docs/zh/graphics/material/builtinShaders/blinnPhong.md, docs/zh/graphics/material/examples/custom.mdx, docs/zh/graphics/material/shaderLab/pass.mdx, docs/zh/graphics/postProcess/customPostProcess.mdx Content Updates: Adjusted hyperlinks, revised titles (e.g., from "Shader API【实验]" to "自定义着色器"), and modified the post-process constructor to disable depth testing and writing.

Sequence Diagram(s)

sequenceDiagram
    participant CP as CustomPass Constructor
    participant DS as DepthState
    CP->>DS: Set enabled = false
    CP->>DS: Set writeEnabled = false
    Note over CP,DS: Blit operation now ignores depth info
Loading

Possibly related PRs

Suggested labels

enhancement, shader

Suggested reviewers

  • cptbtptpbcptdtptp

Poem

In a garden of docs where changes abound,
I hop through lines of code and text profound.
Out with the old keys, in with a bright view,
Metadata polished, new guides shine through.
Rabbit hops with glee, for progress is found!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8f960f8 and cbf9ab6.

📒 Files selected for processing (31)
  • docs/zh/graphics/_meta.json (0 hunks)
  • docs/zh/graphics/material/_meta.json (1 hunks)
  • docs/zh/graphics/material/builtinShaders/_meta.json (1 hunks)
  • docs/zh/graphics/material/builtinShaders/blinnPhong.md (1 hunks)
  • docs/zh/graphics/material/composition.md (0 hunks)
  • docs/zh/graphics/material/editor.md (0 hunks)
  • docs/zh/graphics/material/examples/_meta.json (1 hunks)
  • docs/zh/graphics/material/examples/builtin.mdx (1 hunks)
  • docs/zh/graphics/material/examples/create.mdx (1 hunks)
  • docs/zh/graphics/material/examples/custom.mdx (4 hunks)
  • docs/zh/graphics/material/examples/shaderData.mdx (1 hunks)
  • docs/zh/graphics/material/material.md (0 hunks)
  • docs/zh/graphics/material/overview.mdx (1 hunks)
  • docs/zh/graphics/material/script.md (0 hunks)
  • docs/zh/graphics/material/shaderLab/intro.mdx (1 hunks)
  • docs/zh/graphics/material/shaderLab/pass.mdx (1 hunks)
  • docs/zh/graphics/material/shaderLab/subShader.mdx (1 hunks)
  • docs/zh/graphics/material/variables.mdx (1 hunks)
  • docs/zh/graphics/postProcess/customPostProcess.mdx (1 hunks)
  • docs/zh/graphics/shader/_meta.json (0 hunks)
  • docs/zh/graphics/shader/assets.mdx (0 hunks)
  • docs/zh/graphics/shader/builtins/intro.mdx (0 hunks)
  • docs/zh/graphics/shader/class.mdx (0 hunks)
  • docs/zh/graphics/shader/custom.md (0 hunks)
  • docs/zh/graphics/shader/intro.mdx (0 hunks)
  • docs/zh/graphics/shader/shaderLab/_meta.json (0 hunks)
  • docs/zh/graphics/shader/shaderLab/create.mdx (0 hunks)
  • docs/zh/graphics/shader/shaderLab/intro.md (0 hunks)
  • docs/zh/graphics/shader/shaderLab/syntax/intro.mdx (0 hunks)
  • docs/zh/graphics/shader/shaderLab/syntax/subShader.mdx (0 hunks)
  • docs/zh/graphics/shader/shaderLab/usage.md (0 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Feb 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.03%. Comparing base (8f960f8) to head (cbf9ab6).
Report is 61 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2546      +/-   ##
==========================================
+ Coverage   68.58%   69.03%   +0.44%     
==========================================
  Files         961      961              
  Lines      100219   100219              
  Branches     8591     8591              
==========================================
+ Hits        68739    69189     +450     
+ Misses      31220    30770     -450     
  Partials      260      260              
Flag Coverage Δ
unittests 69.03% <ø> (+0.44%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


参考[模型的导入和使用](/docs/graphics/model/use/)教程,我们可以先将模型导入到编辑器,一般情况下,模型已经自动绑定好材质,用户可以不用做任何操作;

### 2.1. Remap 材质
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • remap 材质这部分可以写得更详细一些
  • 增量修改这块需要补充一篇新的文档,此处指向增量修改的文档

{
"create": { "title": "创建材质" },
"builtin": { "title": "使用内置着色器" },
"custom": { "title": "自定义着色器" },
Copy link
Collaborator

Choose a reason for hiding this comment

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

要么把下面改成「使用自定义着色器」,要么把上面改成「内置着色器」

@cptbtptpbcptdtptp
Copy link
Collaborator

整体缺少一篇「调试材质效果」的文档,介绍如何整体的步骤,内容应该是我们推荐他们如何去快速排查着色器的错误,以及调试得到自己想要的效果

src="https://gw.alipayobjects.com/zos/OasisHub/6351fa81-5159-4469-bd95-8f21a8f2f4ac/image-20250124162909194.png"
style={{ zoom: "50%" }}
/>

默认的 Unlit 模板已经内置了蒙皮计算和 Shadow Pass,可以看到骨骼动画和阴影都能正常渲染:
Copy link
Collaborator

Choose a reason for hiding this comment

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

这部分文字内容有点难啃,如果是用表格展示则会简单很多,Unlit 内置的能力,PBR 内置的能力,开发者一眼就能知道自己要用哪种模版


## 语法标准

`ShaderLab` 语法骨架如下:
Copy link
Collaborator

@cptbtptpbcptdtptp cptbtptpbcptdtptp Mar 31, 2025

Choose a reason for hiding this comment

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

总览要说明这个东西是什么,干啥用的,

  • 这里直接丢两段代码,体验不太好
  • 总览需要有启下的作用,这里和后文的关系太含蓄了


## UsePass

如果一个 `SubShader` 包含多个 `Pass`,可以通过 `UsePass` 指令复用其他 `Pass` 对象,比如引擎内置的 PBR Pass: `UsePass "pbr/Default/Forward"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

其实可以更开放点,

  • 比如文档名就是如何在 ShaderLab 中写多 pass
  • 如何定义渲染状态,全局的,局部的
    比这样扎堆写一起,让开发者查字典要好很多

@@ -53,7 +53,7 @@ vec3 u_lightDir;

## varying 变量声明

通过定义顶点着色器出参[结构体](/docs/graphics/shader/shaderLab/syntax/shader/#结构体函数)和片元着色器入参结构体指定
通过定义顶点着色器出参[结构体](/docs/graphics/material/shaderLab/shader/#结构体函数)和片元着色器入参结构体指定
Copy link
Collaborator

Choose a reason for hiding this comment

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

同理,如何声明变量

  • 声明 varying 变量
  • ……

title: 内置变量
---

Shader 代码中会经常用到内置变量,一种是**逐顶点**的 `attribute` 变量,另一种是**逐 shader** 的 `uniform` 变量。
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里描述的其实是,引擎中有哪些内置变量?
可以加一下如何使用内置变量,那么这篇文档的名字就变成了,着色器中如何使用内置变量


## Tags

ShaderLab 中可以通过 `Tags` 指令直接声明和指定,无须通过 `SubShader.setTag` api 方式手动指定。
Copy link
Collaborator

Choose a reason for hiding this comment

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

感觉说了又好像没说

Copy link
Collaborator

@cptbtptpbcptdtptp cptbtptpbcptdtptp left a comment

Choose a reason for hiding this comment

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

+1

@zhuxudong zhuxudong marked this pull request as ready for review March 31, 2025 07:44
@cptbtptpbcptdtptp cptbtptpbcptdtptp merged commit 3242f89 into galacean:main Mar 31, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation rendering Rendering related functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants