Repository navigation
GI, traced reflections and some fixes #401
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
10 commits
Select commit
Hold shift + click to select a range
b693511
Tust
dariormt f6f8186
Global Illumination
dariormt 74e8b2f
GI leaks less now, fixed accumulator and added fog and volumetrics
dariormt 35f6c7f
Merge branch 'dev' into feature/20YearsInTheCan
dariormt 366dc67
im stoopid
dariormt bea2b32
GPU timers debug lables
dariormt 8367147
fixed GI with fog flickering
dariormt 495c496
tidi
dariormt 164d16a
tidi fr now
dariormt 126e54c
Lots of optimizations
dariormt 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
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
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
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,71 @@ | ||
| // Fog media shared by the volumetrics pass and GI rays | ||
| import lighting; | ||
|
|
||
| // Mirrors VulkanRenderer::FogVolumeGpu | ||
| struct FogVolume | ||
| { | ||
| float4x4 worldToLocal; | ||
| /// xyz half extents w edge fade in meters | ||
| float4 extentsFade; | ||
| /// rgb albedo a extinction per meter | ||
| float4 albedoDensity; | ||
| /// rgb radiance per meter at density 1 a noise strength | ||
| float4 emissionNoise; | ||
| /// xyz wind in meters per second w noise scale in meters | ||
| float4 windScale; | ||
| /// x anisotropy y ambient scale | ||
| float4 phase; | ||
| /// xyz box centre in world space | ||
| float4 centre; | ||
| }; | ||
|
|
||
| [[vk::binding(22, 0)]] | ||
| StructuredBuffer<FogVolume> gFogVolumes; | ||
|
|
||
| uint fogVolumeCount() | ||
| { | ||
| return uint(gCamera.fogMedium.w); | ||
| } | ||
|
|
||
| /// Height fog extinction along origin + direction * t integrated over [near, far] | ||
| float heightFogDepth(float3 origin, float3 direction, float near, float far) | ||
| { | ||
| const float density = gCamera.fogMedium.x; | ||
| if (density <= 0.0 || far <= near) | ||
| { | ||
| return 0.0; | ||
| } | ||
| const float falloff = gCamera.fogMedium.z; | ||
| const float startHeight = origin.y + direction.y * near - gCamera.fogMedium.y; | ||
| const float atStart = density * exp(-clamp(falloff * startHeight, -20.0, 20.0)); | ||
| const float slope = falloff * direction.y; | ||
| const float span = far - near; | ||
| return abs(slope) < 1e-4 ? atStart * span : atStart * (1.0 - exp(-clamp(slope * span, -20.0, 20.0))) / slope; | ||
| } | ||
|
|
||
| /// Volumes count as uniform boxes since noise averages out and the edge fade is thin | ||
| float fogOpticalDepth(float3 origin, float3 direction, float near, float far) | ||
| { | ||
| float depth = heightFogDepth(origin, direction, near, far); | ||
| const uint count = fogVolumeCount(); | ||
| for (uint v = 0u; v < count; ++v) | ||
| { | ||
| const FogVolume volume = gFogVolumes[v]; | ||
| const float3 localOrigin = mul(volume.worldToLocal, float4(origin, 1.0)).xyz; | ||
| const float3 localDirection = mul(volume.worldToLocal, float4(direction, 0.0)).xyz; | ||
| const float3 inverse = 1.0 / select(abs(localDirection) > 1e-8, localDirection, float3(1e-8, 1e-8, 1e-8)); | ||
| const float3 t0 = (-volume.extentsFade.xyz - localOrigin) * inverse; | ||
| const float3 t1 = (volume.extentsFade.xyz - localOrigin) * inverse; | ||
| const float3 low = min(t0, t1); | ||
| const float3 high = max(t0, t1); | ||
| const float enter = max(max(low.x, low.y), max(low.z, near)); | ||
| const float exit = min(min(high.x, high.y), min(high.z, far)); | ||
| depth += max(exit - enter, 0.0) * volume.albedoDensity.a; | ||
| } | ||
| return depth; | ||
| } | ||
|
|
||
| float fogTransmittance(float3 origin, float3 direction, float near, float far) | ||
| { | ||
| return exp(-fogOpticalDepth(origin, direction, near, far)); | ||
| } |
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,4 @@ | ||
| uid = "F0gM3d1aSh4" | ||
| type = "shader" | ||
| created_at = "2026-10-26T00:00:00.0000000Z" | ||
| modified_at = "2026-10-26T00:00:00.0000000Z" |
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,38 @@ | ||
| // GGX visible normal sampling shared by SSR and traced specular | ||
|
|
||
| static const float kGgxPi = 3.14159265; | ||
|
|
||
| float ggxD(float NdotH, float alpha) | ||
| { | ||
| const float a2 = alpha * alpha; | ||
| const float d = NdotH * NdotH * (a2 - 1.0) + 1.0; | ||
| return a2 / max(kGgxPi * d * d, 1e-8); | ||
| } | ||
|
|
||
| float smithG1(float NdotX, float alpha) | ||
| { | ||
| const float a2 = alpha * alpha; | ||
| return 2.0 * NdotX / max(NdotX + sqrt(a2 + (1.0 - a2) * NdotX * NdotX), 1e-8); | ||
| } | ||
|
|
||
| /// Heitz 2018 visible normal sampling in a frame with z up | ||
| float3 sampleVisibleNormal(float3 view, float alpha, float2 u) | ||
| { | ||
| const float3 stretched = normalize(float3(alpha * view.x, alpha * view.y, view.z)); | ||
| const float lengthSquared = stretched.x * stretched.x + stretched.y * stretched.y; | ||
| const float3 t1 = lengthSquared > 0.0 ? float3(-stretched.y, stretched.x, 0.0) * rsqrt(lengthSquared) : float3(1.0, 0.0, 0.0); | ||
| const float3 t2 = cross(stretched, t1); | ||
| const float r = sqrt(u.x); | ||
| const float phi = 2.0 * kGgxPi * u.y; | ||
| const float p1 = r * cos(phi); | ||
| const float s = 0.5 * (1.0 + stretched.z); | ||
| const float p2 = (1.0 - s) * sqrt(max(1.0 - p1 * p1, 0.0)) + s * r * sin(phi); | ||
| const float3 h = p1 * t1 + p2 * t2 + sqrt(max(1.0 - p1 * p1 - p2 * p2, 0.0)) * stretched; | ||
| return normalize(float3(alpha * h.x, alpha * h.y, max(h.z, 0.0))); | ||
| } | ||
|
|
||
| /// Of a direction sampled through sampleVisibleNormal | ||
| float visibleNormalPdf(float NdotV, float NdotH, float alpha) | ||
| { | ||
| return smithG1(NdotV, alpha) * ggxD(NdotH, alpha) / max(4.0 * NdotV, 1e-8); | ||
| } |
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,4 @@ | ||
| uid = "G9xSampl1ng" | ||
| type = "shader" | ||
| created_at = "2026-10-25T00:00:00.0000000Z" | ||
| modified_at = "2026-10-25T00:00:00.0000000Z" |
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.