-
Notifications
You must be signed in to change notification settings - Fork 138
feat(fog): volumetric fog #2361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
3f851fd
feat(fog): volumetric fog
jiayev 12eece8
more vol fog
jiayev 21825c4
feat(fog): enhance volumetric fog parameters and history management
jiayev c832379
feat(fog): add jitter parameters and improve history management for v…
jiayev 17d136a
feat(fog): add local light scattering support and adjust settings for…
jiayev 7b2cee6
fix include order
jiayev 1d67267
feat(fog): add upsample jitter multiplier and enhance volumetric fog …
jiayev f37de2b
feat(fog): add support for terrain and cloud shadows in volumetric fo…
jiayev d82c58e
feat(fog): integrate volumetric shadows support and adjust settings f…
jiayev b24b04f
feat(fog): optimize shadow sampling and adjust volumetric fog settings
jiayev 9b55caf
settings change
jiayev 8a73d9f
fix fog effect mix
jiayev 26c6bd0
Merge branch 'dev' into volumetric-fog
jiayev 3b4ef75
fix dir light inscatter
jiayev f18d445
fix: enhance volumetric fog support for VR and improve blending logic
jiayev e58fb23
Merge branch 'dev' into volumetric-fog
jiayev ddf4796
Merge branch 'dev' into volumetric-fog
jiayev 21b5cfe
Merge branch 'dev' into volumetric-fog
jiayev d893c25
feat(exponential-height-fog): enhance volumetric fog functionality an…
jiayev 2515ef4
Merge branch 'dev' into volumetric-fog
jiayev a30e14e
feat(volumetric-fog): add directional light phase correction and impr…
jiayev 8ad5a20
Merge branch 'dev' into volumetric-fog
jiayev 5ce8e2f
Merge branch 'dev' into volumetric-fog
jiayev 7d5f416
Merge branch 'dev' into volumetric-fog
jiayev 30ab891
Merge branch 'dev' into volumetric-fog
jiayev 97ab4c9
rabbit
jiayev e6aab72
Merge branch 'dev' into volumetric-fog
jiayev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
58 changes: 58 additions & 0 deletions
58
features/Exponential Height Fog/Shaders/ExponentialHeightFog/VolumetricFogCSCommon.hlsli
This file contains hidden or 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,58 @@ | ||
| #ifndef __EXPONENTIAL_HEIGHT_FOG_VOLUMETRIC_CS_COMMON_HLSLI__ | ||
| #define __EXPONENTIAL_HEIGHT_FOG_VOLUMETRIC_CS_COMMON_HLSLI__ | ||
|
|
||
| #include "Common/FrameBuffer.hlsli" | ||
| #include "Common/VR.hlsli" | ||
|
|
||
| cbuffer VolumetricFogCB : register(b0) | ||
| { | ||
| uint4 VolumetricFogGridSizeAndFlags; | ||
| float4 VolumetricFogInvGridSizeAndNearFade; | ||
| float4 VolumetricFogGridZParams; | ||
| row_major float4x4 VolumetricFogClipToWorld[2]; | ||
| float4 VolumetricFogFrameJitterOffsets[16]; | ||
| float4 VolumetricFogHistoryParameters; | ||
| float4 VolumetricFogJitterParameters; | ||
| }; | ||
|
|
||
| #define VolumetricFogGridSize VolumetricFogGridSizeAndFlags.xyz | ||
| #define VolumetricFogHasDirectionalShadowMap ((VolumetricFogGridSizeAndFlags.w & 1u) != 0u) | ||
| #define VolumetricFogHasConservativeDepth ((VolumetricFogGridSizeAndFlags.w & 2u) != 0u) | ||
| #define VolumetricFogHasIBL ((VolumetricFogGridSizeAndFlags.w & 4u) != 0u) | ||
| #define VolumetricFogHasSkylighting ((VolumetricFogGridSizeAndFlags.w & 8u) != 0u) | ||
| #define VolumetricFogHasPrevConservativeDepth ((VolumetricFogGridSizeAndFlags.w & 16u) != 0u) | ||
| #define VolumetricFogHasLocalLights ((VolumetricFogGridSizeAndFlags.w & 32u) != 0u) | ||
| #define VolumetricFogInvGridSize VolumetricFogInvGridSizeAndNearFade.xyz | ||
| #define VolumetricFogNearFadeInDistanceInv VolumetricFogInvGridSizeAndNearFade.w | ||
| #define VolumetricFogHistoryWeight VolumetricFogHistoryParameters.x | ||
| #define VolumetricFogHistoryMissSampleCount max(1u, min(16u, (uint)(VolumetricFogHistoryParameters.y + 0.5f))) | ||
| #define VolumetricFogSampleJitterMultiplier VolumetricFogJitterParameters.x | ||
| #define VolumetricFogStateFrameIndexMod8 ((uint)(VolumetricFogJitterParameters.y + 0.5f)) | ||
|
|
||
| #define EXP_HEIGHT_FOG_GRID_SIZE_Z VolumetricFogGridSizeAndFlags.z | ||
| #define EXP_HEIGHT_FOG_GRID_Z_PARAMS VolumetricFogGridZParams.xyz | ||
| #include "ExponentialHeightFog/VolumetricFogCommon.hlsli" | ||
|
|
||
| namespace ExponentialHeightFog | ||
| { | ||
| bool IsInsideVolumetricGrid(uint3 coord) | ||
| { | ||
| return all(coord < VolumetricFogGridSize); | ||
| } | ||
|
|
||
| float3 ComputeCellWorldPosition(uint3 coord, float3 cellOffset, out uint eyeIndex, out float viewDepth) | ||
| { | ||
| float2 volumeUV = (float2(coord.xy) + cellOffset.xy) * VolumetricFogInvGridSize.xy; | ||
| eyeIndex = Stereo::GetEyeIndexFromTexCoord(volumeUV); | ||
| float2 eyeUV = Stereo::ConvertFromStereoUV(volumeUV, eyeIndex); | ||
|
|
||
| viewDepth = ComputeVolumetricSliceDepth(max(float(coord.z) + cellOffset.z, 0.0f)); | ||
|
|
||
| float2 ndc = eyeUV * float2(2.0f, -2.0f) + float2(-1.0f, 1.0f); | ||
| float deviceZ = (SharedData::CameraData.x - SharedData::CameraData.w / viewDepth) / SharedData::CameraData.z; | ||
| float4 worldPosition = mul(VolumetricFogClipToWorld[eyeIndex], float4(ndc, deviceZ, 1.0f)); | ||
| return worldPosition.xyz / worldPosition.w; | ||
| } | ||
| } | ||
|
|
||
| #endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.