Skip to content

Commit

Permalink
feat: add simple specular ao
Browse files Browse the repository at this point in the history
  • Loading branch information
Pentalimbed committed Dec 15, 2024
1 parent 26966ba commit b3350ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
22 changes: 15 additions & 7 deletions package/Shaders/DeferredCompositeCS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ Texture3D<sh2> SkylightingProbeArray : register(t9);
#endif

#if defined(SSGI)
Texture2D<half4> SsgiYTexture : register(t10);
Texture2D<half4> SsgiCoCgTexture : register(t11);
Texture2D<half4> SsgiAoTexture : register(t10);
Texture2D<half4> SsgiYTexture : register(t11);
Texture2D<half4> SsgiCoCgTexture : register(t12);

void SampleSSGISpecular(uint2 pixCoord, sh2 lobe, out half3 il)
void SampleSSGISpecular(uint2 pixCoord, sh2 lobe, out half ao, out half3 il)
{
ao = 1 - SsgiAoTexture[pixCoord];
ao = pow(ao, 0.25);

half4 ssgiIlYSh = SsgiYTexture[pixCoord];
half ssgiIlY = SphericalHarmonics::FuncProductIntegral(ssgiIlYSh, lobe);
half2 ssgiIlCoCg = SsgiCoCgTexture[pixCoord];
Expand Down Expand Up @@ -156,16 +160,20 @@ void SampleSSGISpecular(uint2 pixCoord, sh2 lobe, out half3 il)
uint2 pixCoord2 = (uint2)(uv2.xy / SharedData::BufferDim.zw - 0.5);
# endif

half ssgiAo;
half3 ssgiIlSpecular;
SampleSSGISpecular(dispatchID.xy, specularLobe, ssgiIlSpecular);
SampleSSGISpecular(dispatchID.xy, specularLobe, ssgiAo, ssgiIlSpecular);

# if defined(VR)
half ssgiAo2;
half3 ssgiIlSpecular2;
SampleSSGISpecular(pixCoord2, specularLobe, ssgiIlSpecular2);
ssgiIlSpecular = Stereo::BlendEyeColors(uv1Mono, float4(ssgiIlSpecular, 0), uv2Mono, float4(ssgiIlSpecular2, 0)).rgb;
SampleSSGISpecular(pixCoord2, specularLobe, ssgiAo2, ssgiIlSpecular2);
half4 ssgiMixed = Stereo::BlendEyeColors(uv1Mono, float4(ssgiIlSpecular, ssgiAo), uv2Mono, float4(ssgiIlSpecular2, ssgiAo2));
ssgiAo = ssgiMixed.a;
ssgiIlSpecular = ssgiMixed.rgb;
# endif

finalIrradiance += ssgiIlSpecular;
finalIrradiance = finalIrradiance * ssgiAo + ssgiIlSpecular;
# endif

color += reflectance * finalIrradiance;
Expand Down
3 changes: 2 additions & 1 deletion src/Deferred.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ void Deferred::DeferredPasses()
{
TracyD3D11Zone(State::GetSingleton()->tracyCtx, "Deferred Composite");

ID3D11ShaderResourceView* srvs[12]{
ID3D11ShaderResourceView* srvs[13]{
specular.SRV,
albedo.SRV,
normalRoughness.SRV,
Expand All @@ -419,6 +419,7 @@ void Deferred::DeferredPasses()
dynamicCubemaps->loaded ? dynamicCubemaps->envTexture->srv.get() : nullptr,
dynamicCubemaps->loaded ? dynamicCubemaps->envReflectionsTexture->srv.get() : nullptr,
dynamicCubemaps->loaded && skylighting->loaded ? skylighting->texProbeArray->srv.get() : nullptr,
ssgi_ao,
ssgi_y,
ssgi_cocg,
};
Expand Down

0 comments on commit b3350ed

Please sign in to comment.