-
Notifications
You must be signed in to change notification settings - Fork 137
feat: raytracing #1658
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
Closed
Closed
feat: raytracing #1658
Changes from all commits
Commits
Show all changes
625 commits
Select commit
Hold shift + click to select a range
c6d1d24
adds proper default textures for face gen
Gistix d4e4b30
Merge pull request #13 from jiayev/raytracing
Gistix ce781a0
fixes emissives when in interior cell
Gistix db06b43
correct hair color
jiayev b916069
fixes to external emittance when in interior and door/container changes
Gistix 3a62255
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev bb2f34a
Merge pull request #14 from jiayev/raytracing
Gistix 2069c7a
uses raster sky for path tracing miss
Gistix 2ccc7f0
eval random sample lr, fix a crash
jiayev 49ab24a
fixes cases where bonesPerVertex is set to 0 and missing createmodel …
Gistix a59249b
Merge branch 'pr/15' into raytracing
Gistix 92b8c40
createmodel cleanup
Gistix c1594d0
adds detached status to instances
Gistix 16bc50f
makes allocation release log debug priority
Gistix 2338256
adds attached/detached state for instances
Gistix 55f71ae
adds debug option to disable skinned geometry
Gistix bc16a03
many performance adjustments and fixes
Gistix 9fcc737
adds hacky interior sun support
Gistix c9b24a8
interior sun fixes
Gistix 7891db8
fixes point lights when isl is off
Gistix f261f14
Merge remote-tracking branch 'upstream/dev' into dev
Gistix 111d776
add alphablend and alphatest flags
jiayev 1ea2164
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev 774056b
alpha flags
jiayev cc48ea5
fix crash and set alpha blend opaque for refraction
jiayev 34a3b21
add transmission path
jiayev f0bce53
transmission fixes
jiayev 8dd3f03
some fixes (not done)
jiayev b68fc28
fix non pbr path initialization
jiayev dad94c4
some more transmission fix
jiayev 4e28e97
improves model creation logic, moves Flags to inside Shape struct and…
Gistix e3304fe
log cleanup
Gistix e2610c5
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev 0de9476
HeadingMarker renamed to IsMarker, additional cleanup
Gistix b494c1f
heading marker debug log updated
Gistix bd151a4
add window shadow
jiayev b2c9efa
add accumulation mode
jiayev bdfac35
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev d2ebe5b
initial changes for proper shape visibility
Gistix ace3985
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev 1951ed2
fix error and accumulation
jiayev 3e6c19e
clean up and add simple transmission
jiayev 6d68f59
use stochastic blend
jiayev 63720b9
fixes for kRenderUse flag usage
Gistix 5242073
Merge branch 'raytracing' of https://github.com/jiayev/skyrim-communi…
jiayev 1292732
add stochastic
jiayev 7ac87ac
better window method
jiayev cc73186
adds support for player character 3rd person model
Gistix 6b8f49a
adds SE Relocation ID for TES_Load3D
Gistix 62f89e6
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev df1d011
fix compile error
jiayev 0e80bfd
temp solution disabling raster alpha blend (would need proper way)
jiayev b21fdcd
correct vanilla specular
jiayev 03119f3
adds player face tint render target
Gistix 4597aac
separate specular color
jiayev dce6712
Merge branch 'pr/15' into raytracing
Gistix 0115d5d
correct offset for transmission
jiayev 51258b0
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev f66a763
fix ndotl in offsetray
jiayev 853e24b
fix nan
jiayev 512fea7
working conversion
Gistix e7e270d
try transmissive window
jiayev d584809
fix shadowanyhit
jiayev 879b9f4
conversion fixes and proper geometry transform
Gistix 906f55a
hides msn conversion debug view behind def
Gistix 42acb95
restores kModelSpaceNormals flag for kSpecular specular color
Gistix b27ad31
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev c1ac67d
adds sky hemisphere rendering in interior cells
Gistix 72ec19e
Merge remote-tracking branch 'gistix/raytracing' into raytracing
jiayev d17fe31
try init
jiayev b266ffb
try fix accumulator
jiayev 86ff865
improve rr based on nvidia
jiayev b57fce7
multiple fixes
jiayev ba6b953
prevent window delta transmission
jiayev ed873e5
fix broken triangles on high-triangle count geometry
Gistix 29f9d96
fix markers in blas
Gistix 7592325
add cloud opacity
Gistix c6a9160
Merge branch 'raytracing' into raytracing-bsdf-2
Gistix e4b54be
BuildMaterial cleanup
Gistix 9505742
update commonlib to 4.0.0
Gistix c49e4c1
Merge remote-tracking branch 'upstream/dev' into raytracing-bsdf-2
Gistix f12ab8b
fixes
Gistix 301eabf
fix for cleared kOwnEmit and emissiveColor
Gistix 4dbae52
restores shader flags
Gistix d60495b
cloud shadows cleanup
Gistix 6f30446
indirection and material buffer replaced by shape buffer
Gistix 55e6653
test with perma mapped shape buffer
Gistix 9191dde
adds proper object to world rotation matrix
Gistix 12a55cd
fix dynamic vertex skinning update
Gistix 620165f
fix for double-sided geometry by enabling back-face culling
Gistix 0023751
fixes landscape normal map and doublesided geom
Gistix 66bc3ac
adds support for shape transform in shadow anyhit, and normal map adj…
Gistix d15931e
cleanup
jiayev cb6ef19
rayoffset from dxvk-remix
jiayev 1914bea
fix ray logic
jiayev 76093c1
try raycone sample
jiayev acaa799
fix compile
jiayev fcf87bb
fixes
jiayev 70e157d
remove tmin
jiayev ece3411
add miplevel debug
jiayev 3e18329
adjust shading normal
jiayev 4d02316
adds variable update rate to instance data
Gistix 8a7dec7
variable update rate fixes
Gistix eda1678
fixes
jiayev 0f582d2
fix enter status
jiayev 0f383c8
Merge branch 'raytracing-bsdf' into raytracing
Gistix 91fcb88
fix sharc for specular
jiayev eded822
Merge branch 'heads/jiaye/raytracing' into raytracing
Gistix 30bf607
i just gotta :(
jiayev 909de81
fix compile
jiayev 49c441d
kinda fix normal not facing camera
jiayev 9346a5f
use flat normal
jiayev 307adb7
adds raycone to GI, removes it from payload and normal warning fix
Gistix 632a06c
raycone adjust
Gistix 9846d22
full sample count specular hit distance
Gistix e534fe8
fix black faces
jiayev a7d5ef6
Merge branch 'heads/jiaye/raytracing' into raytracing
Gistix b704804
create model race condition fix
Gistix c3dd34c
small createmodel adjustment
Gistix d4e0004
add proper actor 3d release hook and cleanup
Gistix 4733236
cleanup
Gistix fba7105
raygen warning fix
Gistix 9db5afc
no need for flag cuz they got culled anyway
jiayev 8bd1479
adds GeometryDesc function to shape
Gistix b3e279a
moves shape update into... shape. *gasp*
Gistix a6af27a
moves model blas build/update into model struct
Gistix b7b6b24
cleanup
Gistix 2649785
Model::BuildBLAS simplification
Gistix 43e4d48
cleanup
Gistix b8088c8
update instances update
Gistix 157e087
this looks awful, doodlum lied
Gistix f2345cb
adjustments
Gistix 043e48e
more adjustments
Gistix e658cea
no need for flag cuz they got culled anyway
jiayev 37adc5a
Merge branch 'raytracing' of https://github.com/jiayev/skyrim-communi…
jiayev a68b45c
working blas rebuild
Gistix ee5cf75
cleanup
Gistix b2fb29f
adds dismemberreference and most code for dismember skin support
Gistix 9623435
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev dad1ca7
try add hair
jiayev f415db0
fixes
jiayev 0d5ee9a
better init
jiayev ddff4b2
fix compile
jiayev 5dc8e88
flow map process
jiayev 5192679
add hair setting
jiayev bb28b97
add subsurface
jiayev 5a0e71d
sss fixes for now
jiayev 59cc1c6
some sss settings
jiayev 270d7af
more sss
jiayev 81fede1
working dismember for player character
Gistix ceb4b52
more sss fix
jiayev 9934bc5
fix seam
jiayev 0c27827
more fixes
jiayev 00bd7ba
better preset
jiayev 449f074
adjustments
Gistix b4a3012
updates BLAS state management
Gistix db66822
removes Visual Studio temporary file
Gistix e3dac37
attempt to fix generic npcs
Gistix 721e94d
renames variable 'meshData' to 'shape' in Raytracing::CreateModelInte…
Gistix b87c9f7
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev fb72912
optimization attemp by keeping buffers permanently mapped
Gistix 5c97a4f
variable update rate update
Gistix 9217c0a
variable update rate update
Gistix 0b66833
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev c8e25a6
replaces SkinningPipeline upload with uploadregion
Gistix 823735b
skinning variables renaming and cleanup
Gistix 3d17038
remainder from skinning update
Gistix c46f8b8
adds final state parameter to upload region
Gistix 112f920
changes light buffer upload to upload region
Gistix 6f31883
Merge branch 'raytracing-skinning-mapped' into raytracing
Gistix a8cceda
barrierCount renamed to numBarriers
Gistix 3f2a37d
Merge remote-tracking branch 'jiaye/raytracing-hair' into raytracing
Gistix 2689ea1
fix using float for irradiance
jiayev 6926d7b
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev 17dc9cd
Merge branch 'heads/jiaye/raytracing' into raytracing
Gistix 740255f
Merge branch 'heads/jiaye/raytracing' into raytracing
Gistix b187532
removes bound radius from shape
Gistix bf04550
alpha fixes
Gistix 9c8aa79
different ray offset
jiayev ff947d4
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev a3841d9
RaceMenu crash fix
Gistix d4694ac
alpha threshold to alpha scale fixed
Gistix 1717c28
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev 19e18ec
more possible mod crash fixes
Gistix 24ed0dc
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev c2055f6
add farfield hair bcsdf
jiayev d4b6804
TES::Load3D renamed to TES::AttachModel
Gistix 09cb7eb
dynamic trishapes update
Gistix 9578b3f
minor style fix
Gistix 2f7334e
sky cubemap update
Gistix 5335730
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev 976781a
eye fix attempt + skinning cleanup
Gistix 18f0373
hair fixes
jiayev 5ef71c0
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev 0e200ba
Merge remote-tracking branch 'upstream/dev' into dev
Gistix bcd64fd
Merge branch 'dev' into raytracing
Gistix e89f58d
Update CommonLibSSE-NG
Gistix 8a92148
adds active constraints
Gistix 5fdec69
adds createactormodel method
Gistix 09b06c1
fix linear lighting shared feature data
Gistix ac96377
add sanity check for shared feature data
Gistix 9ed4a33
fix linear lighting shared feature data
Gistix 054b566
add sanity check for shared feature data
Gistix 0c587c1
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev 067ad44
fix extended translucency shared feature bufer
Gistix 39f9ed5
fix alpha
Gistix fdb3f1f
shared feature buffer adjustments
Gistix 5c121f5
Merge branch 'raytracing-createactormodel' into raytracing
Gistix 7128ea8
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev c232d6a
switch default hair
jiayev e586845
warning fix
Gistix 5eef7bb
cleanup
Gistix 68b2fa1
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev 3d24c52
fix min light logic
jiayev b9f047b
fix farfield and offset
jiayev 72c6139
adds SSSSettings struct
Gistix 9d77e51
fix resource naming
Gistix 2e06f91
adds throw when naming fails
Gistix ecffcd4
i really need it
jiayev 88051b1
post-move naming fix
Gistix bf1b609
Merge remote-tracking branch 'jiaye/raytracing' into raytracing
Gistix e041fb1
hides debug visualization behind options
Gistix 6740ef2
alpha check logic simplified
Gistix b28ca2d
sss settings layout change
Gistix 18d83ae
missing skin fixes
Gistix 3a927a0
fixes global illumination mode, improved vanilla to pbr conversion
Gistix 469c6e1
adds rt define check to Lighting.hlsl
Gistix b3a22f2
restores specular for GI
Gistix 8baf34e
fixes for gi mode
Gistix 4064487
adds vanilla to pbr conversion to Lighting.hlsl
Gistix cb1f83e
improves vanilla to pbr conversion
Gistix ed9904b
rt shared data adjustments
Gistix eef1cd3
Merge remote-tracking branch 'origin/raytracing-nrd' into raytracing
Gistix 451ad14
adds nrd extern submodule
Gistix a01b083
header fixes
Gistix b1ff344
.gitmodules update
Gistix 4d6a9ac
nrd progress
Gistix 0e39044
fix vanilla emit
jiayev b444bd3
shader fixes and revert
jiayev 3e4483d
nrd related fixes
Gistix 182edee
Merge remote-tracking branch 'jiaye/raytracing' into raytracing
Gistix 7b81344
Merge branch 'raytracing' of https://github.com/Gistix/skyrim-communi…
jiayev b6d27c8
smol crash fix
jiayev 110f094
better mis
jiayev 5905d28
gpt fix instance management, adding more locks
jiayev f5f32a0
set sky hemisphere to 16bit
jiayev 8c041a7
really fix sss light sampling (shadow ray cast after)
jiayev a077daf
fix alpha
jiayev fc0a83e
add texturedim lod
jiayev 4fba262
fix emissive logic
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
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,2 @@ | ||
| [Info] | ||
| Version = 1-0-0 |
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,43 @@ | ||
| #include "Common/Color.hlsli" | ||
|
|
||
| Texture2D<float4> MainInputTexture : register(t0); | ||
| Texture2D<float4> DiffuseAlbedoTexture : register(t1); | ||
| Texture2D<float4> DiffuseGITexture : register(t2); | ||
| Texture2D<float4> SpecularGITexture : register(t3); | ||
|
|
||
| RWTexture2D<float4> MainOutputTexture : register(u0); | ||
|
|
||
| cbuffer AccumulationCB : register(b2) | ||
| { | ||
| uint AccumulatedFrames; | ||
| float3 _padding; | ||
| } | ||
|
|
||
| [numthreads(8, 8, 1)] | ||
| void main(uint2 id : SV_DispatchThreadID) | ||
| { | ||
| #if defined(ACCUMULATION) | ||
| float3 previousAccumulated = MainInputTexture[id].rgb; | ||
| float3 currentPathTraced = DiffuseAlbedoTexture[id].rgb; | ||
|
|
||
| float3 outputColor = lerp(previousAccumulated, currentPathTraced, 1.0 / (AccumulatedFrames + 1)); | ||
| #elif defined(COMPOSITE) | ||
| float3 outputColor = Color::GammaToTrueLinear(MainInputTexture[id].rgb); | ||
|
|
||
| # if defined(DIFFUSE) | ||
| outputColor += DiffuseAlbedoTexture[id].rgb * DiffuseGITexture[id].rgb; | ||
| # endif // DIFFUSE | ||
|
|
||
| # if defined(SPECULAR) | ||
| outputColor += SpecularGITexture[id].rgb; | ||
| # endif // SPECULAR | ||
| #else | ||
| float3 outputColor = DiffuseGITexture[id].rgb; | ||
| #endif // COMPOSITE | ||
|
|
||
| #if defined(GAMMA_OUTPUT) | ||
| outputColor = Color::TrueLinearToGamma(outputColor); | ||
| #endif // GAMMA_OUTPUT | ||
|
|
||
| MainOutputTexture[id] = float4(outputColor, 1.0f); | ||
| } |
54 changes: 54 additions & 0 deletions
54
features/Raytracing/Shaders/Raytracing/ConvertTexturesCS.hlsl
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,54 @@ | ||
| #include "Raytracing/Includes/Common.hlsli" | ||
| #include "Common/FrameBuffer.hlsli" | ||
| #include "Common/GBuffer.hlsli" | ||
| #include "Common/Color.hlsli" | ||
|
|
||
| Texture2D<unorm half4> NormalGlossiness : register(t0); | ||
| Texture2D<unorm half4> Albedo : register(t1); | ||
| Texture2D<unorm half4> GNMAO : register(t2); | ||
| Texture2D<half2> MotionVectors : register(t3); | ||
|
|
||
| RWTexture2D<snorm half4> NormalRoughness : register(u0); | ||
| RWTexture2D<half4> Diffuse : register(u1); | ||
| RWTexture2D<half2> MotionVectorsOut : register(u2); | ||
|
|
||
| cbuffer RenderResCB : register(b0) | ||
| { | ||
| uint2 RenderRes; | ||
| float2 RenderResRcp; | ||
| }; | ||
|
|
||
| SamplerState Sampler : register(s0); | ||
|
|
||
| [numthreads(8, 8, 1)] | ||
| void main(uint2 id : SV_DispatchThreadID) | ||
| { | ||
| if (any(id >= RenderRes)) | ||
| return; | ||
|
|
||
| const float2 uv = float2(id.xy + 0.5f) * RenderResRcp; | ||
| #ifndef PT | ||
| const unorm half3 normalGlossiness = NormalGlossiness.SampleLevel(Sampler, uv, 0).xyz; | ||
| const snorm half3 normalWS = normalize(ViewToWorldVector(GBuffer::DecodeNormal(normalGlossiness.xy), FrameBuffer::CameraViewInverse[0])); | ||
| NormalRoughness[id] = half4(normalWS, 1.0f - normalGlossiness.z); | ||
|
|
||
| const float4 albedo = Albedo.SampleLevel(Sampler, uv, 0); | ||
| const float metallic = GNMAO.SampleLevel(Sampler, uv, 0).z; | ||
| Diffuse[id] = float4(Color::GammaToTrueLinear(albedo.rgb) * (1.0f - metallic), albedo.a); | ||
| #endif | ||
| MotionVectorsOut[id] = MotionVectors.SampleLevel(Sampler, uv, 0); | ||
| } | ||
|
|
||
| [numthreads(8, 8, 1)] | ||
| void main2(uint2 id : SV_DispatchThreadID) | ||
| { | ||
| const unorm half3 normalGlossiness = NormalGlossiness[id].xyz; | ||
| const snorm half3 normalWS = normalize(ViewToWorldVector(GBuffer::DecodeNormal(normalGlossiness.xy), FrameBuffer::CameraViewInverse[0])); | ||
| NormalRoughness[id] = half4(normalWS, 1.0f - normalGlossiness.z); | ||
|
|
||
| float metallic, ao; | ||
| UnpackMAO(GNMAO[id].z, metallic, ao); | ||
| Diffuse[id] = Albedo[id] * (1.0f - metallic); | ||
|
|
||
| MotionVectorsOut[id] = MotionVectors[id]; | ||
| } | ||
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,22 @@ | ||
| #include "Common/SharedData.hlsli" | ||
| #include "Raytracing/Includes/Common.hlsli" | ||
|
|
||
| Texture2D<unorm float> DepthIn : register(t0); | ||
| RWTexture2D<float> DepthOut : register(u0); | ||
| RWTexture2D<float2> DepthViewOut : register(u1); | ||
|
|
||
| [numthreads(8, 8, 1)] | ||
| void main(uint2 id : SV_DispatchThreadID) | ||
| { | ||
| uint width, height; | ||
| DepthIn.GetDimensions(width, height); | ||
|
|
||
| if (id.x >= width || id.y >= height) | ||
| return; | ||
|
|
||
| const float depthScreen = DepthIn[id]; | ||
| DepthOut[id] = depthScreen; | ||
|
|
||
| float depthLinear = ScreenToViewDepth(depthScreen, SharedData::CameraData); | ||
| DepthViewOut[id] = float2(depthLinear, 0.0f); | ||
| } |
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,31 @@ | ||
| TextureCube<float4> CubeMap : register(t0); | ||
| TextureCube<float> OcclusionMap : register(t1); | ||
|
|
||
| SamplerState Sampler : register(s0); | ||
|
|
||
| RWTexture2D<float4> HemisphereOut : register(u0); | ||
|
|
||
| [numthreads(8, 8, 1)] | ||
| void main(uint2 id : SV_DispatchThreadID) | ||
| { | ||
|
|
||
| if (id.x >= RESOLUTION || id.y >= RESOLUTION) | ||
| return; | ||
|
|
||
| const float2 uv = float2(id.xy + 0.5f) / float2(RESOLUTION, RESOLUTION); | ||
| const float2 xy = uv * 2.0f - 1.0f; | ||
|
|
||
| const float r = length(xy); | ||
|
|
||
| const float phi = atan2(xy.y, xy.x); | ||
|
|
||
| const float z = 1.0f - r*r; | ||
| const float k = sqrt(1.0f - z*z); | ||
|
|
||
| const float3 dir = float3(k * cos(phi), k * sin(phi), z); | ||
|
|
||
| const float3 color = CubeMap.SampleLevel(Sampler, dir, 0.0f).rgb; | ||
| const float occlusion = OcclusionMap.SampleLevel(Sampler, dir, 0.0f).r; | ||
|
|
||
| HemisphereOut[id.xy] = float4(color, occlusion); | ||
| } |
162 changes: 162 additions & 0 deletions
162
features/Raytracing/Shaders/Raytracing/Denoiser/NRD/Shared.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,162 @@ | ||
| // © 2022 NVIDIA Corporation | ||
|
|
||
| //============================================================================================= | ||
| // SETTINGS | ||
| //============================================================================================= | ||
|
|
||
| // Fused or separate denoising selection | ||
| // 0 - DIFFUSE and SPECULAR | ||
| // 1 - DIFFUSE_SPECULAR | ||
| #define NRD_COMBINED 1 | ||
|
|
||
| // NORMAL - common (non specialized) denoisers | ||
| // SH - SH (spherical harmonics or spherical gaussian) denoisers | ||
| // OCCLUSION - OCCLUSION (ambient or specular occlusion only) denoisers | ||
| // DIRECTIONAL_OCCLUSION - DIRECTIONAL_OCCLUSION (ambient occlusion in SH mode) denoisers | ||
| #define NRD_MODE NORMAL // NRD sample recompilation required | ||
| #define SIGMA_TRANSLUCENCY 0 | ||
|
|
||
| // Default = 1 | ||
| #define USE_IMPORTANCE_SAMPLING 1 | ||
| #define USE_SHARC_DITHERING 1.5 // radius in voxels | ||
| #define USE_TRANSLUCENCY 1 // translucent foliage | ||
| #define USE_MOVING_EMISSION_FIX 1 // fixes a dark tail, left by an animated emissive object | ||
|
|
||
| // Default = 0 | ||
| #define USE_SANITIZATION 0 // NRD sample is NAN/INF free | ||
| #define USE_SIMULATED_MATERIAL_ID_TEST 0 // "material ID" debugging | ||
| #define USE_SIMULATED_FIREFLY_TEST 0 // "anti-firefly" debugging | ||
| #define USE_CAMERA_ATTACHED_REFLECTION_TEST 0 // test special treatment for reflections of objects attached to the camera | ||
| #define USE_RUSSIAN_ROULETTE 0 // bad practice for real-time denoising | ||
| #define USE_DRS_STRESS_TEST 0 // NRD must not touch GARBAGE data outside of DRS rectangle | ||
| #define USE_INF_STRESS_TEST 0 // NRD must not touch GARBAGE data outside of denoising range | ||
| #define USE_ANOTHER_COBALT 0 // another cobalt variant | ||
| #define USE_PUDDLES 0 // add puddles | ||
| #define USE_RANDOMIZED_ROUGHNESS 0 // randomize roughness ( a common case in games ) | ||
| #define USE_STOCHASTIC_SAMPLING 0 // needed? | ||
| #define USE_LOAD 0 // Load vs SampleLevel | ||
| #define USE_SHARC_DEBUG 0 // 1 - show cache, 2 - show grid (NRD sample recompile required) | ||
| #define USE_TAA_DEBUG 0 // 1 - show weight | ||
| #define USE_BIAS_FIX 0 // fixes negligible hair and specular bias | ||
|
|
||
| //============================================================================================= | ||
| // CONSTANTS | ||
| //============================================================================================= | ||
|
|
||
| // NRD variant | ||
| #define NORMAL 0 | ||
| #define SH 1 // NORMAL + SH (SG) resolve | ||
| #define OCCLUSION 2 | ||
| #define DIRECTIONAL_OCCLUSION 3 // diffuse OCCLUSION + SH (SG) resolve | ||
|
|
||
| // Denoiser | ||
| #define DENOISER_REBLUR 0 | ||
| #define DENOISER_RELAX 1 | ||
| #define DENOISER_REFERENCE 2 | ||
|
|
||
| // Resolution | ||
| #define RESOLUTION_FULL 0 | ||
| #define RESOLUTION_FULL_PROBABILISTIC 1 | ||
| #define RESOLUTION_HALF 2 | ||
|
|
||
| // What is on screen? | ||
| #define SHOW_FINAL 0 | ||
| #define SHOW_DENOISED_DIFFUSE 1 | ||
| #define SHOW_DENOISED_SPECULAR 2 | ||
| #define SHOW_AMBIENT_OCCLUSION 3 | ||
| #define SHOW_SPECULAR_OCCLUSION 4 | ||
| #define SHOW_SHADOW 5 | ||
| #define SHOW_BASE_COLOR 6 | ||
| #define SHOW_NORMAL 7 | ||
| #define SHOW_ROUGHNESS 8 | ||
| #define SHOW_METALNESS 9 | ||
| #define SHOW_MATERIAL_ID 10 | ||
| #define SHOW_PSR_THROUGHPUT 11 | ||
| #define SHOW_WORLD_UNITS 12 | ||
| #define SHOW_INSTANCE_INDEX 13 | ||
| #define SHOW_UV 14 | ||
| #define SHOW_CURVATURE 15 | ||
| #define SHOW_MIP_PRIMARY 16 | ||
| #define SHOW_MIP_SPECULAR 17 | ||
|
|
||
| // Predefined material override | ||
| #define MATERIAL_GYPSUM 1 | ||
| #define MATERIAL_COBALT 2 | ||
|
|
||
| // Material ID | ||
| #define MATERIAL_ID_DEFAULT 0.0f | ||
| #define MATERIAL_ID_METAL 1.0f | ||
| #define MATERIAL_ID_HAIR 2.0f | ||
| #define MATERIAL_ID_SELF_REFLECTION 3.0f | ||
|
|
||
| // Mip mode | ||
| #define MIP_VISIBILITY 0 // for visibility: emission, shadow and alpha mask | ||
| #define MIP_LESS_SHARP 1 // for normal | ||
| #define MIP_SHARP 2 // for albedo and roughness | ||
|
|
||
| // Register spaces ( sets ) | ||
| #define SET_OTHER 0 | ||
| #define SET_RAY_TRACING 1 | ||
| #define SET_SHARC 2 | ||
| #define SET_MORPH 3 | ||
| #define SET_ROOT 4 | ||
|
|
||
| // Path tracing | ||
| #define PT_THROUGHPUT_THRESHOLD 0.001 | ||
| #define PT_IMPORTANCE_SAMPLES_NUM 16 | ||
| #define PT_SPEC_LOBE_ENERGY 0.95 // trimmed to 95% | ||
| #define PT_SHADOW_RAY_OFFSET 1.0 // pixels | ||
| #define PT_BOUNCE_RAY_OFFSET 0.25 // pixels | ||
| #define PT_GLASS_RAY_OFFSET 0.05 // pixels | ||
| #define PT_MAX_FIREFLY_RELATIVE_INTENSITY 20.0 // no more than 20x energy increase in case of probabilistic sampling | ||
| #define PT_EVIL_TWIN_LOBE_TOLERANCE 0.005 // normalized % | ||
| #define PT_GLASS_MIN_F 0.05 // adds a bit of stability and bias | ||
| #define PT_DELTA_BOUNCES_NUM 8 | ||
| #define PT_PSR_BOUNCES_NUM 2 | ||
| #define PT_RAY_FLAGS 0 | ||
|
|
||
| // Spatial HAsh-based Radiance Cache ( SHARC ) | ||
| #define SHARC_CAPACITY ( 1 << 22 ) | ||
| #define SHARC_SCENE_SCALE 45.0 | ||
| #define SHARC_DOWNSCALE 5 | ||
| #define SHARC_ANTI_FIREFLY false | ||
| #define SHARC_STALE_FRAME_NUM_MIN 32 // new version uses 8 by default, old value offers more stability in voxels with low number of samples ( critical for glass ) | ||
| #define SHARC_SEPARATE_EMISSIVE 1 | ||
| #define SHARC_MATERIAL_DEMODULATION 1 | ||
| #define SHARC_USE_FP16 0 | ||
|
|
||
| // Blue noise | ||
| #define BLUE_NOISE_SPATIAL_DIM 128 // see StaticTexture::ScramblingRanking | ||
| #define BLUE_NOISE_TEMPORAL_DIM 4 // good values: 4-8 for shadows, 8-16 for occlusion, 8-32 for lighting | ||
|
|
||
| // Other | ||
| #define FP16_MAX 65504.0 | ||
| #define INF 1e5 | ||
| #define LINEAR_BLOCK_SIZE 256 | ||
| #define FP16_VIEWZ_SCALE 0.125 // TODO: tuned for meters, needs to be scaled down for cm and mm | ||
| #define MAX_MIP_LEVEL 11.0 | ||
| #define LEAF_TRANSLUCENCY 0.25 | ||
| #define LEAF_THICKNESS 0.001 // TODO: viewZ dependent? | ||
| #define STRAND_THICKNESS 80e-6f | ||
| #define TAA_HISTORY_SHARPNESS 0.66 // sharper ( was 0.5 ) | ||
| #define TAA_SIGMA_SCALE 2.0 // allow nano ghosting ( was 1.0 ) // TODO: can negatively affect moving shadows | ||
| #define GARBAGE sqrt( -1.0 ) // sqrt( -1.0 ) or -log( 0.0 ) or 32768.0 | ||
|
|
||
| #define MORPH_MAX_ACTIVE_TARGETS_NUM 8u | ||
| #define MORPH_ELEMENTS_PER_ROW_NUM 4 | ||
| #define MORPH_ROWS_NUM ( MORPH_MAX_ACTIVE_TARGETS_NUM / MORPH_ELEMENTS_PER_ROW_NUM ) | ||
|
|
||
| // Instance flags | ||
| #define FLAG_FIRST_BIT 24 // this + number of flags must be <= 32 | ||
| #define NON_FLAG_MASK ( ( 1 << FLAG_FIRST_BIT ) - 1 ) | ||
|
|
||
| #define FLAG_NON_TRANSPARENT 0x01 // geometry flag: non-transparent | ||
| #define FLAG_TRANSPARENT 0x02 // geometry flag: transparent | ||
| #define FLAG_FORCED_EMISSION 0x04 // animated emissive cube | ||
| #define FLAG_STATIC 0x08 // no velocity | ||
| #define FLAG_HAIR 0x10 // hair | ||
| #define FLAG_LEAF 0x20 // leaf | ||
| #define FLAG_SKIN 0x40 // skin | ||
| #define FLAG_MORPH 0x80 // morph | ||
|
|
||
| #define GEOMETRY_ALL ( FLAG_NON_TRANSPARENT | FLAG_TRANSPARENT ) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing bounds check in main2 could cause out-of-bounds writes.
The
main2entry point lacks the bounds check present inmain(lines 26-27). If the compute dispatch size exceeds the texture dimensions, this will result in out-of-bounds writes to the output textures.🔎 Add bounds check consistent with main
[numthreads(8, 8, 1)] void main2(uint2 id : SV_DispatchThreadID) { + if (any(id >= RenderRes)) + return; + const unorm half3 normalGlossiness = NormalGlossiness[id].xyz;🤖 Prompt for AI Agents
🧩 Analysis chain
🏁 Script executed:
Repository: doodlum/skyrim-community-shaders
Length of output: 139
🏁 Script executed:
Repository: doodlum/skyrim-community-shaders
Length of output: 224
🏁 Script executed:
Repository: doodlum/skyrim-community-shaders
Length of output: 224
🏁 Script executed:
Repository: doodlum/skyrim-community-shaders
Length of output: 2467
🏁 Script executed:
Repository: doodlum/skyrim-community-shaders
Length of output: 809
🏁 Script executed:
Repository: doodlum/skyrim-community-shaders
Length of output: 58
🏁 Script executed:
Repository: doodlum/skyrim-community-shaders
Length of output: 520
🏁 Script executed:
Repository: doodlum/skyrim-community-shaders
Length of output: 224
Remove the unused
main2entry point.The file contains two compute shader entry points:
main(lines 24-42, which is correct) andmain2(lines 45-56, which is incorrect and unused). Themain2entry point:mainColor::GammaToTrueLinear) thatmaincorrectly applies on line 39Since
main2is not referenced anywhere in the codebase, it should be removed entirely rather than maintained as dead code or fixed.🤖 Prompt for AI Agents