example data store
This commit is contained in:
@@ -219,6 +219,14 @@ Behavior:
|
||||
- one designated pass writes the next feedback surface
|
||||
- feedback is previous-frame state, not same-frame pass chaining
|
||||
|
||||
Guardrails:
|
||||
|
||||
- Feedback is best suited to image-like state such as trails, masks, luminance fields, decay maps, and shader-local analysis buffers.
|
||||
- Feedback is not a precise long-term data store. The surface uses `RGBA16F`, so repeated accumulation, exact counters, and tightly packed metadata can drift or clamp over time.
|
||||
- The feedback surface is currently filtered like an image, not configured as strict texel-addressed storage. If you reserve texels as data slots, sample them carefully and do not assume exact CPU-style array semantics.
|
||||
- Each feedback-enabled layer allocates two full-resolution feedback textures for ping-pong state. This increases VRAM use and adds one extra full-frame feedback copy per rendered frame.
|
||||
- In multipass shaders, feedback remains previous-frame state even when a pass also consumes same-frame pass outputs. Do not treat feedback as another same-frame intermediate buffer.
|
||||
|
||||
Single-pass example:
|
||||
|
||||
```json
|
||||
@@ -355,13 +363,16 @@ Color/precision notes:
|
||||
The wrapper provides:
|
||||
|
||||
```slang
|
||||
float4 sampleLayerInput(float2 uv);
|
||||
float4 sampleVideo(float2 uv);
|
||||
float4 sampleSourceHistory(int framesAgo, float2 uv);
|
||||
float4 sampleTemporalHistory(int framesAgo, float2 uv);
|
||||
float4 sampleFeedback(float2 uv);
|
||||
```
|
||||
|
||||
`sampleVideo` samples the live decoded source video.
|
||||
`sampleLayerInput` samples the input arriving at this shader layer before any of the layer's own passes run. If this layer follows another shader, it sees that previous shader's output. If this is the first shader layer, it sees the decoded source image.
|
||||
|
||||
`sampleVideo` samples the current pass input texture. In single-pass shaders this is usually the layer input. In multipass shaders it may instead be a named pass output or `previousPass`, depending on the manifest routing for that pass.
|
||||
|
||||
`sampleSourceHistory` samples previous decoded source frames. `framesAgo` is clamped into the available range. If no history is available, it falls back to `sampleVideo`.
|
||||
|
||||
@@ -379,6 +390,17 @@ float4 shadeVideo(ShaderContext context)
|
||||
}
|
||||
```
|
||||
|
||||
Layer-input example:
|
||||
|
||||
```slang
|
||||
float4 finishPass(ShaderContext context)
|
||||
{
|
||||
float3 baseColor = sampleLayerInput(context.uv).rgb;
|
||||
float3 passResult = context.sourceColor.rgb;
|
||||
return float4(baseColor + passResult * 0.25, 1.0);
|
||||
}
|
||||
```
|
||||
|
||||
Feedback example:
|
||||
|
||||
```slang
|
||||
@@ -413,6 +435,12 @@ In that multipass case:
|
||||
- `finishFrame` receives the same-frame pass output through normal multipass routing
|
||||
- the `writePass` decides which pass output becomes next frame's feedback
|
||||
|
||||
That means:
|
||||
|
||||
- use `context.sourceColor` or `sampleVideo()` when you want this pass's routed input
|
||||
- use `sampleLayerInput()` when you want the pre-pass layer input
|
||||
- use `sampleFeedback()` when you want previous-frame persistent shader-local state
|
||||
|
||||
## Parameters
|
||||
|
||||
Manifest parameters are exposed to Slang as global values with the same `id`.
|
||||
|
||||
Reference in New Issue
Block a user