Added new shaders
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"id": "vhs",
|
||||
"name": "VHS",
|
||||
"description": "VHS with wiggle, smear, and YIQ-style color separation inspired by the Godot shader reference.",
|
||||
"category": "Built-in",
|
||||
"description": "VHS with wiggle, smear, and YIQ-style color separation inspired by nostalgic analog references.",
|
||||
"category": "Glitch",
|
||||
"entryPoint": "shadeVideo",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -95,6 +95,24 @@
|
||||
"max": 0.2,
|
||||
"step": 0.005
|
||||
},
|
||||
{
|
||||
"id": "staticAmount",
|
||||
"label": "Analog Static",
|
||||
"type": "float",
|
||||
"default": 0.045,
|
||||
"min": 0.0,
|
||||
"max": 0.25,
|
||||
"step": 0.005
|
||||
},
|
||||
{
|
||||
"id": "staticLines",
|
||||
"label": "Static Lines",
|
||||
"type": "float",
|
||||
"default": 0.65,
|
||||
"min": 0.0,
|
||||
"max": 1.5,
|
||||
"step": 0.01
|
||||
},
|
||||
{
|
||||
"id": "noiseSize",
|
||||
"label": "Noise Size",
|
||||
|
||||
@@ -44,6 +44,13 @@ float noiseHash(float2 p)
|
||||
return frac(sin(dot(p, float2(127.1, 311.7))) * 43758.5453123);
|
||||
}
|
||||
|
||||
// Gold Noise (c)2015 dcerisano@standard3d.com, adapted for Slang.
|
||||
float goldNoise(float2 xy, float seed)
|
||||
{
|
||||
const float phi = 1.61803398874989484820459;
|
||||
return frac(tan(distance(xy * phi, xy) * seed) * xy.x);
|
||||
}
|
||||
|
||||
float grainScalar(float2 uv)
|
||||
{
|
||||
return frac(sin(dot(uv, float2(12.9898, 78.233))) * 43758.5453);
|
||||
@@ -63,6 +70,56 @@ float3 animatedChromaGrain(float2 uv, float time, float2 outputResolution, float
|
||||
return float3(r, g, b) * 2.0 - 1.0;
|
||||
}
|
||||
|
||||
float valueNoise2(float2 p)
|
||||
{
|
||||
float2 cell = floor(p);
|
||||
float2 f = frac(p);
|
||||
float2 u = f * f * (3.0 - 2.0 * f);
|
||||
|
||||
float a = noiseHash(cell);
|
||||
float b = noiseHash(cell + float2(1.0, 0.0));
|
||||
float c = noiseHash(cell + float2(0.0, 1.0));
|
||||
float d = noiseHash(cell + float2(1.0, 1.0));
|
||||
|
||||
return lerp(lerp(a, b, u.x), lerp(c, d, u.x), u.y);
|
||||
}
|
||||
|
||||
float tapeLineNoise(float2 uv, float time, float2 outputResolution)
|
||||
{
|
||||
float y = floor(uv.y * outputResolution.y);
|
||||
float slowLine = valueNoise2(float2(y * 0.021, floor(time * 10.0)));
|
||||
float fastLine = noiseHash(float2(y * 1.73, floor(time * 59.94)));
|
||||
float line = (slowLine * 0.7 + fastLine * 0.3) * 2.0 - 1.0;
|
||||
|
||||
float band = sin(uv.y * outputResolution.y * 0.42 + time * 36.0);
|
||||
return line * (0.65 + 0.35 * band);
|
||||
}
|
||||
|
||||
float3 analogStatic(float2 uv, float time, float2 outputResolution)
|
||||
{
|
||||
float2 safeResolution = max(outputResolution, float2(1.0, 1.0));
|
||||
float2 pixel = floor(uv * safeResolution / max(noiseSize, 0.25));
|
||||
float frame = floor(time * 59.94);
|
||||
float seed = frac(time);
|
||||
|
||||
float2 goldPixel = pixel + float2(0.37, 0.61) + frame;
|
||||
float snowA = goldNoise(goldPixel, seed + 0.1);
|
||||
float snowB = goldNoise(goldPixel * float2(0.37, 2.11) + float2(19.0, 41.0), seed + 0.2);
|
||||
float snowC = goldNoise(goldPixel * float2(1.73, 0.81) + float2(53.0, 7.0), seed + 0.3);
|
||||
float snow = (snowA * 0.72 + snowB * 0.28) * 2.0 - 1.0;
|
||||
|
||||
float lineNoise = tapeLineNoise(uv, time, safeResolution);
|
||||
float dropoutSeed = goldNoise(float2(floor(uv.y * safeResolution.y * 0.25) + 1.0, frame + 2.0), seed + 0.4);
|
||||
float dropout = smoothstep(0.965, 1.0, dropoutSeed);
|
||||
float fleck = smoothstep(0.988, 1.0, snowA) - smoothstep(0.0, 0.012, snowC);
|
||||
|
||||
float scan = sin(uv.y * safeResolution.y * 3.14159265);
|
||||
float scanMask = 0.55 + 0.45 * scan * scan;
|
||||
float lumaNoise = snow * 0.55 + lineNoise * staticLines * 0.45 + fleck * 0.7 + dropout * lineNoise * 1.2;
|
||||
|
||||
return float3(lumaNoise * scanMask, lumaNoise * 0.42, lumaNoise * 0.72);
|
||||
}
|
||||
|
||||
float3 softBloom(float2 uv, float2 outputResolution, float radius)
|
||||
{
|
||||
float2 pixel = 1.0 / max(outputResolution, float2(1.0, 1.0));
|
||||
@@ -164,6 +221,11 @@ float4 shadeVideo(ShaderContext context)
|
||||
color.rg = lerp(color.rg, float2(color.r, color.g) + speckle.xy * noiseAmount * 0.2 * chunkiness, 0.35);
|
||||
color.b = lerp(color.b, color.b + speckle.z * noiseAmount * 0.28 * chunkiness, 0.5);
|
||||
|
||||
float3 staticNoise = analogStatic(context.uv, context.time, context.outputResolution);
|
||||
float staticMask = lerp(0.45, 1.15, 1.0 - saturate(luma));
|
||||
color += staticNoise * staticAmount * staticMask;
|
||||
color = lerp(color, color + float3(staticNoise.r * 0.22, staticNoise.g * 0.08, -staticNoise.b * 0.08), saturate(staticAmount * 2.0));
|
||||
|
||||
float3 grayscale = float3(luma, luma, luma);
|
||||
color = lerp(color, grayscale, fadeAmount * 0.18);
|
||||
color = color * (1.0 - fadeAmount * 0.08) + float3(0.055, 0.055, 0.065) * fadeAmount;
|
||||
|
||||
Reference in New Issue
Block a user