mirror of
https://github.com/galacean/engine.git
synced 2026-06-01 00:05:56 +08:00
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:
@@ -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
|
||||
|
||||
@@ -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. **代码文件** 可编辑的代码文件会显示对应的文件类型的缩略图标
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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+)/;
|
||||
|
||||
|
||||
2
packages/shader/src/global.d.ts
vendored
2
packages/shader/src/global.d.ts
vendored
@@ -3,7 +3,7 @@ declare module "*.glsl" {
|
||||
export default value;
|
||||
}
|
||||
|
||||
declare module "*.gs" {
|
||||
declare module "*.shader" {
|
||||
const value: string;
|
||||
export default value;
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
2
packages/ui/src/shader/global.d.ts
vendored
2
packages/ui/src/shader/global.d.ts
vendored
@@ -3,7 +3,7 @@ declare module "*.glsl" {
|
||||
export default value;
|
||||
}
|
||||
|
||||
declare module "*.gs" {
|
||||
declare module "*.shader" {
|
||||
const value: string;
|
||||
export default value;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
@@ -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
|
||||
})
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Shader "/mrt-test.gs" {
|
||||
Shader "/mrt-test.shader" {
|
||||
|
||||
SubShader "Default" {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user