Skip to content

Commit

Permalink
feat: improved specular AO
Browse files Browse the repository at this point in the history
  • Loading branch information
doodlum committed Feb 20, 2025
1 parent c7e41c3 commit 1670386
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions package/Shaders/DeferredCompositeCS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ Texture2D<float4> SsgiYTexture : register(t11);
Texture2D<float4> SsgiCoCgTexture : register(t12);
Texture2D<float4> SsgiSpecularTexture : register(t13);

void SampleSSGISpecular(uint2 pixCoord, sh2 lobe, out float ao, out float3 il)
void SampleSSGISpecular(uint2 pixCoord, sh2 lobe, out float ao, out float3 il, in float3 normal, in float3 view)
{
// https://www.iryoku.com/stare-into-the-future/
ao = 1 - SsgiAoTexture[pixCoord];
const float SpecularPow = 8.0;
float NdotV = dot(normal, view);
float s = saturate(-0.3 + NdotV * NdotV);
ao = lerp(pow(ao, SpecularPow), 1.0, s);

float4 ssgiIlYSh = SsgiYTexture[pixCoord];
float ssgiIlY = SphericalHarmonics::FuncProductIntegral(ssgiIlYSh, lobe);
Expand Down Expand Up @@ -153,12 +158,12 @@ void SampleSSGISpecular(uint2 pixCoord, sh2 lobe, out float ao, out float3 il)

float ssgiAo;
float3 ssgiIlSpecular;
SampleSSGISpecular(dispatchID.xy, specularLobe, ssgiAo, ssgiIlSpecular);
SampleSSGISpecular(dispatchID.xy, specularLobe, ssgiAo, ssgiIlSpecular, normalWS, V);

# if defined(VR)
float ssgiAo2;
float3 ssgiIlSpecular2;
SampleSSGISpecular(pixCoord2, specularLobe, ssgiAo2, ssgiIlSpecular2);
SampleSSGISpecular(pixCoord2, specularLobe, ssgiAo2, ssgiIlSpecular2, normalWS, V);
float4 ssgiMixed = Stereo::BlendEyeColors(uv1Mono, float4(ssgiIlSpecular, ssgiAo), uv2Mono, float4(ssgiIlSpecular2, ssgiAo2));
ssgiAo = ssgiMixed.a;
ssgiIlSpecular = ssgiMixed.rgb;
Expand Down

0 comments on commit 1670386

Please sign in to comment.