5,9c5,9 < #include "../Common.ush" < #include "../Random.ush" < #include "../EyeAdaptationCommon.ush" < #include "../TextureSampling.ush" < #include "../MonteCarlo.ush" --- > #include "Common.ush" > #include "Random.ush" > #include "EyeAdaptationCommon.ush" > #include "TextureSampling.ush" > #include "MonteCarlo.ush" 56a57,60 > /** Qualities */ > #define TAA_QUALITY_LOW 0 > #define TAA_QUALITY_MEDIUM 1 > #define TAA_QUALITY_HIGH 2 74d77 < #define AA_FILTERED 1 79c82,91 < #if !TAA_FAST --- > #if TAA_QUALITY == TAA_QUALITY_LOW > #define AA_FILTERED 0 > #define AA_DYNAMIC_ANTIGHOST 0 > > #elif TAA_QUALITY == TAA_QUALITY_MEDIUM > #define AA_FILTERED 1 > #define AA_DYNAMIC_ANTIGHOST 0 > > #elif TAA_QUALITY == TAA_QUALITY_HIGH > #define AA_FILTERED 1 80a93,95 > > #else > #error Unknown TAA quality 90c105,111 < --- > #elif TAA_PASS_CONFIG == 7 // Used for Hair > #define AA_HISTORY_PAYLOAD (HISTORY_PAYLOAD_RGB_OPACITY) > #define AA_DYNAMIC 1 > #define AA_FILTERED 0 > #define AA_LERP 3 > #define AA_MANUALLY_CLAMP_HISTORY_UV 1 > #define AA_YCOCG 0 116d136 < #define AA_FILTERED TAA_UPSAMPLE_FILTERED 127,133c147,150 < < #if TAA_FAST < // When doing TAA downsampling, still need the 9 samples. < #if AA_DOWNSAMPLE < #define AA_SAMPLES 9 < #else < #if SWITCH_PROFILE || SWITCH_PROFILE_FORWARD || AA_MOBILE_CONFIG --- > > #if TAA_QUALITY == TAA_QUALITY_LOW > #define AA_FILTERED 0 > #if AA_MOBILE_CONFIG 138d154 < #endif 139a156,159 > #elif TAA_QUALITY == TAA_QUALITY_MEDIUM > #define AA_FILTERED 1 > #if AA_MOBILE_CONFIG > #define AA_SAMPLES 5 140a161,164 > #define AA_SAMPLES 6 > #endif > > #elif TAA_QUALITY == TAA_QUALITY_HIGH 141a166 > #define AA_FILTERED 1 144a170,171 > #else > #error Unknown TAA quality 182,183c209,211 < < #if !TAA_FAST --- > > #if TAA_QUALITY == TAA_QUALITY_MEDIUM > #if AA_UPSAMPLE 186,187c214,216 < #define AA_YCOCG 1 < #elif AA_UPSAMPLE --- > #endif > > #elif TAA_QUALITY == TAA_QUALITY_HIGH 189a219,222 > #define AA_YCOCG 1 > > #else > #error Unknown TAA quality 448,449c481,482 < float SampleWeights[9]; < float PlusWeights[5]; --- > DECLARE_SCALAR_ARRAY(float, SampleWeights, 9); > DECLARE_SCALAR_ARRAY(float, PlusWeights, 5); 467a501,503 > #if COMPILER_GLSL_ES3_1 > Texture2D GBufferVelocityTextureSRV; > #else 469a506 > #endif 515a553,572 > #if COMPILER_SUPPORTS_HLSL2021 > > template > void CorrectExposure(inout T X) > { > X *= HistoryPreExposureCorrection; > } > > #endif > > ENCODED_VELOCITY_TYPE SampleVelocityTexture(float2 BufferUV, int2 PixelOffset = int2(0, 0)) > { > #if COMPILER_GLSL_ES3_1 > int2 Coord = int2(BufferUV * InputSceneColorSize.xy) + PixelOffset; > return GBufferVelocityTextureSRV.Load(int3(Coord, 0)); > #else > return GBufferVelocityTexture.SampleLevel(GBufferVelocityTextureSampler, BufferUV, 0, PixelOffset); > #endif > } > 593c650 < RayDir = abs( RayDir ) < (1.0/65536.0) ? (1.0/65536.0) : RayDir; --- > RayDir = select(abs( RayDir ) < (1.0/65536.0), (1.0/65536.0), RayDir); 630a688,698 > float3 QuantizeForFloatRenderTarget(float3 Color, float E, float3 QuantizationError) > { > float3 Error = Color * QuantizationError; > > Error.x = asfloat(asuint(Error.x) & ~0x007FFFFF); > Error.y = asfloat(asuint(Error.y) & ~0x007FFFFF); > Error.z = asfloat(asuint(Error.z) & ~0x007FFFFF); > > return Color + Error * E; > } > 730c798 < // it is allowed to passdown this guy to major function with still unitialized variables. --- > // it is allowed to passdown this to major function with still unitialized variables. 1513c1581 < float SampleSpatialWeight = SampleWeights[i]; --- > float SampleSpatialWeight = GET_SCALAR_ARRAY_ELEMENT(SampleWeights, i); 1516c1584 < float SampleSpatialWeight = PlusWeights[i]; --- > float SampleSpatialWeight = GET_SCALAR_ARRAY_ELEMENT(PlusWeights, i); 1559c1627 < float SampleWeight = SampleWeights[4]; --- > float SampleWeight = GET_SCALAR_ARRAY_ELEMENT(SampleWeights, 4); 1562c1630 < float SampleWeight = PlusWeights[2]; --- > float SampleWeight = GET_SCALAR_ARRAY_ELEMENT(PlusWeights, 2); 1823c1891,1893 < #if USE_PREEXPOSURE --- > #if COMPILER_SUPPORTS_HLSL2021 > CorrectExposure(HistoryPayload.Color.rgb); > #else 1875d1944 < #if USE_PREEXPOSURE 1877,1879d1945 < #else < InputParams.FrameExposureScale = ToScalarMemory(FrameExposureScale); < #endif 2003c2069 < float4 EncodedVelocity = GBufferVelocityTexture.SampleLevel(GBufferVelocityTextureSampler, InputParams.NearestBufferUV + VelocityOffset, 0); --- > ENCODED_VELOCITY_TYPE EncodedVelocity = SampleVelocityTexture(InputParams.NearestBufferUV + VelocityOffset); 2063,2067c2129,2133 < bool Dynamic1 = GBufferVelocityTexture.SampleLevel(GBufferVelocityTextureSampler, InputParams.NearestBufferUV, 0, int2( 0, -1)).x > 0; < bool Dynamic3 = GBufferVelocityTexture.SampleLevel(GBufferVelocityTextureSampler, InputParams.NearestBufferUV, 0, int2(-1, 0)).x > 0; < Dynamic4 = GBufferVelocityTexture.SampleLevel(GBufferVelocityTextureSampler, InputParams.NearestBufferUV, 0).x > 0; < bool Dynamic5 = GBufferVelocityTexture.SampleLevel(GBufferVelocityTextureSampler, InputParams.NearestBufferUV, 0, int2( 1, 0)).x > 0; < bool Dynamic7 = GBufferVelocityTexture.SampleLevel(GBufferVelocityTextureSampler, InputParams.NearestBufferUV, 0, int2( 0, 1)).x > 0; --- > bool Dynamic1 = SampleVelocityTexture(InputParams.NearestBufferUV, int2( 0, -1)).x > 0; > bool Dynamic3 = SampleVelocityTexture(InputParams.NearestBufferUV, int2(-1, 0)).x > 0; > Dynamic4 = SampleVelocityTexture(InputParams.NearestBufferUV).x > 0; > bool Dynamic5 = SampleVelocityTexture(InputParams.NearestBufferUV, int2( 1, 0)).x > 0; > bool Dynamic7 = SampleVelocityTexture(InputParams.NearestBufferUV, int2( 0, 1)).x > 0; 2228c2294,2296 < //------------------------------------------------------- ENTRY POINT --- > //------------------------------------------------------- ENTRY POINTS > > #if COMPUTESHADER 2277c2345 < FinalOutput0.rgb += FinalOutput0.rgb * (E.x * OutputQuantizationError); --- > FinalOutput0.rgb = QuantizeForFloatRenderTarget(FinalOutput0.rgb, E.x, OutputQuantizationError); 2310a2379,2403 > > #elif PIXELSHADER // Mobile Only. > > #if AA_UPSAMPLE > #error Up sample only available to CS. > #endif > > void MainPS( > float4 SvPosition : SV_POSITION, > out float4 OutColor0 : SV_Target0 > ) > { > float2 ViewportUV = (SvPosition.xy - OutputViewportRect.xy) * OutputViewportSize.zw; > > uint2 GroupId = int2(0, 0); > uint2 GroupThreadId = int2(0, 0); > uint GroupThreadIndex = 0; > float FrameExposureScale = EyeAdaptationLookup(); > > FTAAHistoryPayload OutputPayload = TemporalAASample(GroupId, GroupThreadId, GroupThreadIndex, ViewportUV, FrameExposureScale); > > OutColor0 = OutputPayload.Color; > } > > #endif