Move fish eye to compositor.
This commit is contained in:
parent
85b01f318d
commit
e1ae9c1658
|
@ -39,18 +39,14 @@ os.chdir('../motion_blur_pass')
|
|||
make_resources.make('motion_blur_pass.shader.json')
|
||||
make_variants.make('motion_blur_pass.shader.json')
|
||||
|
||||
os.chdir('../dof_pass')
|
||||
make_resources.make('dof_pass.shader.json')
|
||||
make_variants.make('dof_pass.shader.json')
|
||||
os.chdir('../compositor_pass')
|
||||
make_resources.make('compositor_pass.shader.json')
|
||||
make_variants.make('compositor_pass.shader.json')
|
||||
|
||||
os.chdir('../bloom_pass')
|
||||
make_resources.make('bloom_pass.shader.json')
|
||||
make_variants.make('bloom_pass.shader.json')
|
||||
|
||||
os.chdir('../fisheye_pass')
|
||||
make_resources.make('fisheye_pass.shader.json')
|
||||
make_variants.make('fisheye_pass.shader.json')
|
||||
|
||||
os.chdir('../ssr_pass')
|
||||
make_resources.make('ssr_pass.shader.json')
|
||||
make_variants.make('ssr_pass.shader.json')
|
||||
|
|
|
@ -15,6 +15,10 @@ uniform mat4 VP;
|
|||
|
||||
in vec2 texCoord;
|
||||
|
||||
const float PI = 3.1415926535;
|
||||
const float fishEyeStrength = -0.01;
|
||||
const vec2 m = vec2(0.5, 0.5);
|
||||
|
||||
const float focus_depth = 0.5;
|
||||
|
||||
const float vignout = 1.8; // vignetting outer border
|
||||
|
@ -134,6 +138,22 @@ vec3 tonemapUncharted2(vec3 color) {
|
|||
}
|
||||
|
||||
void main() {
|
||||
// Fish eye
|
||||
vec2 d = texCoord - m;
|
||||
float r = sqrt(dot(d, d));
|
||||
float power = (2.0 * PI / (2.0 * sqrt(dot(m, m)))) * fishEyeStrength;
|
||||
float bind;
|
||||
if (power > 0.0) { bind = sqrt(dot(m, m)); }
|
||||
else { bind = m.x; }
|
||||
vec2 uv;
|
||||
if (power > 0.0) {
|
||||
uv = m + normalize(d) * tan(r * power) * bind / tan(bind * power);
|
||||
}
|
||||
else {
|
||||
uv = m + normalize(d) * atan(r * -power * 10.0) * bind / atan(-power * bind * 10.0);
|
||||
}
|
||||
vec4 col = texture(tex, uv);
|
||||
|
||||
// Blur
|
||||
float depth = texture(gbuffer0, texCoord).a;
|
||||
float blur_amount = abs(depth - focus_depth);
|
||||
|
@ -141,11 +161,11 @@ void main() {
|
|||
blur_amount *= 10.0;
|
||||
}
|
||||
blur_amount = clamp(blur_amount, 0.0, 1.0);
|
||||
vec4 baseColor = texture(tex, texCoord);
|
||||
vec4 baseColor = col;//texture(tex, texCoord);
|
||||
vec4 blurredColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
float blurSize = 0.005 * blur_amount;
|
||||
blurredColor = 0.75 * sampleBox(blurSize * 0.5) + 0.25 * sampleBox(blurSize * 1.0);
|
||||
vec4 col = baseColor * (1.0 - blur_amount) + blurredColor * blur_amount;
|
||||
col = baseColor * (1.0 - blur_amount) + blurredColor * blur_amount;
|
||||
|
||||
// Fog
|
||||
// vec3 pos = texture(gbuffer1, texCoord).rgb;
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"contexts": [
|
||||
{
|
||||
"id": "dof_pass",
|
||||
"id": "compositor_pass",
|
||||
"params": [
|
||||
{
|
||||
"id": "depth_write",
|
||||
|
@ -31,8 +31,8 @@
|
|||
}
|
||||
],
|
||||
"texture_params": [],
|
||||
"vertex_shader": "dof_pass.vert.glsl",
|
||||
"fragment_shader": "dof_pass.frag.glsl"
|
||||
"vertex_shader": "compositor_pass.vert.glsl",
|
||||
"fragment_shader": "compositor_pass.frag.glsl"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
// Fish eye based on Sanch implementation
|
||||
// https://www.shadertoy.com/view/4s2GRR
|
||||
#version 450
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex;
|
||||
|
||||
const float PI = 3.1415926535;
|
||||
const float strength = -0.01;
|
||||
const vec2 m = vec2(0.5, 0.5);
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
void main() {
|
||||
vec2 d = texCoord - m;
|
||||
float r = sqrt(dot(d, d));
|
||||
|
||||
float power = (2.0 * PI / (2.0 * sqrt(dot(m, m)))) * strength;
|
||||
|
||||
float bind;
|
||||
if (power > 0.0) {
|
||||
bind = sqrt(dot(m, m));
|
||||
}
|
||||
else {
|
||||
bind = m.x;
|
||||
}
|
||||
|
||||
vec2 uv;
|
||||
if (power > 0.0) {
|
||||
uv = m + normalize(d) * tan(r * power) * bind / tan(bind * power);
|
||||
}
|
||||
else {
|
||||
uv = m + normalize(d) * atan(r * -power * 10.0) * bind / atan(-power * bind * 10.0);
|
||||
}
|
||||
|
||||
vec3 col = texture(tex, uv).xyz;
|
||||
gl_FragColor = vec4(col, 1.0);
|
||||
|
||||
// vec4 texCol = texture(tex, texCoord);
|
||||
// gl_FragColor = texCol;
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
{
|
||||
"contexts": [
|
||||
{
|
||||
"id": "fisheye_pass",
|
||||
"params": [
|
||||
{
|
||||
"id": "depth_write",
|
||||
"value": "true"
|
||||
},
|
||||
{
|
||||
"id": "compare_mode",
|
||||
"value": "always"
|
||||
},
|
||||
{
|
||||
"id": "cull_mode",
|
||||
"value": "none"
|
||||
}
|
||||
],
|
||||
"links": [],
|
||||
"texture_params": [],
|
||||
"vertex_shader": "fisheye_pass.vert.glsl",
|
||||
"fragment_shader": "fisheye_pass.frag.glsl"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
#version 450
|
||||
|
||||
#ifdef GL_ES
|
||||
precision highp float;
|
||||
#endif
|
||||
|
||||
in vec2 pos;
|
||||
|
||||
out vec2 texCoord;
|
||||
|
||||
const vec2 madd = vec2(0.5, 0.5);
|
||||
|
||||
void main() {
|
||||
// Scale vertex attribute to [0-1] range
|
||||
texCoord = pos.xy * madd + madd;
|
||||
|
||||
gl_Position = vec4(pos.xy, 0.0, 1.0);
|
||||
}
|
Loading…
Reference in a new issue