|
@@ -12,22 +12,23 @@
|
|
|
#define MAX_GHOSTS 4
|
|
#define MAX_GHOSTS 4
|
|
|
#define GHOST_DISPERSAL (0.7)
|
|
#define GHOST_DISPERSAL (0.7)
|
|
|
#define HALO_WIDTH 0.4
|
|
#define HALO_WIDTH 0.4
|
|
|
-#define CHROMATIC_DISTORTION 4.0
|
|
|
|
|
|
|
+#define CHROMATIC_DISTORTION 6.0
|
|
|
#define ENABLE_CHROMATIC_DISTORTION 1
|
|
#define ENABLE_CHROMATIC_DISTORTION 1
|
|
|
#define ENABLE_HALO 1
|
|
#define ENABLE_HALO 1
|
|
|
|
|
+#define HALO_OPACITY 0.5
|
|
|
|
|
|
|
|
-layout(location = 0) in vec2 inTexCoord;
|
|
|
|
|
|
|
+layout(location = 0) in vec2 in_texCoord;
|
|
|
|
|
|
|
|
-layout(binding = 0) uniform sampler2D uRt;
|
|
|
|
|
-layout(binding = 1) uniform sampler2D uLensDirtTex;
|
|
|
|
|
|
|
+layout(binding = 0) uniform sampler2D u_rt;
|
|
|
|
|
+layout(binding = 1) uniform sampler2D u_lensDirtTex;
|
|
|
|
|
|
|
|
-layout(location = 0) out vec3 outColor;
|
|
|
|
|
|
|
+layout(location = 0) out vec3 out_color;
|
|
|
|
|
|
|
|
vec3 textureDistorted(
|
|
vec3 textureDistorted(
|
|
|
in sampler2D tex,
|
|
in sampler2D tex,
|
|
|
in vec2 texcoord,
|
|
in vec2 texcoord,
|
|
|
in vec2 direction, // direction of distortion
|
|
in vec2 direction, // direction of distortion
|
|
|
- in vec3 distortion) // per-channel distortion factor
|
|
|
|
|
|
|
+ in vec3 distortion) // per-channel distortion factor
|
|
|
{
|
|
{
|
|
|
#if ENABLE_CHROMATIC_DISTORTION
|
|
#if ENABLE_CHROMATIC_DISTORTION
|
|
|
return vec3(
|
|
return vec3(
|
|
@@ -41,15 +42,15 @@ vec3 textureDistorted(
|
|
|
|
|
|
|
|
void main()
|
|
void main()
|
|
|
{
|
|
{
|
|
|
- vec2 texcoord = vec2(1.0) - inTexCoord;
|
|
|
|
|
|
|
+ vec2 texcoord = vec2(1.0) - in_texCoord;
|
|
|
|
|
|
|
|
vec2 ghostVec = (vec2(0.5) - texcoord) * GHOST_DISPERSAL;
|
|
vec2 ghostVec = (vec2(0.5) - texcoord) * GHOST_DISPERSAL;
|
|
|
|
|
|
|
|
const vec2 texelSize = 1.0 / vec2(TEX_DIMENSIONS);
|
|
const vec2 texelSize = 1.0 / vec2(TEX_DIMENSIONS);
|
|
|
|
|
|
|
|
const vec3 distortion = vec3(
|
|
const vec3 distortion = vec3(
|
|
|
- -texelSize.x * CHROMATIC_DISTORTION,
|
|
|
|
|
- 0.0,
|
|
|
|
|
|
|
+ -texelSize.x * CHROMATIC_DISTORTION,
|
|
|
|
|
+ 0.0,
|
|
|
texelSize.x * CHROMATIC_DISTORTION);
|
|
texelSize.x * CHROMATIC_DISTORTION);
|
|
|
|
|
|
|
|
const float lenOfHalf = length(vec2(0.5));
|
|
const float lenOfHalf = length(vec2(0.5));
|
|
@@ -58,31 +59,31 @@ void main()
|
|
|
|
|
|
|
|
vec3 result = vec3(0.0);
|
|
vec3 result = vec3(0.0);
|
|
|
|
|
|
|
|
- // sample ghosts:
|
|
|
|
|
- for(int i = 0; i < MAX_GHOSTS; ++i)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ // sample ghosts:
|
|
|
|
|
+ for(int i = 0; i < MAX_GHOSTS; ++i)
|
|
|
|
|
+ {
|
|
|
vec2 offset = fract(texcoord + ghostVec * float(i));
|
|
vec2 offset = fract(texcoord + ghostVec * float(i));
|
|
|
|
|
|
|
|
float weight = length(vec2(0.5) - offset) / lenOfHalf;
|
|
float weight = length(vec2(0.5) - offset) / lenOfHalf;
|
|
|
weight = pow(1.0 - weight, 10.0);
|
|
weight = pow(1.0 - weight, 10.0);
|
|
|
|
|
|
|
|
- result +=
|
|
|
|
|
- textureDistorted(uRt, offset, direction, distortion) * weight;
|
|
|
|
|
|
|
+ result +=
|
|
|
|
|
+ textureDistorted(u_rt, offset, direction, distortion) * weight;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// sample halo
|
|
// sample halo
|
|
|
#if ENABLE_HALO
|
|
#if ENABLE_HALO
|
|
|
vec2 haloVec = normalize(ghostVec) * HALO_WIDTH;
|
|
vec2 haloVec = normalize(ghostVec) * HALO_WIDTH;
|
|
|
- float weight =
|
|
|
|
|
|
|
+ float weight =
|
|
|
length(vec2(0.5) - fract(texcoord + haloVec)) / lenOfHalf;
|
|
length(vec2(0.5) - fract(texcoord + haloVec)) / lenOfHalf;
|
|
|
weight = pow(1.0 - weight, 20.0);
|
|
weight = pow(1.0 - weight, 20.0);
|
|
|
- result += textureDistorted(uRt, texcoord + haloVec, direction, distortion)
|
|
|
|
|
- * weight;
|
|
|
|
|
|
|
+ result += textureDistorted(u_rt, texcoord + haloVec, direction, distortion)
|
|
|
|
|
+ * (weight * HALO_OPACITY);
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
// lens dirt
|
|
// lens dirt
|
|
|
- result *= texture(uLensDirtTex, inTexCoord).rgb;
|
|
|
|
|
|
|
+ result *= texture(u_lensDirtTex, in_texCoord).rgb;
|
|
|
|
|
|
|
|
// Write
|
|
// Write
|
|
|
- outColor = result;
|
|
|
|
|
|
|
+ out_color = result;
|
|
|
}
|
|
}
|