-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: sh skylighting, fixes and cleanup (#334)
* feat: spherical harmonic skylighting * chore: reduced wetness light intensity * chore: optimise setting constant buffers * fix: disable VRS * style: 🎨 apply clang-format changes * chore: performance improvements * fix: water reflections * fix: skylighting flicker * style: 🎨 apply clang-format changes * chore: minor cleanup * chore: convolve and ZH3 hallucination for diffuse skylighitng * chore: skylighting cleanup * fix: SSS crash * fix: incorrect reflections * style: 🎨 apply clang-format changes * fix: reflection and shadow fixes * style: 🎨 apply clang-format changes * feat: cubemap optimisation * chore: use correct depth buffer * fix: wetness edge seam * chore: cleaned up legacy code pending further changes * style: 🎨 apply clang-format changes * style: 🎨 apply clang-format changes * fix: minor wetness issues * style: 🎨 apply clang-format changes * fix: fix VR in skylighting-sh branch * feat: adjustments to improve dynamic cubemaps after quality reduction * style: 🎨 apply clang-format changes * fix: fix AE support * chore: dynamic cubemap tweaks * chore: more contrast to specular skylighting * style: 🎨 apply clang-format changes * fix: dynamic cubemap feedback loop * fix: dynamic cubemap fade fixes * style: 🎨 apply clang-format changes * fix: reset dynamic cubemap when shaders are missing * feat: GetTemporal utility function * feat: skylighting optimisation and blur pass * feat: low precision depth buffer * style: 🎨 apply clang-format changes * fix: skylighting position adjust * feat: low precision depth when available * refactor: lower case frameCount * style: 🎨 apply clang-format changes * chore: artistic tweaks to skylighting application * style: 🎨 apply clang-format changes * feat: skylighting update timer * feat: skylighting and ambient improvements * style: 🎨 apply clang-format changes * refactor: switch on UpdateCubemap * refactor: divide instead of multiply * chore: remove unused CameraData --------- Co-authored-by: doodlum <doodlum@users.noreply.github.com> Co-authored-by: Pentalimbed <pentalimbed@gmail.com> Co-authored-by: FlayaN <hannes.feldt@gmail.com>
- Loading branch information
1 parent
45456de
commit 52ccd51
Showing
44 changed files
with
1,043 additions
and
712 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
features/Skylighting/Shaders/Skylighting/SkylightingBlurCS.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include "../Common/FrameBuffer.hlsl" | ||
#include "../Common/GBuffer.hlsli" | ||
#include "../Common/VR.hlsli" | ||
|
||
Texture2D<half> DepthTexture : register(t0); | ||
|
||
Texture2D<half4> SkylightingTexture : register(t1); | ||
RWTexture2D<float4> SkylightingTextureRW : register(u0); | ||
|
||
cbuffer PerFrame : register(b0) | ||
{ | ||
row_major float4x4 OcclusionViewProj; | ||
float4 EyePosition; | ||
float4 ShadowDirection; | ||
float4 BufferDim; | ||
float4 CameraData; | ||
uint FrameCount; | ||
}; | ||
|
||
SamplerState LinearSampler : register(s0); | ||
|
||
half GetScreenDepth(half depth) | ||
{ | ||
return (CameraData.w / (-depth * CameraData.z + CameraData.x)); | ||
} | ||
|
||
// samples = 8, min distance = 0.5, average samples on radius = 2 | ||
static const float3 g_Poisson8[8] = { | ||
float3(-0.4706069, -0.4427112, +0.6461146), | ||
float3(-0.9057375, +0.3003471, +0.9542373), | ||
float3(-0.3487388, +0.4037880, +0.5335386), | ||
float3(+0.1023042, +0.6439373, +0.6520134), | ||
float3(+0.5699277, +0.3513750, +0.6695386), | ||
float3(+0.2939128, -0.1131226, +0.3149309), | ||
float3(+0.7836658, -0.4208784, +0.8895339), | ||
float3(+0.1564120, -0.8198990, +0.8346850) | ||
}; | ||
|
||
[numthreads(8, 8, 1)] void main(uint3 globalId | ||
: SV_DispatchThreadID) { | ||
half2 uv = half2(globalId.xy + 0.5) * (BufferDim.zw) * DynamicResolutionParams2.xy; | ||
uint eyeIndex = GetEyeIndexFromTexCoord(uv); | ||
|
||
half4 skylightingSH = 0; | ||
half weight = 0.0; | ||
|
||
half rawDepth = DepthTexture[globalId.xy]; | ||
half depth = GetScreenDepth(rawDepth); | ||
|
||
[unroll] for (uint i = 0; i < 8; i++) | ||
{ | ||
|
||
#if defined(HORIZONTAL) | ||
half2 testUV = uv + g_Poisson8[i].xy * BufferDim.zw * 8.0; | ||
#else | ||
half2 testUV = uv + g_Poisson8[i].yx * BufferDim.zw * 16.0; | ||
#endif | ||
|
||
if (any(testUV < 0) || any(testUV > 1)) | ||
continue; | ||
|
||
half sampleDepth = GetScreenDepth(DepthTexture.SampleLevel(LinearSampler, testUV, 0)); | ||
half attenuation = g_Poisson8[i].z * lerp(g_Poisson8[i].z * 0.01, 1.0, 1.0 - saturate(0.01 * abs(sampleDepth - depth))); | ||
|
||
[branch] if (attenuation > 0.0) | ||
{ | ||
skylightingSH += SkylightingTexture.SampleLevel(LinearSampler, testUV, 0) * attenuation; | ||
weight += attenuation; | ||
} | ||
} | ||
|
||
SkylightingTextureRW[globalId.xy] = skylightingSH / weight; | ||
} |
Oops, something went wrong.