mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 03:53:52 +02:00
Remove all tabs from shaders
This commit is contained in:
parent
2df2bbef46
commit
9a28e04e37
22 changed files with 200 additions and 200 deletions
|
@ -31,29 +31,29 @@ vec4 color_sRGBAToLinear(vec4 srgba) {
|
|||
}
|
||||
|
||||
vec3 color_LinearToYCoCg(vec3 rgb) {
|
||||
// Y = R/4 + G/2 + B/4
|
||||
// Co = R/2 - B/2
|
||||
// Cg = -R/4 + G/2 - B/4
|
||||
return vec3(
|
||||
rgb.x/4.0 + rgb.y/2.0 + rgb.z/4.0,
|
||||
rgb.x/2.0 - rgb.z/2.0,
|
||||
-rgb.x/4.0 + rgb.y/2.0 - rgb.z/4.0
|
||||
);
|
||||
// Y = R/4 + G/2 + B/4
|
||||
// Co = R/2 - B/2
|
||||
// Cg = -R/4 + G/2 - B/4
|
||||
return vec3(
|
||||
rgb.x/4.0 + rgb.y/2.0 + rgb.z/4.0,
|
||||
rgb.x/2.0 - rgb.z/2.0,
|
||||
-rgb.x/4.0 + rgb.y/2.0 - rgb.z/4.0
|
||||
);
|
||||
}
|
||||
|
||||
vec3 color_YCoCgToUnclampedLinear(vec3 ycocg) {
|
||||
// R = Y + Co - Cg
|
||||
// G = Y + Cg
|
||||
// B = Y - Co - Cg
|
||||
return vec3(
|
||||
ycocg.x + ycocg.y - ycocg.z,
|
||||
ycocg.x + ycocg.z,
|
||||
ycocg.x - ycocg.y - ycocg.z
|
||||
);
|
||||
// R = Y + Co - Cg
|
||||
// G = Y + Cg
|
||||
// B = Y - Co - Cg
|
||||
return vec3(
|
||||
ycocg.x + ycocg.y - ycocg.z,
|
||||
ycocg.x + ycocg.z,
|
||||
ycocg.x - ycocg.y - ycocg.z
|
||||
);
|
||||
}
|
||||
|
||||
vec3 color_YCoCgToLinear(vec3 ycocg) {
|
||||
return clamp(color_YCoCgToUnclampedLinear(ycocg), vec3(0.0), vec3(1.0));
|
||||
return clamp(color_YCoCgToUnclampedLinear(ycocg), vec3(0.0), vec3(1.0));
|
||||
}
|
||||
|
||||
<@func declareColorWheel()@>
|
||||
|
|
|
@ -284,14 +284,14 @@ float hifi_noise(in vec2 x) {
|
|||
// https://www.shadertoy.com/view/MdX3Rr
|
||||
// https://en.wikipedia.org/wiki/Fractional_Brownian_motion
|
||||
float hifi_fbm(in vec2 p) {
|
||||
const mat2 m2 = mat2(0.8, -0.6, 0.6, 0.8);
|
||||
float f = 0.0;
|
||||
f += 0.5000 * hifi_noise(p); p = m2 * p * 2.02;
|
||||
f += 0.2500 * hifi_noise(p); p = m2 * p * 2.03;
|
||||
f += 0.1250 * hifi_noise(p); p = m2 * p * 2.01;
|
||||
f += 0.0625 * hifi_noise(p);
|
||||
const mat2 m2 = mat2(0.8, -0.6, 0.6, 0.8);
|
||||
float f = 0.0;
|
||||
f += 0.5000 * hifi_noise(p); p = m2 * p * 2.02;
|
||||
f += 0.2500 * hifi_noise(p); p = m2 * p * 2.03;
|
||||
f += 0.1250 * hifi_noise(p); p = m2 * p * 2.01;
|
||||
f += 0.0625 * hifi_noise(p);
|
||||
|
||||
return f / 0.9375;
|
||||
return f / 0.9375;
|
||||
}
|
||||
|
||||
<@endif@>
|
|
@ -2,11 +2,11 @@
|
|||
#ifdef __cplusplus
|
||||
# define _MAT4 Mat4
|
||||
# define _VEC4 Vec4
|
||||
# define _MUTABLE mutable
|
||||
# define _MUTABLE mutable
|
||||
#else
|
||||
# define _MAT4 mat4
|
||||
# define _VEC4 vec4
|
||||
# define _MUTABLE
|
||||
# define _MUTABLE
|
||||
#endif
|
||||
|
||||
struct _TransformCamera {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
struct Parameters
|
||||
{
|
||||
BT_VEC2 _deltaUV;
|
||||
float _threshold;
|
||||
float _threshold;
|
||||
int _sampleCount;
|
||||
};
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ vec4 unpackDeferredPosition(float depthValue, vec2 texcoord) {
|
|||
// This method to unpack position is fastesst
|
||||
vec4 unpackDeferredPositionFromZdb(vec2 texcoord) {
|
||||
float Zdb = texture(depthMap, texcoord).x;
|
||||
return unpackDeferredPosition(Zdb, texcoord);
|
||||
return unpackDeferredPosition(Zdb, texcoord);
|
||||
}
|
||||
|
||||
vec4 unpackDeferredPositionFromZeye(vec2 texcoord) {
|
||||
|
|
|
@ -38,8 +38,8 @@ struct DeferredFrameTransform {
|
|||
mat4 _projectionMono;
|
||||
mat4 _viewInverse;
|
||||
mat4 _view;
|
||||
mat4 _projectionUnJittered[2];
|
||||
mat4 _invProjectionUnJittered[2];
|
||||
mat4 _projectionUnJittered[2];
|
||||
mat4 _invProjectionUnJittered[2];
|
||||
};
|
||||
|
||||
layout(binding=RENDER_UTILS_BUFFER_DEFERRED_FRAME_TRANSFORM) uniform deferredFrameTransformBuffer {
|
||||
|
@ -68,10 +68,10 @@ mat4 getProjectionMono() {
|
|||
return frameTransform._projectionMono;
|
||||
}
|
||||
mat4 getUnjitteredProjection(int side) {
|
||||
return frameTransform._projectionUnJittered[side];
|
||||
return frameTransform._projectionUnJittered[side];
|
||||
}
|
||||
mat4 getUnjitteredInvProjection(int side) {
|
||||
return frameTransform._invProjectionUnJittered[side];
|
||||
return frameTransform._invProjectionUnJittered[side];
|
||||
}
|
||||
|
||||
// positive near distance of the projection
|
||||
|
@ -158,7 +158,7 @@ vec3 evalUnjitteredEyePositionFromZdb(int side, float Zdb, vec2 texcoord) {
|
|||
}
|
||||
|
||||
vec3 evalEyePositionFromZeye(int side, float Zeye, vec2 texcoord) {
|
||||
float Zdb = evalZdbFromZeye(Zeye);
|
||||
float Zdb = evalZdbFromZeye(Zeye);
|
||||
return evalEyePositionFromZdb(side, Zdb, texcoord);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
|
||||
struct FadeParameters
|
||||
{
|
||||
VEC4 _noiseInvSizeAndLevel;
|
||||
VEC4 _innerEdgeColor;
|
||||
VEC4 _outerEdgeColor;
|
||||
VEC2 _edgeWidthInvWidth;
|
||||
FLOAT32 _baseLevel;
|
||||
INT32 _isInverted;
|
||||
VEC4 _noiseInvSizeAndLevel;
|
||||
VEC4 _innerEdgeColor;
|
||||
VEC4 _outerEdgeColor;
|
||||
VEC2 _edgeWidthInvWidth;
|
||||
FLOAT32 _baseLevel;
|
||||
INT32 _isInverted;
|
||||
};
|
||||
|
||||
// <@if 1@>
|
||||
|
|
|
@ -45,7 +45,7 @@ struct ShadowSampleOffsets {
|
|||
};
|
||||
|
||||
ShadowSampleOffsets evalShadowFilterOffsets(vec4 position) {
|
||||
float shadowScale = getShadowScale();
|
||||
float shadowScale = getShadowScale();
|
||||
ShadowSampleOffsets offsets;
|
||||
|
||||
#if SHADOW_SCREEN_SPACE_DITHER
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<@include Shadows_shared.slh@>
|
||||
|
||||
layout(std140, binding=RENDER_UTILS_BUFFER_SHADOW_PARAMS) uniform shadowTransformBuffer {
|
||||
ShadowParameters shadow;
|
||||
ShadowParameters shadow;
|
||||
};
|
||||
|
||||
int getShadowCascadeCount() {
|
||||
|
@ -30,26 +30,26 @@ float evalShadowFalloff(float depth) {
|
|||
}
|
||||
|
||||
mat4 getShadowReprojection(int cascadeIndex) {
|
||||
return shadow.cascades[cascadeIndex].reprojection;
|
||||
return shadow.cascades[cascadeIndex].reprojection;
|
||||
}
|
||||
|
||||
float getShadowScale() {
|
||||
return shadow.invMapSize;
|
||||
return shadow.invMapSize;
|
||||
}
|
||||
|
||||
float getShadowFixedBias(int cascadeIndex) {
|
||||
return shadow.cascades[cascadeIndex].fixedBias;
|
||||
return shadow.cascades[cascadeIndex].fixedBias;
|
||||
}
|
||||
|
||||
float getShadowSlopeBias(int cascadeIndex) {
|
||||
return shadow.cascades[cascadeIndex].slopeBias;
|
||||
return shadow.cascades[cascadeIndex].slopeBias;
|
||||
}
|
||||
|
||||
|
||||
// Compute the texture coordinates from world coordinates
|
||||
vec4 evalShadowTexcoord(int cascadeIndex, vec4 position) {
|
||||
vec4 shadowCoord = getShadowReprojection(cascadeIndex) * position;
|
||||
return vec4(shadowCoord.xyz, 1.0);
|
||||
vec4 shadowCoord = getShadowReprojection(cascadeIndex) * position;
|
||||
return vec4(shadowCoord.xyz, 1.0);
|
||||
}
|
||||
|
||||
bool isShadowCascadeProjectedOnPixel(vec4 cascadeTexCoords) {
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#define SHADOW_CASCADE_MAX_COUNT 4
|
||||
|
||||
struct ShadowTransform {
|
||||
MAT4 reprojection;
|
||||
float fixedBias;
|
||||
MAT4 reprojection;
|
||||
float fixedBias;
|
||||
float slopeBias;
|
||||
float _padding1;
|
||||
float _padding2;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
struct DebugParameters
|
||||
{
|
||||
INT32 _shadowCascadeIndex;
|
||||
INT32 _shadowCascadeIndex;
|
||||
};
|
||||
|
||||
// <@if 1@>
|
||||
|
|
|
@ -44,7 +44,7 @@ void main(void) {
|
|||
|
||||
sharpenedPixel = pixels[4]*6.8 - (pixels[1]+pixels[3]+pixels[5]+pixels[7]) - (pixels[0]+pixels[2]+pixels[6]+pixels[8])*0.7;
|
||||
|
||||
vec4 minColor = max(vec4(0), pixels[4]-vec4(0.5));
|
||||
vec4 maxColor = pixels[4]+vec4(0.5);
|
||||
vec4 minColor = max(vec4(0), pixels[4]-vec4(0.5));
|
||||
vec4 maxColor = pixels[4]+vec4(0.5);
|
||||
outFragColor = clamp(pixels[4] + sharpenedPixel * params.sharpenIntensity, minColor, maxColor);
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ void main(void) {
|
|||
float alpha = 1.0 - abs(distanceFromCenter);
|
||||
|
||||
// Convert from a linear alpha curve to a sharp peaked one
|
||||
alpha = _color.a * pow(alpha, 10.0);
|
||||
|
||||
// Drop everything where the curve falls off to nearly nothing
|
||||
alpha = _color.a * pow(alpha, 10.0);
|
||||
|
||||
// Drop everything where the curve falls off to nearly nothing
|
||||
if (alpha <= 0.05) {
|
||||
discard;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ void main(void) {
|
|||
1.0,
|
||||
occlusionTex,
|
||||
fragPositionES,
|
||||
fragPositionWS,
|
||||
fragPositionWS,
|
||||
albedo,
|
||||
fresnel,
|
||||
metallic,
|
||||
|
|
|
@ -97,7 +97,7 @@ void main(void) {
|
|||
1.0,
|
||||
occlusionTex,
|
||||
fragPositionES,
|
||||
fragPositionWS,
|
||||
fragPositionWS,
|
||||
albedo,
|
||||
fresnel,
|
||||
metallic,
|
||||
|
|
|
@ -54,12 +54,12 @@ void main() {
|
|||
vec2 dxTexCoord = dFdx(_texCoord0) * 0.5 * taaBias;
|
||||
vec2 dyTexCoord = dFdy(_texCoord0) * 0.5 * taaBias;
|
||||
|
||||
// Perform 4x supersampling for anisotropic filtering
|
||||
// Perform 4x supersampling for anisotropic filtering
|
||||
float a;
|
||||
a = evalSDF(_texCoord0);
|
||||
a += evalSDF(_texCoord0+dxTexCoord);
|
||||
a += evalSDF(_texCoord0+dyTexCoord);
|
||||
a += evalSDF(_texCoord0+dxTexCoord+dyTexCoord);
|
||||
a = evalSDF(_texCoord0);
|
||||
a += evalSDF(_texCoord0+dxTexCoord);
|
||||
a += evalSDF(_texCoord0+dyTexCoord);
|
||||
a += evalSDF(_texCoord0+dxTexCoord+dyTexCoord);
|
||||
a *= 0.25;
|
||||
|
||||
// discard if invisible
|
||||
|
|
|
@ -16,7 +16,7 @@ layout(binding=0) uniform sampler2D depthMap;
|
|||
layout(location=0) out vec4 outFragColor;
|
||||
|
||||
void main(void) {
|
||||
float Zdb = texelFetch(depthMap, ivec2(gl_FragCoord.xy), 0).x;
|
||||
outFragColor = vec4(Zdb, 0.0, 0.0, 1.0);
|
||||
float Zdb = texelFetch(depthMap, ivec2(gl_FragCoord.xy), 0).x;
|
||||
outFragColor = vec4(Zdb, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,10 +24,10 @@ layout(binding=RENDER_UTILS_TEXTURE_TAA_NEXT) uniform sampler2D nextMap;
|
|||
|
||||
struct TAAParams
|
||||
{
|
||||
float none;
|
||||
float blend;
|
||||
float covarianceGamma;
|
||||
float debugShowVelocityThreshold;
|
||||
float none;
|
||||
float blend;
|
||||
float covarianceGamma;
|
||||
float debugShowVelocityThreshold;
|
||||
ivec4 flags;
|
||||
vec4 pixelInfo_orbZoom;
|
||||
vec4 regionInfo;
|
||||
|
@ -77,47 +77,47 @@ vec2 taa_getRegionFXAA() {
|
|||
#define USE_YCOCG 1
|
||||
|
||||
vec4 taa_fetchColor(sampler2D map, vec2 uv) {
|
||||
vec4 c = texture(map, uv);
|
||||
// Apply rapid pseudo tonemapping as TAA is applied to a tonemapped image, using luminance as weight, as proposed in
|
||||
// https://de45xmedrsdbp.cloudfront.net/Resources/files/TemporalAA_small-59732822.pdf
|
||||
float lum = dot(vec3(0.3,0.5,0.2),c.rgb);
|
||||
c.rgb = c.rgb / (1.0+lum);
|
||||
vec4 c = texture(map, uv);
|
||||
// Apply rapid pseudo tonemapping as TAA is applied to a tonemapped image, using luminance as weight, as proposed in
|
||||
// https://de45xmedrsdbp.cloudfront.net/Resources/files/TemporalAA_small-59732822.pdf
|
||||
float lum = dot(vec3(0.3,0.5,0.2),c.rgb);
|
||||
c.rgb = c.rgb / (1.0+lum);
|
||||
#if USE_YCOCG
|
||||
return vec4(color_LinearToYCoCg(c.rgb), c.a);
|
||||
return vec4(color_LinearToYCoCg(c.rgb), c.a);
|
||||
#else
|
||||
return c;
|
||||
return c;
|
||||
#endif
|
||||
}
|
||||
|
||||
vec3 taa_resolveColor(vec3 color) {
|
||||
#if USE_YCOCG
|
||||
color = max(vec3(0), color_YCoCgToUnclampedLinear(color));
|
||||
color = max(vec3(0), color_YCoCgToUnclampedLinear(color));
|
||||
#endif
|
||||
// Apply rapid inverse tonemapping, using luminance as weight, as proposed in
|
||||
// https://de45xmedrsdbp.cloudfront.net/Resources/files/TemporalAA_small-59732822.pdf
|
||||
float lum = dot(vec3(0.3,0.5,0.2),color.rgb);
|
||||
color = color / (1.0-lum);
|
||||
return color;
|
||||
// Apply rapid inverse tonemapping, using luminance as weight, as proposed in
|
||||
// https://de45xmedrsdbp.cloudfront.net/Resources/files/TemporalAA_small-59732822.pdf
|
||||
float lum = dot(vec3(0.3,0.5,0.2),color.rgb);
|
||||
color = color / (1.0-lum);
|
||||
return color;
|
||||
}
|
||||
|
||||
vec4 taa_fetchSourceMap(vec2 uv) {
|
||||
return taa_fetchColor(sourceMap, uv);
|
||||
return taa_fetchColor(sourceMap, uv);
|
||||
}
|
||||
|
||||
vec4 taa_fetchHistoryMap(vec2 uv) {
|
||||
return taa_fetchColor(historyMap, uv);
|
||||
return taa_fetchColor(historyMap, uv);
|
||||
}
|
||||
|
||||
vec4 taa_fetchNextMap(vec2 uv) {
|
||||
return taa_fetchColor(nextMap, uv);
|
||||
return taa_fetchColor(nextMap, uv);
|
||||
}
|
||||
|
||||
vec2 taa_fetchVelocityMap(vec2 uv) {
|
||||
return texture(velocityMap, uv).xy;
|
||||
return texture(velocityMap, uv).xy;
|
||||
}
|
||||
|
||||
float taa_fetchDepth(vec2 uv) {
|
||||
return -texture(depthMap, vec2(uv), 0).x;
|
||||
return -texture(depthMap, vec2(uv), 0).x;
|
||||
}
|
||||
|
||||
|
||||
|
@ -141,35 +141,35 @@ vec2 taa_getTexelSize() {
|
|||
|
||||
vec3 taa_findClosestFragment3x3(vec2 uv)
|
||||
{
|
||||
vec2 dd = abs(taa_getTexelSize());
|
||||
vec2 du = vec2(dd.x, 0.0);
|
||||
vec2 dv = vec2(0.0, dd.y);
|
||||
vec2 dd = abs(taa_getTexelSize());
|
||||
vec2 du = vec2(dd.x, 0.0);
|
||||
vec2 dv = vec2(0.0, dd.y);
|
||||
|
||||
vec3 dtl = vec3(-1, -1, taa_fetchDepth(uv - dv - du));
|
||||
vec3 dtc = vec3( 0, -1, taa_fetchDepth(uv - dv));
|
||||
vec3 dtr = vec3( 1, -1, taa_fetchDepth(uv - dv + du));
|
||||
vec3 dtl = vec3(-1, -1, taa_fetchDepth(uv - dv - du));
|
||||
vec3 dtc = vec3( 0, -1, taa_fetchDepth(uv - dv));
|
||||
vec3 dtr = vec3( 1, -1, taa_fetchDepth(uv - dv + du));
|
||||
|
||||
vec3 dml = vec3(-1, 0, taa_fetchDepth(uv - du));
|
||||
vec3 dmc = vec3( 0, 0, taa_fetchDepth(uv));
|
||||
vec3 dmr = vec3( 1, 0, taa_fetchDepth(uv + du));
|
||||
vec3 dml = vec3(-1, 0, taa_fetchDepth(uv - du));
|
||||
vec3 dmc = vec3( 0, 0, taa_fetchDepth(uv));
|
||||
vec3 dmr = vec3( 1, 0, taa_fetchDepth(uv + du));
|
||||
|
||||
vec3 dbl = vec3(-1, 1, taa_fetchDepth(uv + dv - du));
|
||||
vec3 dbc = vec3( 0, 1, taa_fetchDepth(uv + dv));
|
||||
vec3 dbr = vec3( 1, 1, taa_fetchDepth(uv + dv + du));
|
||||
vec3 dbl = vec3(-1, 1, taa_fetchDepth(uv + dv - du));
|
||||
vec3 dbc = vec3( 0, 1, taa_fetchDepth(uv + dv));
|
||||
vec3 dbr = vec3( 1, 1, taa_fetchDepth(uv + dv + du));
|
||||
|
||||
vec3 dmin = dtl;
|
||||
if (ZCMP_GT(dmin.z, dtc.z)) dmin = dtc;
|
||||
if (ZCMP_GT(dmin.z, dtr.z)) dmin = dtr;
|
||||
vec3 dmin = dtl;
|
||||
if (ZCMP_GT(dmin.z, dtc.z)) dmin = dtc;
|
||||
if (ZCMP_GT(dmin.z, dtr.z)) dmin = dtr;
|
||||
|
||||
if (ZCMP_GT(dmin.z, dml.z)) dmin = dml;
|
||||
if (ZCMP_GT(dmin.z, dmc.z)) dmin = dmc;
|
||||
if (ZCMP_GT(dmin.z, dmr.z)) dmin = dmr;
|
||||
if (ZCMP_GT(dmin.z, dml.z)) dmin = dml;
|
||||
if (ZCMP_GT(dmin.z, dmc.z)) dmin = dmc;
|
||||
if (ZCMP_GT(dmin.z, dmr.z)) dmin = dmr;
|
||||
|
||||
if (ZCMP_GT(dmin.z, dbl.z)) dmin = dbl;
|
||||
if (ZCMP_GT(dmin.z, dbc.z)) dmin = dbc;
|
||||
if (ZCMP_GT(dmin.z, dbr.z)) dmin = dbr;
|
||||
if (ZCMP_GT(dmin.z, dbl.z)) dmin = dbl;
|
||||
if (ZCMP_GT(dmin.z, dbc.z)) dmin = dbc;
|
||||
if (ZCMP_GT(dmin.z, dbr.z)) dmin = dbr;
|
||||
|
||||
return vec3(uv + dd.xy * dmin.xy, dmin.z);
|
||||
return vec3(uv + dd.xy * dmin.xy, dmin.z);
|
||||
}
|
||||
|
||||
vec2 taa_fetchVelocityMapBest(vec2 uv) {
|
||||
|
@ -264,8 +264,8 @@ mat3 taa_evalNeighbourColorVariance(vec3 sourceColor, vec2 fragUV, vec2 fragVelo
|
|||
vec2 texelSize = taa_getTexelSize();
|
||||
|
||||
|
||||
vec2 du = vec2(texelSize.x, 0.0);
|
||||
vec2 dv = vec2(0.0, texelSize.y);
|
||||
vec2 du = vec2(texelSize.x, 0.0);
|
||||
vec2 dv = vec2(0.0, texelSize.y);
|
||||
|
||||
vec3 sampleColor = taa_fetchSourceMap(fragUV - dv - du).rgb;
|
||||
vec3 sumSamples = sampleColor;
|
||||
|
@ -320,72 +320,72 @@ mat3 taa_evalNeighbourColorRegion(vec3 sourceColor, vec2 fragUV, vec2 fragVeloci
|
|||
vec3 cmin, cmax, cavg;
|
||||
|
||||
#if MINMAX_3X3_ROUNDED
|
||||
vec2 du = vec2(texelSize.x, 0.0);
|
||||
vec2 dv = vec2(0.0, texelSize.y);
|
||||
vec2 du = vec2(texelSize.x, 0.0);
|
||||
vec2 dv = vec2(0.0, texelSize.y);
|
||||
|
||||
vec3 ctl = taa_fetchSourceMap(fragUV - dv - du).rgb;
|
||||
vec3 ctc = taa_fetchSourceMap(fragUV - dv).rgb;
|
||||
vec3 ctr = taa_fetchSourceMap(fragUV - dv + du).rgb;
|
||||
vec3 cml = taa_fetchSourceMap(fragUV - du).rgb;
|
||||
vec3 cmc = sourceColor; //taa_fetchSourceMap(fragUV).rgb; // could resuse the same osurce sample isn't it ?
|
||||
vec3 cmr = taa_fetchSourceMap(fragUV + du).rgb;
|
||||
vec3 cbl = taa_fetchSourceMap(fragUV + dv - du).rgb;
|
||||
vec3 cbc = taa_fetchSourceMap(fragUV + dv).rgb;
|
||||
vec3 cbr = taa_fetchSourceMap(fragUV + dv + du).rgb;
|
||||
vec3 ctl = taa_fetchSourceMap(fragUV - dv - du).rgb;
|
||||
vec3 ctc = taa_fetchSourceMap(fragUV - dv).rgb;
|
||||
vec3 ctr = taa_fetchSourceMap(fragUV - dv + du).rgb;
|
||||
vec3 cml = taa_fetchSourceMap(fragUV - du).rgb;
|
||||
vec3 cmc = sourceColor; //taa_fetchSourceMap(fragUV).rgb; // could resuse the same osurce sample isn't it ?
|
||||
vec3 cmr = taa_fetchSourceMap(fragUV + du).rgb;
|
||||
vec3 cbl = taa_fetchSourceMap(fragUV + dv - du).rgb;
|
||||
vec3 cbc = taa_fetchSourceMap(fragUV + dv).rgb;
|
||||
vec3 cbr = taa_fetchSourceMap(fragUV + dv + du).rgb;
|
||||
|
||||
cmin = min(ctl, min(ctc, min(ctr, min(cml, min(cmc, min(cmr, min(cbl, min(cbc, cbr))))))));
|
||||
cmax = max(ctl, max(ctc, max(ctr, max(cml, max(cmc, max(cmr, max(cbl, max(cbc, cbr))))))));
|
||||
cmin = min(ctl, min(ctc, min(ctr, min(cml, min(cmc, min(cmr, min(cbl, min(cbc, cbr))))))));
|
||||
cmax = max(ctl, max(ctc, max(ctr, max(cml, max(cmc, max(cmr, max(cbl, max(cbc, cbr))))))));
|
||||
|
||||
#if MINMAX_3X3_ROUNDED || USE_YCOCG || USE_CLIPPING
|
||||
cavg = (ctl + ctc + ctr + cml + cmc + cmr + cbl + cbc + cbr) / 9.0;
|
||||
#if MINMAX_3X3_ROUNDED || USE_YCOCG || USE_CLIPPING
|
||||
cavg = (ctl + ctc + ctr + cml + cmc + cmr + cbl + cbc + cbr) / 9.0;
|
||||
#elif
|
||||
cavg = (cmin + cmax ) * 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if MINMAX_3X3_ROUNDED
|
||||
vec3 cmin5 = min(ctc, min(cml, min(cmc, min(cmr, cbc))));
|
||||
vec3 cmax5 = max(ctc, max(cml, max(cmc, max(cmr, cbc))));
|
||||
vec3 cavg5 = (ctc + cml + cmc + cmr + cbc) / 5.0;
|
||||
cmin = 0.5 * (cmin + cmin5);
|
||||
cmax = 0.5 * (cmax + cmax5);
|
||||
cavg = 0.5 * (cavg + cavg5);
|
||||
#endif
|
||||
#if MINMAX_3X3_ROUNDED
|
||||
vec3 cmin5 = min(ctc, min(cml, min(cmc, min(cmr, cbc))));
|
||||
vec3 cmax5 = max(ctc, max(cml, max(cmc, max(cmr, cbc))));
|
||||
vec3 cavg5 = (ctc + cml + cmc + cmr + cbc) / 5.0;
|
||||
cmin = 0.5 * (cmin + cmin5);
|
||||
cmax = 0.5 * (cmax + cmax5);
|
||||
cavg = 0.5 * (cavg + cavg5);
|
||||
#endif
|
||||
#else
|
||||
const float _SubpixelThreshold = 0.5;
|
||||
const float _GatherBase = 0.5;
|
||||
const float _GatherSubpixelMotion = 0.1666;
|
||||
const float _SubpixelThreshold = 0.5;
|
||||
const float _GatherBase = 0.5;
|
||||
const float _GatherSubpixelMotion = 0.1666;
|
||||
|
||||
vec2 texel_vel = fragVelocity * imageSize;
|
||||
float texel_vel_mag = length(texel_vel) * -fragZe;
|
||||
float k_subpixel_motion = clamp(_SubpixelThreshold / (0.0001 + texel_vel_mag), 0.0, 1.0);
|
||||
float k_min_max_support = _GatherBase + _GatherSubpixelMotion * k_subpixel_motion;
|
||||
vec2 texel_vel = fragVelocity * imageSize;
|
||||
float texel_vel_mag = length(texel_vel) * -fragZe;
|
||||
float k_subpixel_motion = clamp(_SubpixelThreshold / (0.0001 + texel_vel_mag), 0.0, 1.0);
|
||||
float k_min_max_support = _GatherBase + _GatherSubpixelMotion * k_subpixel_motion;
|
||||
|
||||
vec2 ss_offset01 = k_min_max_support * vec2(-texelSize.x, texelSize.y);
|
||||
vec2 ss_offset11 = k_min_max_support * vec2(texelSize.x, texelSize.y);
|
||||
vec3 c00 = taa_fetchSourceMap(fragUV - ss_offset11).rgb;
|
||||
vec3 c10 = taa_fetchSourceMap(fragUV - ss_offset01).rgb;
|
||||
vec3 c01 = taa_fetchSourceMap(fragUV + ss_offset01).rgb;
|
||||
vec3 c11 = taa_fetchSourceMap(fragUV + ss_offset11).rgb;
|
||||
vec2 ss_offset01 = k_min_max_support * vec2(-texelSize.x, texelSize.y);
|
||||
vec2 ss_offset11 = k_min_max_support * vec2(texelSize.x, texelSize.y);
|
||||
vec3 c00 = taa_fetchSourceMap(fragUV - ss_offset11).rgb;
|
||||
vec3 c10 = taa_fetchSourceMap(fragUV - ss_offset01).rgb;
|
||||
vec3 c01 = taa_fetchSourceMap(fragUV + ss_offset01).rgb;
|
||||
vec3 c11 = taa_fetchSourceMap(fragUV + ss_offset11).rgb;
|
||||
|
||||
cmin = min(c00, min(c10, min(c01, c11)));
|
||||
cmax = max(c00, max(c10, max(c01, c11)));
|
||||
cmin = min(c00, min(c10, min(c01, c11)));
|
||||
cmax = max(c00, max(c10, max(c01, c11)));
|
||||
cavg = (cmin + cmax ) * 0.5;
|
||||
|
||||
#if USE_YCOCG || USE_CLIPPING
|
||||
cavg = (c00 + c10 + c01 + c11) / 4.0;
|
||||
#if USE_YCOCG || USE_CLIPPING
|
||||
cavg = (c00 + c10 + c01 + c11) / 4.0;
|
||||
#elif
|
||||
cavg = (cmin + cmax ) * 0.5;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// shrink chroma min-max
|
||||
#if USE_YCOCG
|
||||
vec2 chroma_extent = vec2(0.25 * 0.5 * (cmax.r - cmin.r));
|
||||
vec2 chroma_center = sourceColor.gb;
|
||||
cmin.yz = chroma_center - chroma_extent;
|
||||
cmax.yz = chroma_center + chroma_extent;
|
||||
cavg.yz = chroma_center;
|
||||
#endif
|
||||
// shrink chroma min-max
|
||||
#if USE_YCOCG
|
||||
vec2 chroma_extent = vec2(0.25 * 0.5 * (cmax.r - cmin.r));
|
||||
vec2 chroma_center = sourceColor.gb;
|
||||
cmin.yz = chroma_center - chroma_extent;
|
||||
cmax.yz = chroma_center + chroma_extent;
|
||||
cavg.yz = chroma_center;
|
||||
#endif
|
||||
|
||||
return mat3(cmin, cmax, cavg);
|
||||
}
|
||||
|
@ -393,22 +393,22 @@ mat3 taa_evalNeighbourColorRegion(vec3 sourceColor, vec2 fragUV, vec2 fragVeloci
|
|||
//#define USE_OPTIMIZATIONS 0
|
||||
|
||||
vec3 taa_clampColor(vec3 colorMin, vec3 colorMax, vec3 colorSource, vec3 color) {
|
||||
const float eps = 0.00001;
|
||||
const float eps = 0.00001;
|
||||
vec3 p = colorSource;
|
||||
vec3 q = color;
|
||||
// note: only clips towards aabb center (but fast!)
|
||||
vec3 p_clip = 0.5 * (colorMax + colorMin);
|
||||
vec3 e_clip = 0.5 * (colorMax - colorMin) + vec3(eps);
|
||||
// note: only clips towards aabb center (but fast!)
|
||||
vec3 p_clip = 0.5 * (colorMax + colorMin);
|
||||
vec3 e_clip = 0.5 * (colorMax - colorMin) + vec3(eps);
|
||||
|
||||
vec3 v_clip = q - p_clip;
|
||||
vec3 v_unit = v_clip.xyz / e_clip;
|
||||
vec3 a_unit = abs(v_unit);
|
||||
float ma_unit = max(a_unit.x, max(a_unit.y, a_unit.z));
|
||||
vec3 v_clip = q - p_clip;
|
||||
vec3 v_unit = v_clip.xyz / e_clip;
|
||||
vec3 a_unit = abs(v_unit);
|
||||
float ma_unit = max(a_unit.x, max(a_unit.y, a_unit.z));
|
||||
|
||||
if (ma_unit > 1.0)
|
||||
return p_clip + v_clip / ma_unit;
|
||||
else
|
||||
return q;// point inside aabb
|
||||
if (ma_unit > 1.0)
|
||||
return p_clip + v_clip / ma_unit;
|
||||
else
|
||||
return q;// point inside aabb
|
||||
}
|
||||
|
||||
vec3 taa_evalConstrainColor(vec3 sourceColor, vec2 sourceUV, vec2 sourceVel, vec3 candidateColor) {
|
||||
|
@ -416,25 +416,25 @@ vec3 taa_evalConstrainColor(vec3 sourceColor, vec2 sourceUV, vec2 sourceVel, vec
|
|||
|
||||
colorMinMaxAvg = taa_evalNeighbourColorVariance(sourceColor, sourceUV, sourceVel);
|
||||
|
||||
// clamp history to neighbourhood of current sample
|
||||
// clamp history to neighbourhood of current sample
|
||||
return taa_clampColor(colorMinMaxAvg[0], colorMinMaxAvg[1], sourceColor, candidateColor);
|
||||
}
|
||||
|
||||
vec3 taa_evalFeedbackColor(vec3 sourceColor, vec3 historyColor, float blendFactor) {
|
||||
const float _FeedbackMin = 0.1;
|
||||
const float _FeedbackMax = 0.9;
|
||||
// feedback weight from unbiased luminance diff (t.lottes)
|
||||
#if USE_YCOCG
|
||||
float lum0 = sourceColor.r;
|
||||
float lum1 = historyColor.r;
|
||||
#else
|
||||
float lum0 = Luminance(sourceColor.rgb);
|
||||
float lum1 = Luminance(historyColor.rgb);
|
||||
#endif
|
||||
float unbiased_diff = abs(lum0 - lum1) / max(lum0, max(lum1, 0.2));
|
||||
float unbiased_weight = 1.0 - unbiased_diff;
|
||||
float unbiased_weight_sqr = unbiased_weight * unbiased_weight;
|
||||
float k_feedback = mix(_FeedbackMin, _FeedbackMax, unbiased_weight_sqr);
|
||||
// feedback weight from unbiased luminance diff (t.lottes)
|
||||
#if USE_YCOCG
|
||||
float lum0 = sourceColor.r;
|
||||
float lum1 = historyColor.r;
|
||||
#else
|
||||
float lum0 = Luminance(sourceColor.rgb);
|
||||
float lum1 = Luminance(historyColor.rgb);
|
||||
#endif
|
||||
float unbiased_diff = abs(lum0 - lum1) / max(lum0, max(lum1, 0.2));
|
||||
float unbiased_weight = 1.0 - unbiased_diff;
|
||||
float unbiased_weight_sqr = unbiased_weight * unbiased_weight;
|
||||
float k_feedback = mix(_FeedbackMin, _FeedbackMax, unbiased_weight_sqr);
|
||||
|
||||
|
||||
vec3 nextColor = mix(historyColor, sourceColor, k_feedback * blendFactor).xyz;
|
||||
|
@ -478,7 +478,7 @@ vec3 taa_evalFXAA(vec2 fragUV) {
|
|||
vec3 rgbSW = texture(sourceMap, fragUV + (vec2(-1.0, +1.0) * texelSize)).xyz;
|
||||
vec3 rgbSE = texture(sourceMap, fragUV + (vec2(+1.0, +1.0) * texelSize)).xyz;
|
||||
vec3 rgbM = texture(sourceMap, fragUV).xyz;
|
||||
|
||||
|
||||
// convert RGB values to luminance
|
||||
vec3 luma = vec3(0.299, 0.587, 0.114);
|
||||
float lumaNW = dot(rgbNW, luma);
|
||||
|
@ -486,11 +486,11 @@ vec3 taa_evalFXAA(vec2 fragUV) {
|
|||
float lumaSW = dot(rgbSW, luma);
|
||||
float lumaSE = dot(rgbSE, luma);
|
||||
float lumaM = dot( rgbM, luma);
|
||||
|
||||
|
||||
// luma range of local neighborhood
|
||||
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
|
||||
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
|
||||
|
||||
|
||||
// direction perpendicular to local luma gradient
|
||||
vec2 dir;
|
||||
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
|
||||
|
@ -502,7 +502,7 @@ vec3 taa_evalFXAA(vec2 fragUV) {
|
|||
float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
|
||||
dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
|
||||
max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * texelSize;
|
||||
|
||||
|
||||
// perform additional texture sampling perpendicular to gradient
|
||||
vec3 rgbA = (1.0 / 2.0) * (
|
||||
texture(sourceMap, fragUV + dir * (1.0 / 3.0 - 0.5)).xyz +
|
||||
|
|
|
@ -23,7 +23,7 @@ void main(void) {
|
|||
|
||||
|
||||
// Pixel being shaded
|
||||
vec3 sourceColor = texture(sourceMap, varTexCoord0).xyz;
|
||||
vec3 sourceColor = texture(sourceMap, varTexCoord0).xyz;
|
||||
|
||||
vec2 imageSize = getWidthHeight(0);
|
||||
vec2 texelSize = getInvWidthHeight();
|
||||
|
@ -124,9 +124,9 @@ void main(void) {
|
|||
|
||||
// draw region splitter
|
||||
if ((abs(distToRegionDebug) < getInvWidthHeight().x) || (abs(distToRegionFXAA) < getInvWidthHeight().x)) {
|
||||
outFragColor.rgb = vec3(1.0, 1.0, 0.0);
|
||||
return;
|
||||
}
|
||||
outFragColor.rgb = vec3(1.0, 1.0, 0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (distToRegionFXAA > 0.0) {
|
||||
return;
|
||||
|
@ -138,7 +138,7 @@ void main(void) {
|
|||
return;
|
||||
}
|
||||
|
||||
outFragColor = vec4(nextColor, 1.0);
|
||||
outFragColor = vec4(nextColor, 1.0);
|
||||
|
||||
vec3 prevColor = nextColor;
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@ void main(void) {
|
|||
ivec4 stereoSide;
|
||||
ivec2 framePixelPos = getPixelPosTexcoordPosAndSide(gl_FragCoord.xy, pixelPos, texcoordPos, stereoSide);
|
||||
|
||||
float Zdb = texelFetch(depthMap, ivec2(gl_FragCoord.xy), 0).x;
|
||||
float Zdb = texelFetch(depthMap, ivec2(gl_FragCoord.xy), 0).x;
|
||||
|
||||
// The position of the pixel fragment in Eye space then in world space
|
||||
// The position of the pixel fragment in Eye space then in world space
|
||||
vec3 eyePos = evalUnjitteredEyePositionFromZdb(stereoSide.x, Zdb, texcoordPos);
|
||||
vec3 worldPos = (getViewInverse() * vec4(eyePos, 1.0)).xyz;
|
||||
vec3 worldPos = (getViewInverse() * vec4(eyePos, 1.0)).xyz;
|
||||
|
||||
vec3 prevEyePos = (getPreviousView() * vec4(worldPos, 1.0)).xyz;
|
||||
vec4 prevClipPos = (getUnjitteredProjection(stereoSide.x) * vec4(prevEyePos, 1.0));
|
||||
|
|
|
@ -36,7 +36,7 @@ void main(void) {
|
|||
vec3 outSpherePos = normalize(vec3(sphereUV, -sqrt(1.0 - sphereR2)));
|
||||
vec3 outNormal = vec3(getViewInverse() * vec4(outSpherePos, 0.0));
|
||||
|
||||
float val = step(SUN_THRESHOLD, dot(-lightDirection, outNormal));
|
||||
float val = step(SUN_THRESHOLD, dot(-lightDirection, outNormal));
|
||||
|
||||
color = lightIrradiance * vec3(val);
|
||||
|
||||
|
@ -45,7 +45,7 @@ void main(void) {
|
|||
vec3 inSpherePos = normalize(vec3(inSphereUV, sqrt(1.0 - dot(inSphereUV.xy, inSphereUV.xy))));
|
||||
vec3 inNormal = vec3(getViewInverse() * vec4(inSpherePos, 0.0));
|
||||
|
||||
vec3 marbleColor = max(lightIrradiance * vec3(dot(-lightDirection, inNormal)), vec3(0.01));
|
||||
vec3 marbleColor = max(lightIrradiance * vec3(dot(-lightDirection, inNormal)), vec3(0.01));
|
||||
color += marbleColor;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ layout(location=0) out vec4 outFragColor;
|
|||
layout(binding=0) uniform sampler2D _icons;
|
||||
vec2 getIconTexcoord(float icon, vec2 uv) {
|
||||
const vec2 ICON_COORD_SIZE = vec2(0.0625, 1.0);
|
||||
return vec2((uv.x + icon) * ICON_COORD_SIZE.x, uv.y * ICON_COORD_SIZE.y);
|
||||
return vec2((uv.x + icon) * ICON_COORD_SIZE.x, uv.y * ICON_COORD_SIZE.y);
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
|
|
Loading…
Reference in a new issue