Skip to content

Commit

Permalink
🟦 [Nodes] Add a Post-Process Glow. closes #110
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesFouchy committed Dec 30, 2024
1 parent a840530 commit 026f586
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Nodes/11 Image Modifier (Post Process)/Glow.clbnode
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Credit: [illtellyoulater](https://github.com/CoolLibs/Lab/issues/110)

INPUT UV->Oklab_PremultipliedA 'Image';
INPUT float 'Brightness';
INPUT float 'Size';
INPUT int 'Quality'; /// The higher the number the smoother the result, but it will start to get laggy if set too high.
INPUT float 'Mask';

vec4 blur(vec2 uv)
{
vec4 color = vec4(0.);
for (int x = -'Quality'; x <= 'Quality'; x++)
{
for (int y = -'Quality'; y <= 'Quality'; y++)
{
vec2 offset = vec2(x, y) / 'Quality' * 'Size';
color += 'Image'(uv + offset);
}
}

float weights_sum = (2. * 'Quality' + 1.) * (2. * 'Quality' + 1.);
return color / weights_sum;
}

Oklab_PremultipliedA main(UV uv)
{
vec4 blurred = blur(uv);
vec4 glow = blurred * 'Brightness';
vec4 base = 'Image'(uv);

// Combine original image and glow
// return mix(base, glow, 'Blend Strength');
return base + glow * 'Mask';
}
86 changes: 86 additions & 0 deletions Nodes/11 Image Modifier (Post Process)/Glow.clbnode.presets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"Presets": {
"Underlying container": [
{
"first": "d07c9f21-6de8-4dfd-bc8f-04a5573983de",
"second": {
"Name": "Default",
"Values": [
{
"index": 2,
"data": {
"Name": "Brightness",
"Value": 1.5,
"Metadata": {
"Bounds": {
"Has min bound": true,
"Min": 0.0,
"Has max bound": false,
"Max": 1.0,
"Drag speed": 0.009999999776482582,
"Use slider": false,
"Is logarithmic": false
}
}
}
},
{
"index": 2,
"data": {
"Name": "Size",
"Value": 0.15000000596046449,
"Metadata": {
"Bounds": {
"Has min bound": true,
"Min": 0.0,
"Has max bound": false,
"Max": 1.0,
"Drag speed": 0.0010000000474974514,
"Use slider": false,
"Is logarithmic": false
}
}
}
},
{
"index": 1,
"data": {
"Name": "Quality",
"Value": 3,
"Metadata": {
"Bounds": {
"Has min bound": true,
"Min": 1,
"Has max bound": true,
"Max": 6,
"Drag speed": 0.009999999776482582,
"Use slider": false,
"Is logarithmic": false
}
}
}
},
{
"index": 2,
"data": {
"Name": "Mask",
"Value": 1.0,
"Metadata": {
"Bounds": {
"Has min bound": true,
"Min": 0.0,
"Has max bound": true,
"Max": 1.0,
"Drag speed": 0.009999999776482582,
"Use slider": true,
"Is logarithmic": false
}
}
}
}
]
}
}
]
}
}

0 comments on commit 026f586

Please sign in to comment.