Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions blueprints/.glsl/Brightness_and_Contrast_1.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#version 300 es
precision highp float;

uniform sampler2D u_image0;
uniform float u_float0; // Brightness slider -100..100
uniform float u_float1; // Contrast slider -100..100

in vec2 v_texCoord;
out vec4 fragColor;

const float MID_GRAY = 0.18; // 18% reflectance

// sRGB gamma 2.2 approximation
vec3 srgbToLinear(vec3 c) {
return pow(max(c, 0.0), vec3(2.2));
}

vec3 linearToSrgb(vec3 c) {
return pow(max(c, 0.0), vec3(1.0/2.2));
}

float mapBrightness(float b) {
return clamp(b / 100.0, -1.0, 1.0);
}

float mapContrast(float c) {
return clamp(c / 100.0 + 1.0, 0.0, 2.0);
}

void main() {
vec4 orig = texture(u_image0, v_texCoord);

float brightness = mapBrightness(u_float0);
float contrast = mapContrast(u_float1);

vec3 lin = srgbToLinear(orig.rgb);

lin = (lin - MID_GRAY) * contrast + brightness + MID_GRAY;

// Convert back to sRGB
vec3 result = linearToSrgb(clamp(lin, 0.0, 1.0));

fragColor = vec4(result, orig.a);
}
72 changes: 72 additions & 0 deletions blueprints/.glsl/Chromatic_Aberration_16.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#version 300 es
precision highp float;

uniform sampler2D u_image0;
uniform vec2 u_resolution;
uniform int u_int0; // Mode
uniform float u_float0; // Amount (0 to 100)

in vec2 v_texCoord;
out vec4 fragColor;

const int MODE_LINEAR = 0;
const int MODE_RADIAL = 1;
const int MODE_BARREL = 2;
const int MODE_SWIRL = 3;
const int MODE_DIAGONAL = 4;

const float AMOUNT_SCALE = 0.0005;
const float RADIAL_MULT = 4.0;
const float BARREL_MULT = 8.0;
const float INV_SQRT2 = 0.70710678118;

void main() {
vec2 uv = v_texCoord;
vec4 original = texture(u_image0, uv);

float amount = u_float0 * AMOUNT_SCALE;

if (amount < 0.000001) {
fragColor = original;
return;
}

// Aspect-corrected coordinates for circular effects
float aspect = u_resolution.x / u_resolution.y;
vec2 centered = uv - 0.5;
vec2 corrected = vec2(centered.x * aspect, centered.y);
float r = length(corrected);
vec2 dir = r > 0.0001 ? corrected / r : vec2(0.0);
vec2 offset = vec2(0.0);

if (u_int0 == MODE_LINEAR) {
// Horizontal shift (no aspect correction needed)
offset = vec2(amount, 0.0);
}
else if (u_int0 == MODE_RADIAL) {
// Outward from center, stronger at edges
offset = dir * r * amount * RADIAL_MULT;
offset.x /= aspect; // Convert back to UV space
}
else if (u_int0 == MODE_BARREL) {
// Lens distortion simulation (r² falloff)
offset = dir * r * r * amount * BARREL_MULT;
offset.x /= aspect; // Convert back to UV space
}
else if (u_int0 == MODE_SWIRL) {
// Perpendicular to radial (rotational aberration)
vec2 perp = vec2(-dir.y, dir.x);
offset = perp * r * amount * RADIAL_MULT;
offset.x /= aspect; // Convert back to UV space
}
else if (u_int0 == MODE_DIAGONAL) {
// 45° offset (no aspect correction needed)
offset = vec2(amount, amount) * INV_SQRT2;
}

float red = texture(u_image0, uv + offset).r;
float green = original.g;
float blue = texture(u_image0, uv - offset).b;

fragColor = vec4(red, green, blue, original.a);
}
78 changes: 78 additions & 0 deletions blueprints/.glsl/Color_Adjustment_15.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#version 300 es
precision highp float;

uniform sampler2D u_image0;
uniform float u_float0; // temperature (-100 to 100)
uniform float u_float1; // tint (-100 to 100)
uniform float u_float2; // vibrance (-100 to 100)
uniform float u_float3; // saturation (-100 to 100)

in vec2 v_texCoord;
out vec4 fragColor;

const float INPUT_SCALE = 0.01;
const float TEMP_TINT_PRIMARY = 0.3;
const float TEMP_TINT_SECONDARY = 0.15;
const float VIBRANCE_BOOST = 2.0;
const float SATURATION_BOOST = 2.0;
const float SKIN_PROTECTION = 0.5;
const float EPSILON = 0.001;
const vec3 LUMA_WEIGHTS = vec3(0.299, 0.587, 0.114);

