Added trigger
This commit is contained in:
@@ -187,6 +187,7 @@ Supported types:
|
||||
| `bool` | `bool` | `true` or `false` |
|
||||
| `enum` | `int` | selected option index |
|
||||
| `text` | generated texture/helper | string |
|
||||
| `trigger` | `int <id>`, `float <id>Time` | pulse/count |
|
||||
|
||||
Float example:
|
||||
|
||||
@@ -314,6 +315,26 @@ float4 premultipliedText = drawTitleText(textUv, float4(1.0, 1.0, 1.0, 1.0));
|
||||
|
||||
Text is currently limited to printable ASCII. `maxLength` defaults to `64` and is clamped to `1..256`. The optional `font` field references a packaged font declared in `fonts`; if no font is specified, the runtime uses its fallback sans-serif renderer.
|
||||
|
||||
Trigger example:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "flash",
|
||||
"label": "Flash",
|
||||
"type": "trigger"
|
||||
}
|
||||
```
|
||||
|
||||
A trigger appears as a button in the control UI. Pressing it increments the shader-visible integer `flash` and records the runtime time in `flashTime`:
|
||||
|
||||
```slang
|
||||
float age = context.time - flashTime;
|
||||
float intensity = flash > 0 ? exp(-age * 5.0) : 0.0;
|
||||
color.rgb += intensity;
|
||||
```
|
||||
|
||||
Triggers are useful for one-shot shader reactions such as flashes, ripples, cuts, or randomized looks. They do not execute arbitrary CPU code; they only update uniforms consumed by the shader.
|
||||
|
||||
Parameter validation:
|
||||
|
||||
- Float values are clamped to `min`/`max` if provided.
|
||||
@@ -321,6 +342,7 @@ Parameter validation:
|
||||
- `color` must have exactly 4 numbers.
|
||||
- Enum defaults must match one of the declared option values.
|
||||
- Text defaults must be strings. Non-printable characters are dropped and values are clamped to `maxLength`.
|
||||
- Trigger values are incremented by the host when triggered. The shader sees the trigger count and last trigger time.
|
||||
- Non-finite numeric values are rejected.
|
||||
|
||||
## Texture Assets
|
||||
|
||||
Reference in New Issue
Block a user