1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00
OpenMW/files/shaders/lib/util/distortion.glsl

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

33 lines
737 B
Plaintext
Raw Normal View History

2023-11-10 08:02:53 -08:00
#ifndef LIB_UTIL_DISTORTION
#define LIB_UTIL_DISTORTION
vec4 applyDistortion(in vec4 color, in float strength, in float pixelDepth, in float sceneDepth)
{
vec4 distortion = color;
float invOcclusion = 1.0;
// TODO: Investigate me. Alpha-clipping is enabled for refraction for what seems an arbitrary threshold, even when
// there are no associated NIF properties.
if (distortion.a < 0.1)
discard;
distortion.b = 0.0;
#if @reverseZ
if (pixelDepth < sceneDepth)
#else
if (pixelDepth > sceneDepth)
#endif
{
invOcclusion = 0.0;
distortion.b = 1.0;
}
distortion.rg = color.rg * 2.0 - 1.0;
distortion.rg *= invOcclusion * strength;
return distortion;
}
#endif