void main() {
vec4 tex = texture(u_image0, v_texCoord);
vec3 color = tex.rgb;

// Scale inputs: -100/100 → -1/1
float temperature = u_float0 * INPUT_SCALE;
float tint = u_float1 * INPUT_SCALE;
float vibrance = u_float2 * INPUT_SCALE;
float saturation = u_float3 * INPUT_SCALE;

// Temperature (warm/cool): positive = warm, negative = cool
color.r += temperature * TEMP_TINT_PRIMARY;
color.b -= temperature * TEMP_TINT_PRIMARY;

// Tint (green/magenta): positive = green, negative = magenta
color.g += tint * TEMP_TINT_PRIMARY;
color.r -= tint * TEMP_TINT_SECONDARY;
color.b -= tint * TEMP_TINT_SECONDARY;

// Single clamp after temperature/tint
color = clamp(color, 0.0, 1.0);

// Vibrance with skin protection
if (vibrance != 0.0) {
float maxC = max(color.r, max(color.g, color.b));
float minC = min(color.r, min(color.g, color.b));
float sat = maxC - minC;
float gray = dot(color, LUMA_WEIGHTS);

if (vibrance < 0.0) {
// Desaturate: -100 → gray
color = mix(vec3(gray), color, 1.0 + vibrance);
} else {
// Boost less saturated colors more
float vibranceAmt = vibrance * (1.0 - sat);

// Branchless skin tone protection
float isWarmTone = step(color.b, color.g) * step(color.g, color.r);
float warmth = (color.r - color.b) / max(maxC, EPSILON);
float skinTone = isWarmTone * warmth * sat * (1.0 - sat);
vibranceAmt *= (1.0 - skinTone * SKIN_PROTECTION);

color = mix(vec3(gray), color, 1.0 + vibranceAmt * VIBRANCE_BOOST);
}
}

// Saturation
if (saturation != 0.0) {
float gray = dot(color, LUMA_WEIGHTS);
float satMix = saturation < 0.0
? 1.0 + saturation // -100 → gray
: 1.0 + saturation * SATURATION_BOOST; // +100 → 3x boost
color = mix(vec3(gray), color, satMix);
}

fragColor = vec4(clamp(color, 0.0, 1.0), tex.a);
}
94 changes: 94 additions & 0 deletions blueprints/.glsl/Edge-Preserving_Blur_128.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#version 300 es
precision highp float;

uniform sampler2D u_image0;
uniform float u_float0; // Blur radius (0–20, default ~5)
uniform float u_float1; // Edge threshold (0–100, default ~30)
uniform int u_int0; // Step size (0/1 = every pixel, 2+ = skip pixels)

in vec2 v_texCoord;
out vec4 fragColor;

const int MAX_RADIUS = 20;
const float EPSILON = 0.0001;

// Perceptual luminance
float getLuminance(vec3 rgb) {
return dot(rgb, vec3(0.299, 0.587, 0.114));
}

vec4 bilateralFilter(vec2 uv, vec2 texelSize, int radius,
float sigmaSpatial, float sigmaColor)
{
vec4 center = texture(u_image0, uv);
vec3 centerRGB = center.rgb;

float invSpatial2 = -0.5 / (sigmaSpatial * sigmaSpatial);
float invColor2 = -0.5 / (sigmaColor * sigmaColor + EPSILON);

vec3 sumRGB = vec3(0.0);
float sumWeight = 0.0;

int step = max(u_int0, 1);
float radius2 = float(radius * radius);

for (int dy = -MAX_RADIUS; dy <= MAX_RADIUS; dy++) {
if (dy < -radius || dy > radius) continue;
if (abs(dy) % step != 0) continue;

for (int dx = -MAX_RADIUS; dx <= MAX_RADIUS; dx++) {
if (dx < -radius || dx > radius) continue;
if (abs(dx) % step != 0) continue;

vec2 offset = vec2(float(dx), float(dy));
float dist2 = dot(offset, offset);
if (dist2 > radius2) continue;

vec3 sampleRGB = texture(u_image0, uv + offset * texelSize).rgb;

// Spatial Gaussian
float spatialWeight = exp(dist2 * invSpatial2);

// Perceptual color distance (weighted RGB)
vec3 diff = sampleRGB - centerRGB;
float colorDist = dot(diff * diff, vec3(0.299, 0.587, 0.114));
float colorWeight = exp(colorDist * invColor2);

float w = spatialWeight * colorWeight;
sumRGB += sampleRGB * w;
sumWeight += w;
}
}

vec3 resultRGB = sumRGB / max(sumWeight, EPSILON);
return vec4(resultRGB, center.a); // preserve center alpha
}

void main() {
vec2 texelSize = 1.0 / vec2(textureSize(u_image0, 0));

float radiusF = clamp(u_float0, 0.0, float(MAX_RADIUS));
int radius = int(radiusF + 0.5);

if (radius == 0) {
fragColor = texture(u_image0, v_texCoord);
return;
}

// Edge threshold → color sigma
// Squared curve for better low-end control
float t = clamp(u_float1, 0.0, 100.0) / 100.0;
t *= t;
float sigmaColor = mix(0.01, 0.5, t);

// Spatial sigma tied to radius
float sigmaSpatial = max(radiusF * 0.75, 0.5);

fragColor = bilateralFilter(
v_texCoord,
texelSize,
radius,
sigmaSpatial,
sigmaColor
);
}
Loading
Loading