Chromatic aberration

master
Alexander 2019-08-08 20:02:42 +02:00
parent f521828edc
commit 000ec17e3d
7 changed files with 139 additions and 0 deletions

View File

@ -0,0 +1,69 @@
#version 450
#include "compiled.inc"
uniform sampler2D tex;
in vec2 texCoord;
out vec4 fragColor;
vec2 barrelDistortion(vec2 coord, float amt) {
vec2 cc = coord - 0.5;
float dist = dot(cc, cc);
return coord + cc * dist * amt;
}
float sat(float value)
{
return clamp(value, 0.0, 1.0);
}
float linterp(float t) {
return sat(1.0 - abs(2.0 * t - 1.0) );
}
float remap(float t, float a, float b ) {
return sat((t - a) / (b - a));
}
vec4 spectrum_offset(float t) {
vec4 ret;
float low = step(t,0.5);
float high = 1.0 - low;
float minMap = 1.0;
float maxMap = 6.0;
float w = linterp( remap(t, minMap/maxMap, 5.0/maxMap ) );
ret = vec4(low, 1.0, high, 1.) * vec4(1.0-w, w, 1.0-w, 1.0);
return pow(ret, vec4(1.0/2.2) );
}
void main() {
float max_distort = compoChromaticStrength;
int num_iter = compoChromaticSamples;
float reci_num_iter_f = 1.0 / float(num_iter);
if (compoChromaticType == 1) {
vec2 resolution = vec2(1,1);
vec2 uv = (texCoord.xy/resolution.xy);
vec4 sumcol = vec4(0.0);
vec4 sumw = vec4(0.0);
for (int i=0; i < num_iter; ++i)
{
float t = float(i) * reci_num_iter_f;
vec4 w = spectrum_offset(t);
sumw += w;
sumcol += w * texture(tex, barrelDistortion(uv, 0.6 * max_distort * t));
}
fragColor = sumcol / sumw;
} else {
vec3 col = vec3(0.0);
col.x = texture(tex, texCoord + ((vec2(0.0, 1.0) * max_distort) / vec2(1000.0))).x;
col.y = texture(tex, texCoord + ((vec2(-0.85, -0.5) * max_distort) / vec2(1000.0))).y;
col.z = texture(tex, texCoord + ((vec2(0.85, -0.5) * max_distort) / vec2(1000.0))).z;
fragColor = vec4(col.x, col.y, col.z, fragColor.w);
}
}

View File

@ -0,0 +1,15 @@
{
"contexts": [
{
"name": "chromatic_aberration_pass",
"depth_write": false,
"color_write_alpha": false,
"compare_mode": "always",
"cull_mode": "none",
"links": [],
"texture_params": [],
"vertex_shader": "../include/pass.vert.glsl",
"fragment_shader": "chromatic_aberration_pass.frag.glsl"
}
]
}

View File

Internal Server Error - Final Minetest

Internal Server Error

Gitea Version: 1.20.5

@ -378,6 +378,14 @@ class RenderPathDeferred {
path.renderTargets.set(t.name, rt);
}