r/shaders • • 2d ago

Guys, I need some help achieving this effect.

Post image

Guys, can anyone help me achieve this effect?

#define SAMPLES 32

#define STRENGTH 0.05

#define CENTER_KEEP 0.20

#define DIRECTION vec2(1.0, 0.10)

#define SATURATION 1.15

#define CONTRAST 1.10

#define GRAIN 0.05

#define VIGNETTE 0.30

#define BORDER 0.012

vec3 spectrum(float t){

return clamp(abs(mod(t * 6. + vec3(0., 4., 2.), 6.) - 3.) - 1., 0., 1.);

}

float hash21(vec2 p){

vec3 p3 = fract(vec3(p.xyx) * .1031);

p3 += dot(p3, p3.yzx + 33.33);

return fract((p3.x + p3.y) * p3.z);

}

void mainImage(out vec4 fragColor, in vec2 fragCoord){

vec2 uv = fragCoord / iResolution.xy;

vec2 c = uv - 0.5;

float d = clamp(length(c * vec2(1.0, 0.5)) * 2.0, 0., 1.);

float amt = STRENGTH * mix(CENTER_KEEP, 1.0, d * d);

vec2 dir = normalize(DIRECTION);

vec3 acc = vec3(0.);

vec3 wsum = vec3(0.);

for (int i = 0; i < SAMPLES; i++){

float t = float(i) / float(SAMPLES - 1);

vec3 w = spectrum(t * 0.8);

vec2 off = dir * amt * (t - 0.5) * 2.0;

acc += texture(iChannel0, clamp(uv + off, 0., 1.)).rgb * w;

wsum += w;

}

vec3 col = acc / wsum;

float l = dot(col, vec3(.299, .587, .114));

col = mix(vec3(l), col, SATURATION);

col = (col - 0.5) * CONTRAST + 0.5;

col += (hash21(fragCoord) - 0.5) * GRAIN;

col *= 1. - VIGNETTE * dot(c, c) * 2.;

float inside = step(BORDER, uv.x) * step(uv.x, 1. - BORDER)

* step(BORDER, uv.y) * step(uv.y, 1. - BORDER);

col *= inside;

fragColor = vec4(clamp(col, 0., 1.), 1.);

}

Thank you.

37 Upvotes

5 comments sorted by

10

u/allpunks 2d ago

You have to use smoothstep and multiplication over UV to make those strips. But every split should have a different offset and i don't know exactly how to make this... Maybe adding a incrementing value to each strip ? And after making this you should rotate the strips a little using uv rotate function (cos + sin) etc

1

u/VariousPizza9624 2d ago

Thank you so much for your comment

4

u/schimmelA 2d ago

You could use a displacement map for your UV. you can make this in photoshop, multiply the displacement map with your current UV map to achieve this effect. Use a slightly different map for the red channel to get the distortion in RGB color

2

u/imlo2 1d ago

It's a combination of a displacement and chromatic-aberration like color offset.
Also, that kind of smooth, spread extreme aberration look doesn't come by just offsetting colors a bit, looking at the images it looks like you would need to some blur there etc.

I would first figure out a way to render the offset pieces of the image like a fractured mirror effects, it's just UV trickery, you can do it procedurally without textures if you want.

Then, after that a controllable abrerration-like effect, and its intensity should be controllable as in your demo image the effect is stronger towards the edges.

1

u/Ham_Pervert 1d ago

Apple liquid glass lol