mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-22 00:37:35 +08:00
intial changes for commit #495
This commit is contained in:
@ -11,7 +11,7 @@ const int colortex6Format = R11F_G11F_B10F; // additionnal buffer for bloom (c
|
||||
const int colortex7Format = RGBA8; // Final output, transparencies id (gbuffer->composite4)
|
||||
const int colortex8Format = RGBA8; // Specular Texture
|
||||
const int colortex9Format = RGBA8; // rain in alpha
|
||||
const int colortex10Format = RGBA16; // resourcepack Skies
|
||||
const int colortex10Format = RGBA16F; // resourcepack Skies
|
||||
const int colortex11Format = RGBA16; // unchanged translucents albedo, alpha and tangent normals
|
||||
const int colortex12Format = RGBA16F; // DISTANT HORIZONS + VANILLA MIXED DEPTHs
|
||||
|
||||
@ -31,7 +31,7 @@ const bool colortex6Clear = false;
|
||||
const bool colortex7Clear = false;
|
||||
const bool colortex8Clear = false;
|
||||
const bool colortex9Clear = true;
|
||||
const bool colortex10Clear = true;
|
||||
const bool colortex10Clear = false;
|
||||
const bool colortex11Clear = true;
|
||||
const bool colortex12Clear = false;
|
||||
const bool colortex13Clear = false;
|
||||
@ -41,11 +41,11 @@ const bool colortex15Clear = false;
|
||||
|
||||
#ifdef SCREENSHOT_MODE
|
||||
/*
|
||||
const int colortex5Format = RGBA32F;// TAA buffer (everything)
|
||||
const int colortex5Format = RGBA32F; //TAA buffer (everything)
|
||||
*/
|
||||
#else
|
||||
/*
|
||||
const int colortex5Format = R11F_G11F_B10F; // TAA buffer (everything)
|
||||
const int colortex5Format = RGBA16F; //TAA buffer (everything)
|
||||
*/
|
||||
#endif
|
||||
|
||||
@ -67,6 +67,7 @@ uniform vec2 texelSize;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float viewHeight;
|
||||
uniform float viewWidth;
|
||||
|
||||
uniform vec3 previousCameraPosition;
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
|
||||
@ -213,6 +214,24 @@ vec4 smoothfilter(in sampler2D tex, in vec2 uv)
|
||||
|
||||
return texture2D(tex, uv);
|
||||
}
|
||||
vec2 smoothfilterUV(in vec2 uv)
|
||||
{
|
||||
vec2 textureResolution = vec2(viewWidth,viewHeight);
|
||||
uv = uv*textureResolution + 0.5;
|
||||
vec2 iuv = floor( uv );
|
||||
vec2 fuv = fract( uv );
|
||||
|
||||
#ifndef SMOOTHESTSTEP_INTERPOLATION
|
||||
uv = iuv + (fuv*fuv)*(3.0-2.0*fuv);
|
||||
#endif
|
||||
#ifdef SMOOTHESTSTEP_INTERPOLATION
|
||||
uv = iuv + fuv*fuv*fuv*(fuv*(fuv*6.0-15.0)+10.0);
|
||||
#endif
|
||||
|
||||
uv = (uv - 0.5)/textureResolution;
|
||||
|
||||
return uv;
|
||||
}
|
||||
//approximation from SMAA presentation from siggraph 2016
|
||||
vec3 FastCatmulRom(sampler2D colorTex, vec2 texcoord, vec4 rtMetrics, float sharpenAmount)
|
||||
{
|
||||
@ -231,15 +250,14 @@ vec3 FastCatmulRom(sampler2D colorTex, vec2 texcoord, vec4 rtMetrics, float shar
|
||||
vec2 w12 = w1 + w2;
|
||||
vec2 tc12 = rtMetrics.xy * (centerPosition + w2 / w12);
|
||||
vec3 centerColor = texture2D(colorTex, vec2(tc12.x, tc12.y)).rgb;
|
||||
|
||||
vec2 tc0 = rtMetrics.xy * (centerPosition - 1.0);
|
||||
vec2 tc3 = rtMetrics.xy * (centerPosition + 2.0);
|
||||
vec4 color = vec4(texture2D(colorTex, vec2(tc12.x, tc0.y )).rgb, 1.0) * (w12.x * w0.y ) +
|
||||
vec4 color = vec4(texture2D(colorTex, vec2(tc12.x, tc0.y )).rgb, 1.0) * (w12.x * w0.y ) +
|
||||
vec4(texture2D(colorTex, vec2(tc0.x, tc12.y)).rgb, 1.0) * (w0.x * w12.y) +
|
||||
vec4(centerColor, 1.0) * (w12.x * w12.y) +
|
||||
vec4(texture2D(colorTex, vec2(tc3.x, tc12.y)).rgb, 1.0) * (w3.x * w12.y) +
|
||||
vec4(texture2D(colorTex, vec2(tc12.x, tc3.y )).rgb, 1.0) * (w12.x * w3.y );
|
||||
|
||||
|
||||
return color.rgb/color.a;
|
||||
|
||||
}
|
||||
@ -314,6 +332,24 @@ vec3 closestToCamera5taps_DH(vec2 texcoord, sampler2D depth, sampler2D dhDepth,
|
||||
return dmin;
|
||||
}
|
||||
|
||||
vec3 RGB2YCoCg(vec3 RGB)
|
||||
{
|
||||
vec3 o;
|
||||
o.x = 0.25*RGB.r + 0.5*RGB.g + 0.25*RGB.b;
|
||||
o.y = 0.5*RGB.r - 0.5*RGB.b;
|
||||
o.z = -0.25*RGB.r + 0.5*RGB.g - 0.25*RGB.b;
|
||||
return o;
|
||||
}
|
||||
|
||||
vec3 YCoCg2RGB(vec3 YCoCg)
|
||||
{
|
||||
vec3 o;
|
||||
o.r = YCoCg.x + YCoCg.y - YCoCg.z;
|
||||
o.g = YCoCg.x + YCoCg.z;
|
||||
o.b = YCoCg.x - YCoCg.y - YCoCg.z;
|
||||
return o;
|
||||
}
|
||||
|
||||
vec4 computeTAA(vec2 texcoord, bool hand){
|
||||
|
||||
vec2 jitter = offsets[framemod8]*texelSize*0.5;
|
||||
@ -340,9 +376,9 @@ vec4 computeTAA(vec2 texcoord, bool hand){
|
||||
|
||||
vec2 velocity = previousPosition.xy - closestToCamera.xy;
|
||||
previousPosition.xy = texcoord + velocity;
|
||||
|
||||
// sample current frame, and make sure it is de-jittered
|
||||
vec3 currentFrame = smoothfilter(colortex3, adjTC + jitter).rgb;
|
||||
// vec3 currentFrame = smoothfilter(colortex3, adjTC + jitter).rgb;
|
||||
vec3 currentFrame = texelFetch2D(colortex3, ivec2((adjTC + jitter)/texelSize), 0).rgb;
|
||||
|
||||
//reject history if off-screen and early exit
|
||||
if (previousPosition.x < 0.0 || previousPosition.y < 0.0 || previousPosition.x > 1.0 || previousPosition.y > 1.0) return vec4(currentFrame, 1.0);
|
||||
@ -366,14 +402,13 @@ vec4 computeTAA(vec2 texcoord, bool hand){
|
||||
vec3 colMax = max(col0,max(col1,max(col2,max(col3, max(col4, max(col5, max(col6, max(col7, col8))))))));
|
||||
vec3 colMin = min(col0,min(col1,min(col2,min(col3, min(col4, min(col5, min(col6, min(col7, col8))))))));
|
||||
|
||||
vec3 colMax5 = max(col0,max(col5,max(col6,max(col7,col8))));
|
||||
vec3 colMin5 = min(col0,min(col5,min(col6,min(col7,col8))));
|
||||
colMin = 0.5 * (colMin + min(col0,min(col5,min(col6,min(col7,col8)))));
|
||||
colMax = 0.5 * (colMax + max(col0,max(col5,max(col6,max(col7,col8)))));
|
||||
|
||||
colMin = 0.5 * (colMin + colMin5);
|
||||
colMax = 0.5 * (colMax + colMax5);
|
||||
#endif
|
||||
|
||||
#ifdef DAMAGE_TAKEN_EFFECT
|
||||
// when this triggers, use current frame UV to sample history, for a funny trailing effect.
|
||||
////// when this triggers, use current frame UV to sample history, for a funny trailing effect.
|
||||
if(CriticalDamageTaken > 0.01) previousPosition.xy = texcoord;
|
||||
#endif
|
||||
|
||||
@ -383,14 +418,17 @@ vec4 computeTAA(vec2 texcoord, bool hand){
|
||||
float blendingFactor = BLEND_FACTOR;
|
||||
if(hand) blendingFactor = clamp(length(velocity/texelSize),blendingFactor,1.0);
|
||||
|
||||
//Increases blending factor when far from AABB, reduces ghosting
|
||||
blendingFactor = min(blendingFactor + luma(min(max(clampedframeHistory - frameHistory,0.0) / frameHistory, 1.0)),1.0);
|
||||
////// Increases blending factor when far from AABB, reduces ghosting
|
||||
// blendingFactor = min(blendingFactor + luma(min(max(clampedframeHistory-frameHistory,0.0) / frameHistory, 1.0)),1.0);
|
||||
// blendingFactor = min(blendingFactor + luma(abs(clampedframeHistory - frameHistory)/clampedframeHistory) ,1.0);
|
||||
|
||||
// Blend current pixel with clamped history, apply fast tonemap beforehand to reduce flickering
|
||||
// if(luma(abs(clampedframeHistory - frameHistory)) > 0.01) blendingFactor = 1.0;
|
||||
|
||||
////// Blend current pixel with clamped history, apply fast tonemap beforehand to reduce flickering
|
||||
vec3 finalResult = invTonemap(mix(tonemap(clampedframeHistory), tonemap(currentFrame), blendingFactor));
|
||||
|
||||
#ifdef DAMAGE_TAKEN_EFFECT
|
||||
// when this triggers, do a funny trailing effect.
|
||||
////// when this triggers, do a funny trailing effect.
|
||||
if(CriticalDamageTaken > 0.01) finalResult = mix(finalResult, frameHistory, sqrt(CriticalDamageTaken)*0.8);
|
||||
#endif
|
||||
#ifdef SCREENSHOT_MODE
|
||||
@ -418,14 +456,10 @@ void main() {
|
||||
|
||||
// vec4 color = TAA_hq(hand);
|
||||
|
||||
vec4 color = computeTAA(texcoord, hand);
|
||||
vec4 color = computeTAA(smoothfilterUV(texcoord), hand);
|
||||
|
||||
// gl_FragData[0] = clamp(color, 0.0, 65000.0);
|
||||
|
||||
#if DEBUG_VIEW == debug_TEMPORAL_REPROJECTION
|
||||
color.rgb = texture2D(colortex3, taauTC).rgb;
|
||||
#endif
|
||||
|
||||
#ifdef SCREENSHOT_MODE
|
||||
gl_FragData[0] = clamp(color, 0.0, 65000.0);
|
||||
#else
|
||||
|
Reference in New Issue
Block a user