Optimize SSR a bit more
This commit is contained in:
@@ -7,10 +7,15 @@
|
||||
#include "./Flax/MaterialCommon.hlsl"
|
||||
#include "./Flax/ReflectionsCommon.hlsl"
|
||||
|
||||
// Enable/disable blurring SSR during sampling results and mixing with reflections buffer
|
||||
#define SSR_MIX_BLUR (!defined(PLATFORM_ANDROID) && !defined(PLATFORM_IOS) && !defined(PLATFORM_SWITCH))
|
||||
|
||||
META_CB_BEGIN(0, Data)
|
||||
EnvProbeData PData;
|
||||
float4x4 WVP;
|
||||
GBufferData GBuffer;
|
||||
float2 SSRTexelSize;
|
||||
float2 Dummy0;
|
||||
META_CB_END
|
||||
|
||||
DECLARE_GBUFFERDATA_ACCESS(GBuffer)
|
||||
@@ -18,6 +23,7 @@ DECLARE_GBUFFERDATA_ACCESS(GBuffer)
|
||||
TextureCube Probe : register(t4);
|
||||
Texture2D Reflections : register(t5);
|
||||
Texture2D PreIntegratedGF : register(t6);
|
||||
Texture2D SSR : register(t7);
|
||||
|
||||
// Vertex Shader for probe shape rendering
|
||||
META_VS(true, FEATURE_LEVEL_ES2)
|
||||
@@ -76,6 +82,17 @@ float4 PS_CombinePass(Quad_VS2PS input) : SV_Target0
|
||||
// Sample reflections buffer
|
||||
float3 reflections = SAMPLE_RT(Reflections, input.TexCoord).rgb;
|
||||
|
||||
// Blend with Screen Space Reflections
|
||||
float4 ssr = SSR.SampleLevel(SamplerLinearClamp, input.TexCoord, 0);
|
||||
#if SSR_MIX_BLUR
|
||||
ssr += SSR.SampleLevel(SamplerLinearClamp, input.TexCoord + float2(0, SSRTexelSize.y), 0);
|
||||
ssr += SSR.SampleLevel(SamplerLinearClamp, input.TexCoord - float2(0, SSRTexelSize.y), 0);
|
||||
ssr += SSR.SampleLevel(SamplerLinearClamp, input.TexCoord + float2(SSRTexelSize.x, 0), 0);
|
||||
ssr += SSR.SampleLevel(SamplerLinearClamp, input.TexCoord - float2(SSRTexelSize.x, 0), 0);
|
||||
ssr *= (1.0f / 5.0f);
|
||||
#endif
|
||||
reflections = lerp(reflections, ssr.rgb, saturate(ssr.a));
|
||||
|
||||
// Calculate specular color
|
||||
float3 specularColor = GetSpecularColor(gBuffer);
|
||||
|
||||
|
||||
@@ -14,9 +14,6 @@
|
||||
// Enable/disable luminance filter to reduce reflections highlights
|
||||
#define SSR_REDUCE_HIGHLIGHTS 1
|
||||
|
||||
// Enable/disable blurring SSR during sampling results and mixing with reflections buffer
|
||||
#define SSR_MIX_BLUR (!defined(PLATFORM_ANDROID) && !defined(PLATFORM_IOS) && !defined(PLATFORM_SWITCH))
|
||||
|
||||
META_CB_BEGIN(0, Data)
|
||||
GBufferData GBuffer;
|
||||
float MaxColorMiplevel;
|
||||
@@ -264,24 +261,3 @@ float4 PS_TemporalPass(Quad_VS2PS input) : SV_Target0
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
// Pixel Shader for screen space reflections rendering - mix pass
|
||||
META_PS(true, FEATURE_LEVEL_ES2)
|
||||
float4 PS_MixPass(Quad_VS2PS input) : SV_Target0
|
||||
{
|
||||
// Inputs:
|
||||
// Texture0 - final SSR reflections buffer
|
||||
|
||||
float4 ssr = Texture0.SampleLevel(SamplerLinearClamp, input.TexCoord, 0);
|
||||
|
||||
#if SSR_MIX_BLUR
|
||||
ssr += Texture0.SampleLevel(SamplerLinearClamp, input.TexCoord + float2(0, SSRtexelSize.y), 0);
|
||||
ssr += Texture0.SampleLevel(SamplerLinearClamp, input.TexCoord - float2(0, SSRtexelSize.y), 0);
|
||||
ssr += Texture0.SampleLevel(SamplerLinearClamp, input.TexCoord + float2(SSRtexelSize.x, 0), 0);
|
||||
ssr += Texture0.SampleLevel(SamplerLinearClamp, input.TexCoord - float2(SSRtexelSize.x, 0), 0);
|
||||
ssr *= (1.0f / 5.0f);
|
||||
#endif
|
||||
|
||||
ssr.a = saturate(ssr.a);
|
||||
return ssr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user