Vignette for basic DoF.
This commit is contained in:
parent
804d3c9400
commit
9de351477c
|
@ -9,26 +9,24 @@ uniform vec2 dir;
|
|||
|
||||
in vec2 texCoord;
|
||||
|
||||
const float weight[5] = float[] (0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
|
||||
// const float weight[5] = float[] (0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
|
||||
|
||||
void main() {
|
||||
vec2 step = dir / vec2(400, 300);
|
||||
// vec2 step = dir / vec2(800, 600);
|
||||
|
||||
vec3 result = texture(tex, texCoord).rgb * weight[0];
|
||||
// vec3 result = texture(tex, texCoord).rgb * weight[0];
|
||||
// result += texture(tex, texCoord + step * 1).rgb * weight[1];
|
||||
// result += texture(tex, texCoord - step * 1).rgb * weight[1];
|
||||
// result += texture(tex, texCoord + step * 2).rgb * weight[2];
|
||||
// result += texture(tex, texCoord - step * 2).rgb * weight[2];
|
||||
// result += texture(tex, texCoord + step * 3).rgb * weight[3];
|
||||
// result += texture(tex, texCoord - step * 3).rgb * weight[3];
|
||||
// result += texture(tex, texCoord + step * 4).rgb * weight[4];
|
||||
// result += texture(tex, texCoord - step * 4).rgb * weight[4];
|
||||
// gl_FragColor = vec4(vec3(result), 1.0);
|
||||
|
||||
result += texture(tex, texCoord + step * 1).rgb * weight[1];
|
||||
result += texture(tex, texCoord - step * 1).rgb * weight[1];
|
||||
result += texture(tex, texCoord + step * 2).rgb * weight[2];
|
||||
result += texture(tex, texCoord - step * 2).rgb * weight[2];
|
||||
result += texture(tex, texCoord + step * 3).rgb * weight[3];
|
||||
result += texture(tex, texCoord - step * 3).rgb * weight[3];
|
||||
result += texture(tex, texCoord + step * 4).rgb * weight[4];
|
||||
result += texture(tex, texCoord - step * 4).rgb * weight[4];
|
||||
|
||||
gl_FragColor = vec4(vec3(result), 1.0);
|
||||
|
||||
/*
|
||||
float res = texture( tex, texCoord + (step * 4.0) ).r;
|
||||
res += texture( tex, texCoord + (step * 3.0) ).r;
|
||||
res += texture( tex, texCoord + (step * 2.0) ).r;
|
||||
|
@ -39,7 +37,7 @@ void main() {
|
|||
res += texture( tex, texCoord -(step * 3.0) ).r;
|
||||
res += texture( tex, texCoord -(step * 4.0) ).r;
|
||||
res /= 9.0;
|
||||
gl_FragColor = vec4(vec3(res), 1.0);
|
||||
|
||||
gl_FragColor = vec4(vec3(res), 1.0);*/
|
||||
// gl_FragColor = texture(tex, texCoord);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,17 @@ uniform sampler2D gbuffer2;
|
|||
const float focus_depth = 0.5;
|
||||
in vec2 texCoord;
|
||||
|
||||
const float vignout = 1.3; // vignetting outer border
|
||||
const float vignin = 0.0; // vignetting inner border
|
||||
const float vignfade = 90.0; // f-stops till vignete fades
|
||||
const float fstop = 20; // f-stop value
|
||||
|
||||
float vignette() {
|
||||
float dist = distance(texCoord, vec2(0.5,0.5));
|
||||
dist = smoothstep(vignout + (fstop / vignfade), vignin + (fstop / vignfade), dist);
|
||||
return clamp(dist, 0.0, 1.0);
|
||||
}
|
||||
|
||||
vec4 sampleBox(float size) {
|
||||
vec4 color = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
color += texture(tex, vec2(texCoord.x - size, texCoord.y - size)) * 0.075;
|
||||
|
@ -36,5 +47,10 @@ void main() {
|
|||
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);
|
||||
gl_FragColor = baseColor * (1.0 - blur_amount) + blurredColor * blur_amount;
|
||||
vec4 col = baseColor * (1.0 - blur_amount) + blurredColor * blur_amount;
|
||||
|
||||
// Vignetting
|
||||
col *= vignette();
|
||||
|
||||
gl_FragColor = col;
|
||||
}
|
||||
|
|
|
@ -29,9 +29,9 @@ uniform sampler2D snoise;
|
|||
|
||||
const float PI = 3.1415926535;
|
||||
const vec2 screenSize = vec2(800.0, 600.0);
|
||||
const float aoSize = 0.43;
|
||||
const float aoSize = 0.6;//0.43;
|
||||
const int kernelSize = 8;
|
||||
const float strength = 0.55;
|
||||
const float strength = 0.8;//0.55;
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
|
|
Loading…
Reference in a new issue