Skip to content

Commit

Permalink
🟦 [Nodes] Handle alpha in some nodes + added LED Screen
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesFouchy committed Dec 23, 2023
1 parent 5a30304 commit 537de8a
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
INPUT UV->sRGB 'Image';
INPUT UV->sRGB_PremultipliedA 'Image';
INPUT Point2D 'Center';

INPUT int 'Sample Count';
INPUT float 'Blur';
INPUT float 'Falloff';

sRGB main(UV uv)
sRGB_PremultipliedA main(UV uv)
{
float inverse_sample_count = 1.0 / 'Sample Count';

Expand All @@ -21,14 +21,21 @@ sRGB main(UV uv)
velocity * 4.0 * inverse_sample_count
);

vec3 accumulator = vec3(0);
vec4 accumulator = vec4(0);
mat3x2 offsets = mat3x2(0);

for (int i = 0; i < 'Sample Count'; i++)
{
accumulator.g += 'Image'(uv + offsets[1]).g;
accumulator.b += 'Image'(uv + offsets[2]).b;
accumulator.r += 'Image'(uv + offsets[0]).r;
vec4 color0 = 'Image'(uv + offsets[0]);
vec4 color1 = 'Image'(uv + offsets[1]);
vec4 color2 = 'Image'(uv + offsets[2]);
accumulator.r += color0.r;
accumulator.g += color1.g;
accumulator.b += color2.b;
accumulator.a += (color0.a
+ color1.a
+ color2.a)
/ 3.;

offsets -= increments;
}
Expand Down
42 changes: 42 additions & 0 deletions Nodes/11 Image Modifier (Post Process)/LED Screen.clbnode
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
INPUT UV->sRGB_StraightA 'Image';
INPUT float 'BOB';
INPUT float 'BAB';
INPUT float 'Off';

float sat(float x)
{
return clamp(x, 0., 1.);
}
vec3 sat(vec3 v)
{
return vec3(sat(v.x), sat(v.y), sat(v.z));
}

vec3 pow3(vec3 v, float p)
{
return vec3(pow(v.x, p), pow(v.y, p), pow(v.z, p));
}

sRGB_StraightA main(UV uv)
{
vec2 r = vec2(_aspect_ratio, 1.);

float x = cos(uv.x * PI * 'BOB' * r.x);
float y = cos(uv.x * PI * 'BOB' * r.x + 'Off');
float z = cos(uv.x * PI * 'BOB' * r.x + 'Off' * 2);
vec3 grid = sat(vec3(x, y, z));
grid = pow3(grid, 'BAB');
// grid = sat(grid - .3);
// grid = pow3(grid, .5);
float g = pow(abs(cos(uv.y * PI * 'BOB' * r.y)), .3);
grid *= g;
grid *= 1.5;

uv = round(uv * 'BOB' * r) / ('BOB' * r);

vec3 c = 'Image'(uv).rgb;

vec3 col = grid * c;

return vec4(col, 1.0);
}
9 changes: 5 additions & 4 deletions Nodes/11 Image Modifier (Post Process)/Posterize.clbnode
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
INPUT float 'Levels';
INPUT UV->sRGB 'Image';
INPUT UV->sRGB_StraightA 'Image';

sRGB main(UV uv)
sRGB_StraightA main(UV uv)
{
if ('Levels' == 1.f)
return vec3(0.f);
return vec4(vec3(0.f), 'Image'(uv).a);

return vec3(floor('Image'(uv) * 'Levels') / ('Levels' - 1.));
vec4 color = 'Image'(uv);
return vec4(vec3(floor(color.rgb * 'Levels') / ('Levels' - 1.)), color.a);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

INPUT float 'Opacity';

Oklab_StraightA main(Oklab_StraightA Image)
Oklab_PremultipliedA main(Oklab_PremultipliedA Image)
{
Image.a = 'Opacity';
return Image;
return Image * 'Opacity';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"Presets": {
"Underlying container": [
{
"first": "73c034ed-8075-46ef-a8a4-bc8a3bc1542d",
"second": {
"Name": "Default",
"Values": [
{
"index": 2,
"data": {
"Name": "Opacity",
"Value": 0.5,
"Metadata": {
"Bounds": {
"Has min bound": true,
"Min": 0.0,
"Has max bound": true,
"Max": 1.0,
"Drag speed": 0.009999999776482582,
"Use slider": true
}
},
"Default Value": 0.0,
"Default Metadata": {
"Bounds": {
"Has min bound": false,
"Min": 0.0,
"Has max bound": false,
"Max": 1.0,
"Drag speed": 0.009999999776482582,
"Use slider": false
}
}
}
}
]
}
}
]
}
}

0 comments on commit 537de8a

Please sign in to comment.