Working
This commit is contained in:
50
shaders/studio-color/shader.json
Normal file
50
shaders/studio-color/shader.json
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"id": "studio-color",
|
||||
"name": "Studio Color",
|
||||
"description": "A built-in sample shader package that demonstrates the runtime parameter contract.",
|
||||
"category": "Built-in",
|
||||
"entryPoint": "shadeVideo",
|
||||
"parameters": [
|
||||
{
|
||||
"id": "brightness",
|
||||
"label": "Brightness",
|
||||
"type": "float",
|
||||
"default": 1.0,
|
||||
"min": 0.0,
|
||||
"max": 2.0,
|
||||
"step": 0.01
|
||||
},
|
||||
{
|
||||
"id": "offset",
|
||||
"label": "Offset",
|
||||
"type": "vec2",
|
||||
"default": [0.0, 0.0],
|
||||
"min": [-0.2, -0.2],
|
||||
"max": [0.2, 0.2],
|
||||
"step": [0.001, 0.001]
|
||||
},
|
||||
{
|
||||
"id": "tint",
|
||||
"label": "Tint",
|
||||
"type": "color",
|
||||
"default": [1.0, 1.0, 1.0, 1.0]
|
||||
},
|
||||
{
|
||||
"id": "invert",
|
||||
"label": "Invert",
|
||||
"type": "bool",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"id": "mode",
|
||||
"label": "Mode",
|
||||
"type": "enum",
|
||||
"default": "normal",
|
||||
"options": [
|
||||
{ "value": "normal", "label": "Normal" },
|
||||
{ "value": "luma", "label": "Luma" },
|
||||
{ "value": "posterize", "label": "Posterize" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
23
shaders/studio-color/shader.slang
Normal file
23
shaders/studio-color/shader.slang
Normal file
@@ -0,0 +1,23 @@
|
||||
float4 shadeVideo(ShaderContext context)
|
||||
{
|
||||
float2 uv = clamp(context.uv + offset, float2(0.0, 0.0), float2(1.0, 1.0));
|
||||
float4 color = sampleVideo(uv);
|
||||
|
||||
color.rgb *= brightness;
|
||||
color *= tint;
|
||||
|
||||
if (invert)
|
||||
color.rgb = 1.0 - color.rgb;
|
||||
|
||||
if (mode == 1)
|
||||
{
|
||||
float luma = dot(color.rgb, float3(0.2126, 0.7152, 0.0722));
|
||||
color.rgb = float3(luma, luma, luma);
|
||||
}
|
||||
else if (mode == 2)
|
||||
{
|
||||
color.rgb = floor(color.rgb * 4.0) / 4.0;
|
||||
}
|
||||
|
||||
return saturate(color);
|
||||
}
|
||||
Reference in New Issue
Block a user