mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 14:03:17 +02:00
Adding the code for the color clamping
This commit is contained in:
parent
025f7fa0d0
commit
21987c4c5d
3 changed files with 50 additions and 40 deletions
|
@ -20,22 +20,16 @@ layout(location = 0) out vec4 outFragColor;
|
|||
|
||||
void main() {
|
||||
|
||||
vec3 fragUV = taa_findClosestFragment3x3(varTexCoord0);
|
||||
// vec3 fragUV = vec3(varTexCoord0, taa_fetchDepth(varTexCoord0));
|
||||
vec2 fragVel = taa_fetchVelocityMap(fragUV.xy);
|
||||
vec3 sourceColor;
|
||||
vec3 nearFragUV = taa_findClosestFragment3x3(varTexCoord0);
|
||||
vec2 fragVel = taa_fetchVelocityMap(nearFragUV.xy);
|
||||
vec2 fragUV = varTexCoord0;
|
||||
|
||||
/*vec3 sourceColor;
|
||||
vec3 historyColor;
|
||||
//vec3 nextColor = taa_temporalReprojection(fragUV.xy, fragVel, fragUV.z);
|
||||
vec2 prevFragUV = taa_fetchSourceAndHistory(fragUV.xy, fragVel, sourceColor, historyColor);
|
||||
/* vec3 sourceColor = taa_fetchSourceMap(fragUV.xy).xyz;
|
||||
vec2 prevFragUV = fragUV.xy - fragVel;
|
||||
vec3 historyColor = sourceColor;
|
||||
if (!(any(lessThan(prevFragUV, vec2(0.0))) || any(greaterThan(prevFragUV, vec2(1.0))))) {
|
||||
historyColor = taa_fetchHistoryMap(prevFragUV).xyz;
|
||||
}*/
|
||||
|
||||
vec2 prevFragUV = taa_fetchSourceAndHistory(fragUV, fragVel, sourceColor, historyColor);
|
||||
vec3 nextColor = mix(historyColor, sourceColor, params.blend);
|
||||
|
||||
*/
|
||||
vec3 nextColor = taa_temporalReprojection(fragUV, fragVel, nearFragUV.z);
|
||||
|
||||
outFragColor = vec4(nextColor, 1.0);
|
||||
}
|
||||
|
|
|
@ -141,48 +141,52 @@ vec2 taa_fetchSourceAndHistory(vec2 fragUV, vec2 fragVelocity, out vec3 sourceCo
|
|||
return prevFragUV;
|
||||
}
|
||||
|
||||
float Luminance(vec3 rgb) {
|
||||
return rgb.x/4.0 + rgb.y/2.0 + rgb.z/4.0;
|
||||
}
|
||||
|
||||
vec3 taa_temporalReprojection(vec2 fragUV, vec2 fragVelocity, float fragZe)
|
||||
{
|
||||
vec3 sourceColor;
|
||||
vec3 historyColor;
|
||||
vec2 prevFragUV = taa_fetchSourceAndHistory(fragUV, fragVelocity, sourceColor, historyColor);
|
||||
|
||||
vec3 nextColor = mix(historyColor, sourceColor, params.blend);
|
||||
vec4 texel1 = vec4(historyColor, 1.0);
|
||||
vec4 texel0 = vec4(sourceColor, 1.0);
|
||||
|
||||
return taa_resolveColor(nextColor);
|
||||
vec2 imageSize = getWidthHeight(0);
|
||||
vec2 texelSize = getInvWidthHeight();
|
||||
|
||||
/*
|
||||
const float _SubpixelThreshold = 0.5;
|
||||
const float _GatherBase = 0.5;
|
||||
const float _GatherSubpixelMotion = 0.1666;
|
||||
const float _FeedbackMin = 0.1;
|
||||
const float _FeedbackMax = 0.9;
|
||||
|
||||
float2 texel_vel = ss_vel / _MainTex_TexelSize.xy;
|
||||
float texel_vel_mag = length(texel_vel) * fragZe;
|
||||
float k_subpixel_motion = saturate(_SubpixelThreshold / (FLT_EPS + texel_vel_mag));
|
||||
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;
|
||||
|
||||
float2 ss_offset01 = k_min_max_support * float2(-_MainTex_TexelSize.x, _MainTex_TexelSize.y);
|
||||
float2 ss_offset11 = k_min_max_support * float2(_MainTex_TexelSize.x, _MainTex_TexelSize.y);
|
||||
float4 c00 = taa_fetchSourceMap(uv - ss_offset11);
|
||||
float4 c10 = taa_fetchSourceMap(uv - ss_offset01);
|
||||
float4 c01 = taa_fetchSourceMap(uv + ss_offset01);
|
||||
float4 c11 = taa_fetchSourceMap(uv + ss_offset11);
|
||||
vec2 ss_offset01 = k_min_max_support * vec2(-texelSize.x, texelSize.y);
|
||||
vec2 ss_offset11 = k_min_max_support * vec2(texelSize.x, texelSize.y);
|
||||
vec4 c00 = taa_fetchSourceMap(fragUV - ss_offset11);
|
||||
vec4 c10 = taa_fetchSourceMap(fragUV - ss_offset01);
|
||||
vec4 c01 = taa_fetchSourceMap(fragUV + ss_offset01);
|
||||
vec4 c11 = taa_fetchSourceMap(fragUV + ss_offset11);
|
||||
|
||||
float4 cmin = min(c00, min(c10, min(c01, c11)));
|
||||
float4 cmax = max(c00, max(c10, max(c01, c11)));
|
||||
vec4 cmin = min(c00, min(c10, min(c01, c11)));
|
||||
vec4 cmax = max(c00, max(c10, max(c01, c11)));
|
||||
|
||||
#if USE_YCOCG || USE_CLIPPING
|
||||
float4 cavg = (c00 + c10 + c01 + c11) / 4.0;
|
||||
vec4 cavg = (c00 + c10 + c01 + c11) / 4.0;
|
||||
#endif
|
||||
|
||||
#else
|
||||
#error "missing keyword MINMAX_..."
|
||||
#endif
|
||||
|
||||
// shrink chroma min-max
|
||||
#if USE_YCOCG
|
||||
float2 chroma_extent = 0.25 * 0.5 * (cmax.r - cmin.r);
|
||||
float2 chroma_center = texel0.gb;
|
||||
vec2 chroma_extent = 0.25 * 0.5 * (cmax.r - cmin.r);
|
||||
vec2 chroma_center = texel0.gb;
|
||||
cmin.yz = chroma_center - chroma_extent;
|
||||
cmax.yz = chroma_center + chroma_extent;
|
||||
cavg.yz = chroma_center;
|
||||
|
@ -206,11 +210,15 @@ vec3 taa_temporalReprojection(vec2 fragUV, vec2 fragVelocity, float fragZe)
|
|||
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 = lerp(_FeedbackMin, _FeedbackMax, unbiased_weight_sqr);
|
||||
float k_feedback = mix(_FeedbackMin, _FeedbackMax, unbiased_weight_sqr);
|
||||
|
||||
// output
|
||||
return lerp(texel0, texel1, k_feedback);
|
||||
*/
|
||||
vec3 nextColor = mix(texel0, texel1, k_feedback).xyz;
|
||||
|
||||
|
||||
// vec3 nextColor = mix(texel0, texel1, params.blend);
|
||||
|
||||
return taa_resolveColor(nextColor);
|
||||
}
|
||||
|
||||
<$declareColorWheel()$>
|
||||
|
|
|
@ -7,15 +7,23 @@
|
|||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
import QtQuick 2.5
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Layouts 1.3
|
||||
|
||||
import "../lib/styles-uit"
|
||||
//import "../../controls-uit" as HifiControls
|
||||
|
||||
|
||||
import "configSlider"
|
||||
import "../lib/plotperf"
|
||||
|
||||
Column {
|
||||
Rectangle {
|
||||
id: root;
|
||||
// color: hifi.colors.baseGray;
|
||||
|
||||
HifiConstants { id: hifi; }
|
||||
color: hifi.colors.baseGray;
|
||||
|
||||
Column {
|
||||
id: antialiasing
|
||||
|
|
Loading…
Reference in a new issue