Example shaders
This commit is contained in:
33
shaders/pixelate/shader.json
Normal file
33
shaders/pixelate/shader.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"id": "pixelate",
|
||||
"name": "Pixelate",
|
||||
"description": "Reduces the effective X and Y pixel count independently to create a low-resolution blocky image.",
|
||||
"category": "Utility",
|
||||
"entryPoint": "shadeVideo",
|
||||
"parameters": [
|
||||
{
|
||||
"id": "pixelCount",
|
||||
"label": "Pixel Count",
|
||||
"type": "vec2",
|
||||
"default": [96.0, 54.0],
|
||||
"min": [2.0, 2.0],
|
||||
"max": [1920.0, 1080.0],
|
||||
"step": [1.0, 1.0]
|
||||
},
|
||||
{
|
||||
"id": "gridAmount",
|
||||
"label": "Grid",
|
||||
"type": "float",
|
||||
"default": 0.0,
|
||||
"min": 0.0,
|
||||
"max": 1.0,
|
||||
"step": 0.01
|
||||
},
|
||||
{
|
||||
"id": "gridColor",
|
||||
"label": "Grid Color",
|
||||
"type": "color",
|
||||
"default": [0.0, 0.0, 0.0, 1.0]
|
||||
}
|
||||
]
|
||||
}
|
||||
12
shaders/pixelate/shader.slang
Normal file
12
shaders/pixelate/shader.slang
Normal file
@@ -0,0 +1,12 @@
|
||||
float4 shadeVideo(ShaderContext context)
|
||||
{
|
||||
float2 count = max(pixelCount, float2(1.0, 1.0));
|
||||
float2 cell = floor(context.uv * count);
|
||||
float2 sampledUv = (cell + 0.5) / count;
|
||||
float4 color = sampleVideo(clamp(sampledUv, 0.0, 1.0));
|
||||
|
||||
float2 local = frac(context.uv * count);
|
||||
float gridLine = 1.0 - step(0.035, min(min(local.x, 1.0 - local.x), min(local.y, 1.0 - local.y)));
|
||||
color.rgb = lerp(color.rgb, gridColor.rgb, gridLine * saturate(gridAmount) * gridColor.a);
|
||||
return color;
|
||||
}
|
||||
Reference in New Issue
Block a user