refactor: unify shader file extension from .gs/.gsl to .shader (#2951)

refactor: Align with Unity convention by using .shader as the standard extension
for Galacean shader files instead of .gs/.gsl.
This commit is contained in:
ChenMo
2026-04-01 23:19:50 +08:00
committed by GitHub
parent b5614679ec
commit e9bea5b32a
11 changed files with 14 additions and 14 deletions

View File

@@ -24,14 +24,14 @@ For more information about the code editor, please check [Code Editor](/en/docs/
After creating a script asset in the scene editor, double-click the script to open the code editor. Scripts in Galacean need to be written in [Typescript](https://www.typescriptlang.org/), and new scripts are created based on built-in templates by default. Additionally, the Galacean code editor is based on Monaco, with shortcuts similar to VSCode. After modifying the script, press `Ctrl/⌘ + S` to save, and the real-time preview area on the right will show the latest scene effects.
> Tip: The Galacean code editor currently supports `.ts`, `.gs`, and `.glsl` file editing.
> Tip: The Galacean code editor currently supports `.ts`, `.shader`, and `.glsl` file editing.
## File Preview
<Image src="https://mdn.alipayobjects.com/huamei_fvsq9p/afts/img/A*o51FQa9Uh0MAAAAAAAAAAAAADqiTAQ/original" />
1. **File Search** Quickly search for files in the project
2. **Code Filter** Whether to display only code files ( `.ts`, `.gs`, `.glsl` ) in the file tree
2. **Code Filter** Whether to display only code files ( `.ts`, `.shader`, `.glsl` ) in the file tree
3. **Built-in Files** Used to display which files are non-editable internal files
4. **Expand/Hide** Toggle the expansion or hiding of folders
5. **Code Files** Editable code files will display corresponding file type thumbnails

View File

@@ -24,14 +24,14 @@ Galacean Editor 提供了一个功能强大的代码编辑器,提供了代码
在场景编辑器中创建脚本资产后双击该脚本即可打开代码编辑器。Galacean 中的脚本需使用 [Typescript](https://www.typescriptlang.org/) 语言编写同时新脚本默认基于内置模板创建。另外Galacean 的代码编辑器基于 Monaco快捷键与 VSCode 类似。修改脚本后,按 `Ctrl/⌘ + S` 保存,右侧实时预览区展现最新场景效果。
> 提示Galacean 代码编辑器目前支持 `.ts` `.gs` 和 `.glsl` 的文件编辑
> 提示Galacean 代码编辑器目前支持 `.ts` `.shader` 和 `.glsl` 的文件编辑
## 文件预览
<Image src="https://mdn.alipayobjects.com/huamei_fvsq9p/afts/img/A*o51FQa9Uh0MAAAAAAAAAAAAADqiTAQ/original" />
1. **文件搜索** 可快速搜索项目中的文件
2. **代码筛选** 文件树是否仅显示代码文件 ( `.ts` `.gs` `.glsl` )
2. **代码筛选** 文件树是否仅显示代码文件 ( `.ts` `.shader` `.glsl` )
3. **内置文件** 用来显示哪些文件是不可编辑的内部文件
4. **展开/隐藏** 可切换文件夹的展开或隐藏
5. **代码文件** 可编辑的代码文件会显示对应的文件类型的缩略图标

View File

@@ -9,7 +9,7 @@ import { initScreenshot, updateForE2E } from "./.mockForE2E";
const shaderLab = new ShaderLab();
const shaderSource = `Shader "/custom.gs" {
const shaderSource = `Shader "/custom.shader" {
SubShader "Default" {
UsePass "pbr/Default/ShadowCaster"

View File

@@ -9,7 +9,7 @@ import {
} from "@galacean/engine-core";
import { ShaderChunkLoader } from "./ShaderChunkLoader";
@resourceLoader(AssetType.Shader, ["gs", "gsl"])
@resourceLoader(AssetType.Shader, ["shader"])
class ShaderLoader extends Loader<Shader> {
private static _builtinRegex = /^\s*\/\/\s*@builtin\s+(\w+)/;

View File

@@ -3,7 +3,7 @@ declare module "*.glsl" {
export default value;
}
declare module "*.gs" {
declare module "*.shader" {
const value: string;
export default value;
}

View File

@@ -3,7 +3,7 @@ import Common from "./Common.glsl";
import Fog from "./Fog.glsl";
import Light from "./Light.glsl";
import Normal from "./Normal.glsl";
import PBRSource from "./PBR.gs";
import PBRSource from "./PBR.shader";
import Shadow from "./Shadow.glsl";
import ShadowSampleTent from "./ShadowSampleTent.glsl";
import Skin from "./Skin.glsl";

View File

@@ -3,7 +3,7 @@ declare module "*.glsl" {
export default value;
}
declare module "*.gs" {
declare module "*.shader" {
const value: string;
export default value;
}

View File

@@ -35,7 +35,7 @@ function compressShader(code) {
export default function glsl(userOptions = {}) {
const options = Object.assign(
{
include: ["**/*.vs", "**/*.fs", "**/*.vert", "**/*.frag", "**/*.glsl"]
include: ["**/*.vs", "**/*.fs", "**/*.vert", "**/*.frag", "**/*.glsl", "**/*.shader"]
},
userOptions
);

View File

@@ -32,7 +32,7 @@ const extensions = [".js", ".jsx", ".ts", ".tsx"];
const mainFields = NODE_ENV === "development" ? ["debug", "module", "main"] : undefined;
const glslPlugin = glsl({
include: [/\.(glsl|gs)$/],
include: [/\.(glsl|shader)$/],
compress: false
});
@@ -90,7 +90,7 @@ function config({ location, pkgJson, verboseMode }) {
glslifyPluginIdx,
1,
glsl({
include: [/\.(glsl|gs)$/],
include: [/\.(glsl|shader)$/],
compress: true
})
);
@@ -157,7 +157,7 @@ function config({ location, pkgJson, verboseMode }) {
glslifyPluginIdx,
1,
glsl({
include: [/\.(glsl|gs)$/],
include: [/\.(glsl|shader)$/],
compress: true
})
);

View File

@@ -1,4 +1,4 @@
Shader "/mrt-test.gs" {
Shader "/mrt-test.shader" {
SubShader "Default" {