# 著色器參數

著色器參數/Shader parameters是著色器類別中的屬性，您可以在編輯器中為使用該著色器創建的材質設置這些屬性。這使您能夠在編輯器中自訂著色器的外觀，並重複使用相同的程式碼來適用於不同的材質。

可以透過在角色類別（actor class）中的屬性上添加 `@Parameter()` 裝飾器來創建參數。參數的類型將根據屬性的型別註解自動推斷。

以下範例展示了目前支援的所有類型：

```typescript
import { rgb, standardMaterial } from "@hology/core/shader-nodes";
import { NodeShader, NodeShaderOutput, Parameter } from "@hology/core/shader/shader";
import { Color, Vector2, Vector3, Color, Euler } from "three";

export class ExampleShader extends NodeShader {
    @Parameter() color: Color = new Color(0xff0000)
    @Parameter() aNumber: number
    @Parameter() aBoolen: boolean
    @Parameter() aString: string
    @Parameter() vec2: Vector2
    @Parameter() vec3: Vector3
    @Parameter() color: Color
    @Parameter() rotation: Euler

    output(): NodeShaderOutput {
        return {
            color: standardMaterial({color: rgb(this.color)})
        }
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hology.app/zh-tw/shaders/zhu-se-qi-can-shu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
