Level
brightness, contrast and gamma
Gain scales, offset shifts, gamma curves, and invert flips what comes out. Alpha is left alone.
input
out
- Type name
graphics:Level- Plane
graphics- Tags
imagetransform- Language
wgsl- Tier
shader- Bundle
graphics- Source
node-bundles/graphics/Level.wgsl- Availability
- available
Slots
| Slot | Direction | Type | |
|---|---|---|---|
input | input | TEXTURE | |
out | output | TEXTURE |
Parameters
level
| Name | Type | Default | Range | Doc |
|---|---|---|---|---|
gain | float | 1 | 0 … 4 | |
offset | float | 0 | -1 … 1 | |
gamma | float | 1 | 0.1 … 4 | |
invert | bool | false |
common
| Name | Type | Default | Range | Doc |
|---|---|---|---|---|
width | int | 0 | 0 … 8192 | Texture size in pixels; 0 follows the first wired texture input. A node that makes its own frames follows the patch's default instead. |
height | int | 0 | 0 … 8192 | Texture size in pixels; 0 follows the first wired texture input. A node that makes its own frames follows the patch's default instead. |
Source
The current source of this node, as it stands in the goofi repository at node-bundles/graphics/Level.wgsl.
/* goofi
{ "doc": "brightness, contrast and gamma\nGain scales, offset shifts, gamma curves, and invert flips what comes out. Alpha is left alone.",
"tags": ["image", "transform"],
"inputs": [{"name": "input", "kind": "TEXTURE"}],
"params": [
{"group": "level", "name": "gain", "kind": "float", "default": 1.0, "min": 0.0, "max": 4.0},
{"group": "level", "name": "offset", "kind": "float", "default": 0.0, "min": -1.0, "max": 1.0},
{"group": "level", "name": "gamma", "kind": "float", "default": 1.0, "min": 0.1, "max": 4.0},
{"group": "level", "name": "invert", "kind": "bool", "default": false} ] }
*/
fn shade(uv: vec2f) -> vec4f {
let c = textureSample(input, samp, uv);
var rgb = pow(max(c.rgb * p.gain + p.offset, vec3f(0.0)), vec3f(1.0 / p.gamma));
if (p.invert != 0u) {
rgb = 1.0 - rgb;
}
return vec4f(rgb, c.a);
}