Skip to content

Commit 318ceac

Browse files
committed
Added lightmap importance sampling
Added Environment map importance sampling(needs to be equirectangular) Added Constrast Adapative Sharpening filter Improved DX11 support Fixed heightmaps with a differing width and height Replaced a lot of "GetComponent" calls with "TryGetComponent" which has majorly sped up several things Fixed minor error that caused unity to yell about stopwatches Fixed OIDN normal buffer guide Decent performance bump Small fix to behavior of "Link Mat To Unity Material" Moved bloom and tonemapping to after OIDN Memory from BVH2 and LightBVH is now properly cleared Fixed instances being broken with LightBVH Added toggle to disable atlas compression in "Functionality Settings"(much higher vram cost but no more texture artifacts) Fixed "Emission Mask" material toggle being inverted Removed quantization of
1 parent 81f62ac commit 318ceac

30 files changed

+2494
-602
lines changed

README.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ A passion projects that has been going on for a while with the goal of bringing
1616
<li>Compressed Wide Bounding Volume Hierarchy as the Acceleration Structure (See Ylitie et al. 2017 below)</li>
1717
<li>PBR Texture Support</li>
1818
<li>Next Event Estimation with Multiple Importance Sampling for Explicit Light Sampling</li>
19+
<li>Light BVH from PBRT 4 for NEE</li>
1920
<li>Support for all default unity lights, which interact via NEE</li>
2021
<li>Bloom, Depth of Field, AutoExposure, TAA, Tonemapping</li>
2122
<li>No specific GPU vendor needed(this will run on integrated graphics if you so wish it, aka no RTX cores needed)</li>
@@ -28,6 +29,8 @@ A passion projects that has been going on for a while with the goal of bringing
2829
<li>Full skinned mesh support for animated skinned meshes</li>
2930
<li>Supports deformable standard meshes</li>
3031
<li>Supports unity heightmap terrain and heightmap trees</li>
32+
<li>Supports OIDN Denoiser</li>
33+
<li>Enironment Map Importance Sampling</li>
3134
</ul>
3235

3336
[Ylitie et al](https://research.nvidia.com/sites/default/files/publications/ylitie2017hpg-paper.pdf)
@@ -45,7 +48,7 @@ Let me know if you use this for anything, I would be excited to see any use of t
4548
# Instructions:
4649
## Required Settings Changes:
4750
<ul>
48-
<li>Change the Graphics Api for Windows to DirectX12 through Edit Tab(Top Left) -> Project Settings -> Player -> Other Settings -> Untoggle "Auto Graphics API For Windows", then click the little + that appears, select "Direct3D12(Experimental)", and drag that to the top. A restart of the editor is required</li>
51+
<li>If you plan to use DX12(otherwise look down below for DX11 instructions): Change the Graphics Api for Windows to DirectX12 through Edit Tab(Top Left) -> Project Settings -> Player -> Other Settings -> Untoggle "Auto Graphics API For Windows", then click the little + that appears, select "Direct3D12(Experimental)", and drag that to the top. A restart of the editor is required</li>
4952
<li>Your target camera NEEDS to be deferred, this will usually be automatically done for you by TrueTrace</li>
5053
</ul>
5154

@@ -75,12 +78,13 @@ Camera Controls: WASD, Mouse, hold right click rotate the camera, and shift incr
7578
<li>To set up PBR with the DEFAULT material, all textures go into their proper names, but Roughness goes into the Occlusion texture(This can be changed in the MaterialPairing menu)</li>
7679
<li>If you are using blendshapes to change geometry of a skinned mesh, you may need to go to the import settings of it(in the inspector), turn off Legacy Blendshape Normals, and make sure all normals are imported, not calculated, otherwise the normals for blendshapes might be wrong</li>
7780
<li>A fun thing you may want to do is go to TrueTrace -> Resources -> RenderPipelines -> RendererHandle, and uncomment the "[ImageEffectOpaque]"</li>
78-
<li>If you use HDRIs, or CubeMaps for the skybox, you need to format as the texture to a cube shape in the inspector of the image, unity will convert it automatically, then put it in the slot in Scene Settings</li>
81+
<li>If you use HDRIs, or CubeMaps for the skybox, you need to format as the texture to a Texture2D in the inspector of the image, unity will convert it automatically, then put it in the slot in "Scene Settings" in the TrueTrace settings menu</li>
7982
<li>With multi-pass ReSTIR GI, the additional passes for spatial are in the RayTracingMaster script, where you can add more to the "Spatials" array. X is spatial sample count, Y is spatial sample radius.</li>
8083
</ul>
8184

8285
## Using Instancing
8386
<ul>
87+
<li>THIS DOES NOT WORK WITH RT CORES</li>
8488
<li>Firstly, all objects that will be the source of instanced objects will need to go under the InstancedStorage and can be arranged like normal objects(with regards to the layout of parentobject to raytracingobjects)</li>
8589
<li>Then, to instance the objects, you just need GameObjects with the InstanceObject script attatched to them under the Scene GameObject, and then drag the desired object instance from the hierarchy to the Instance Parent slot in the InstanceObject script</li>
8690
</ul>
@@ -94,6 +98,11 @@ Camera Controls: WASD, Mouse, hold right click rotate the camera, and shift incr
9498
<li>Once this is done, click "Apply Material Links" and rebuild the BVH in the "Main Options" tab to update the objects in the scene</li>
9599
</ul>
96100

101+
## Using OIDN
102+
<ul>
103+
<li>Go to "Functionality Settings" in the TrueTrace Options, and check "Enable OIDN"</li>
104+
</ul>
105+
97106
## Using HDRP
98107
<ul>
99108
<li>Go into TrueTrace -> Resources -> GlobalDefines.cginc, and uncomment the #define HDRP</li>
@@ -110,6 +119,7 @@ Camera Controls: WASD, Mouse, hold right click rotate the camera, and shift incr
110119

111120
## Using DX11 Only
112121
<ul>
122+
<li>DX11 does not currently work with ASVGF(just havent fixed yet), or hue shift(seems to be a compiler bug)</li>
113123
<li>In the TrueTrace settings menu, click on the top right button "Functionality Settings" and toggle "Use DX11"</li>
114124
<li>Uncomment the "#define DX11" in: TrueTrace -> Resources -> GlobalDefines.cginc</li>
115125
</ul>
@@ -141,16 +151,18 @@ TrueTrace Options Description -
141151
<li>Enable Object Moving - Allows objects to be moved during play, and allows for added objects to spawn in when they are done building</li>
142152
<li>Allow Image Accumulation - Allows the image to accumulate while the camera is not moving</li>
143153
<li>Use Next Event Estimation - Enables shadow rays/NEE for direct light sampling</li>
144-
<li>RIS Count - Number of RIS passes done for lights(select the best light out of X number of randomly selected lights)</li>
154+
<li>RIS Count - Number of RIS passes done for lights(select the best light out of X number of randomly selected lights, only works if LBVH is off in "GlobalDefines.cginc")</li>
145155
<li>Allow Mesh Skinning - Turns on the ability for skinned meshes to be animated or deformed with respect to their armeture</li>
146156
<li>Denoiser - Allows you to switch between different denoisers</li>
147157
<li>Allow Bloom - Turns on or off Bloom</li>
158+
<li>Sharpness Filter - Contrast Adaptive Sharpening</li>
148159
<li>Enable DoF - Turns on or off Depth of Field, and its associated settings</li>
149160
<li>Autofocus DoF - Sets the focal length to bring whatever is in the center of the screen into focus</li>
150161
<li>Enable Auto/Manual Exposure - Turns on or off Exposure</li>
151162
<li>Use ReSTIR GI - Enables ReSTIR GI which is usually much higher quality(Works with Recur and SVGF denoisers)</li>
152163
<li>Do Sample Connection Validation - Confirms that two samples are mutually visable and throws it away if they are not</li>
153164
<li>Update Rate - How many pixels per frame get re-traced to ensure they are still valid paths(7 or 33 is a good number to aim for here at 1080p)</li>
165+
<li>Unmarked Toggle - Unlabeled toggle, switches between old ReSTIR GI and new ReSTIR GI</li>
154166
<li>Enable Temporal - Enables the Temporal pass of ReSTIR GI(allows samples to travel across time</li>
155167
<li>Temporal M Cap - How long a sample may live for, lower means lighting updates faster(until 0 which is the opposite) but more noise(recommended either 0 or around 12, but can be played with)</li>
156168
<li>Enable Spatial - Enables the Spatial pass of ReSTIR GI(Allows pixels to choose to use the neighboring pixels sample instead)</li>
@@ -173,8 +185,11 @@ TrueTrace Options Description -
173185
<li>Base Color - If theres no Albedo Texture, this is the color the object will be</li>
174186
<li>Emission - The emittance of an object(how much light it gives off)</li>
175187
<li>Emission Color - Changes the color of emissive objects, most useful when you have an emission mask on an object</li>
188+
<li>Thin - Marks an object as thin, Influences Diffuse, DiffTrans, and SpecTrans</li>
176189
<li>Roughness - Roughness of the object</li>
190+
<li>Roughness Remap - Remaps from the [0,1] of Roughness Slider to the min and max defined here</li>
177191
<li>Metallic - How metallic an object is</li>
192+
<li>Metallic Remap - Remaps from the [0,1] of Metallic Slider to the min and max defined here</li>
178193
<li>IOR - Index of Refraction of an object - Affects Glass and Specular</li>
179194
<li>Specular - Adds specular reflection to an object, use in conjunction with Roughness and IOR</li>
180195
<li>Specular Tint - Weights color more towards the objects color for specular reflections</li>
@@ -184,12 +199,18 @@ TrueTrace Options Description -
184199
<li>ClearCoatGloss - Influences the ClearCoat</li>
185200
<li>Anisotropic - Makes the material anisotropic based on roughness</li>
186201
<li>SpecTrans(Glass) - Makes an object more or less like glass</li>
187-
<li>Thin - Marks an object as thin, Influences Diffuse, DiffTrans, and SpecTrans</li>
188202
<li>Diffuse Transmission - Makes an object Diffuse but Transmissive(transluscent)</li>
189203
<li>Transmission Color - Affects Diffuse Transmission color, must be greater than 0 for diffuse transmission</li>
190204
<li>Flatness - Affects Thin objects</li>
191205
<li>Scatter Distance - Affects SpecTrans and Diffuse Transmission, must be greater than 0 for Diffuse Transmission</li>
192-
<li>Save Material - Saves the material and applys it when you exit play mode(MUST HAVE TRUETRACE SETTINGS OPEN)</li>
206+
<li>Alpha Cutoff - For Cutout objects, this is the value compared against the alpha texture</li>
207+
<li>Normalmap Strength - Strength of the Normal Map</li>
208+
<li>Blend Color - Color to blend to</li>
209+
<li>Blend Factor - Blending weight between Blend Color and the usual color an object would have</li>
210+
<li>MainTex Scale/Offset - Albedo texture scales and all texture offset</li>
211+
<li>SecondaryTex Scale - All texture scale other than Albedo</li>
212+
<li>Link Mat To Unity Material - The material will have its properties overridden by the unity material</li>
213+
193214
<li>Texture Scroll Changed - Updates the textures offset/scaling from the shader</li>
194215
<li>Propogate To Materials - Copies properties of local material to all other objects in the scene with the same material</li>
195216
</ul>
@@ -198,6 +219,7 @@ TrueTrace Options Description -
198219
</br>
199220
<ul>
200221
<li>Report any you find! There WILL be bugs, I just dont know what they are</li>
222+
<li>DX11 does not work with ASVGF</li>
201223
</ul>
202224

203225
# Huge thanks to these people for being sponsors/patrons:

TrueTrace.unitypackage

6.67 KB
Binary file not shown.

TrueTrace/DemoScene.unity

Lines changed: 59 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4726,43 +4726,6 @@ MonoBehaviour:
47264726
JustCreated: 0
47274727
TilingChanged: 0
47284728
MatOffset: 0
4729-
--- !u!84 &239337102
4730-
RenderTexture:
4731-
m_ObjectHideFlags: 0
4732-
m_CorrespondingSourceObject: {fileID: 0}
4733-
m_PrefabInstance: {fileID: 0}
4734-
m_PrefabAsset: {fileID: 0}
4735-
m_Name:
4736-
m_ImageContentsHash:
4737-
serializedVersion: 2
4738-
Hash: 00000000000000000000000000000000
4739-
m_ForcedFallbackFormat: 4
4740-
m_DownscaleFallback: 0
4741-
m_IsAlphaChannelOptional: 0
4742-
serializedVersion: 5
4743-
m_Width: 1
4744-
m_Height: 1
4745-
m_AntiAliasing: 1
4746-
m_MipCount: -1
4747-
m_DepthStencilFormat: 0
4748-
m_ColorFormat: 4
4749-
m_MipMap: 0
4750-
m_GenerateMips: 1
4751-
m_SRGB: 1
4752-
m_UseDynamicScale: 0
4753-
m_BindMS: 0
4754-
m_EnableCompatibleFormat: 1
4755-
m_TextureSettings:
4756-
serializedVersion: 2
4757-
m_FilterMode: 1
4758-
m_Aniso: 1
4759-
m_MipBias: 0
4760-
m_WrapU: 1
4761-
m_WrapV: 1
4762-
m_WrapW: 1
4763-
m_Dimension: 2
4764-
m_VolumeDepth: 1
4765-
m_ShadowSamplingMode: 2
47664729
--- !u!114 &242431739
47674730
MonoBehaviour:
47684731
m_ObjectHideFlags: 0
@@ -8108,6 +8071,43 @@ Transform:
81088071
m_CorrespondingSourceObject: {fileID: 1379565675112781638, guid: 16500a523b718314091d7e9b83146c62, type: 3}
81098072
m_PrefabInstance: {fileID: 1770587712}
81108073
m_PrefabAsset: {fileID: 0}
8074+
--- !u!84 &407770371
8075+
RenderTexture:
8076+
m_ObjectHideFlags: 0
8077+
m_CorrespondingSourceObject: {fileID: 0}
8078+
m_PrefabInstance: {fileID: 0}
8079+
m_PrefabAsset: {fileID: 0}
8080+
m_Name:
8081+
m_ImageContentsHash:
8082+
serializedVersion: 2
8083+
Hash: 00000000000000000000000000000000
8084+
m_ForcedFallbackFormat: 4
8085+
m_DownscaleFallback: 0
8086+
m_IsAlphaChannelOptional: 0
8087+
serializedVersion: 5
8088+
m_Width: 1
8089+
m_Height: 1
8090+
m_AntiAliasing: 1
8091+
m_MipCount: -1
8092+
m_DepthStencilFormat: 0
8093+
m_ColorFormat: 4
8094+
m_MipMap: 0
8095+
m_GenerateMips: 1
8096+
m_SRGB: 1
8097+
m_UseDynamicScale: 0
8098+
m_BindMS: 0
8099+
m_EnableCompatibleFormat: 1
8100+
m_TextureSettings:
8101+
serializedVersion: 2
8102+
m_FilterMode: 1
8103+
m_Aniso: 1
8104+
m_MipBias: 0
8105+
m_WrapU: 1
8106+
m_WrapV: 1
8107+
m_WrapW: 1
8108+
m_Dimension: 2
8109+
m_VolumeDepth: 1
8110+
m_ShadowSamplingMode: 2
81118111
--- !u!33 &413101093 stripped
81128112
MeshFilter:
81138113
m_CorrespondingSourceObject: {fileID: -1194852140991108348, guid: 16500a523b718314091d7e9b83146c62, type: 3}
@@ -28426,28 +28426,30 @@ MonoBehaviour:
2842628426
IrradianceTex: {fileID: 0}
2842728427
Assets: {fileID: 0}
2842828428
ShadingShader: {fileID: 0}
28429+
CDFX: {fileID: 0}
28430+
CDFY: {fileID: 0}
2842928431
ScreenSpaceInfo: {fileID: 0}
2843028432
_currentSample: 0
2843128433
_transformsToWatch: []
2843228434
FramesSinceStart2: 0
2843328435
SampleCount: 0
2843428436
IndirectBoost: 1
28435-
bouncecount: 4
28437+
bouncecount: 12
2843628438
ClayMode: 0
2843728439
UseRussianRoulette: 1
2843828440
UseNEE: 1
2843928441
DoTLASUpdates: 1
28440-
AllowConverge: 0
28442+
AllowConverge: 1
2844128443
AllowBloom: 0
2844228444
AllowDoF: 0
2844328445
AllowAutoExpose: 0
2844428446
AllowToneMap: 0
2844528447
AllowTAA: 0
28446-
DoFAperature: 0.015
28448+
DoFAperature: 0.023
2844728449
DoFAperatureScale: 1
28448-
DoFFocal: 2.6303766
28450+
DoFFocal: 11.328476
2844928451
RenderScale: 1
28450-
BloomStrength: 43.776
28452+
BloomStrength: 17.152
2845128453
MinSpatialSize: 12
2845228454
UseASVGF: 0
2845328455
UseReCur: 0
@@ -28456,32 +28458,34 @@ MonoBehaviour:
2845628458
ReSTIRGIUpdateRate: 7
2845728459
UseReSTIRGITemporal: 1
2845828460
UseReSTIRGISpatial: 1
28459-
UseReSTIRGI: 1
28460-
ReSTIRGISpatialCount: 4
28461+
UseReSTIRGI: 0
28462+
ReSTIRGISpatialCount: 12
2846128463
ReSTIRGITemporalMCap: 32
2846228464
DoReSTIRGIConnectionValidation: 1
2846328465
Exposure: 50
28464-
ReCurBlurRadius: 32
28466+
ReCurBlurRadius: 12
2846528467
PrevReSTIRGI: 0
2846628468
DoPartialRendering: 0
2846728469
PartialRenderingFactor: 4
2846828470
DoFirefly: 0
28469-
ImprovedPrimaryHit: 0
28470-
RISCount: 12
28471+
ImprovedPrimaryHit: 1
28472+
RISCount: 1
2847128473
ToneMapper: 0
2847228474
DoOldReSTIR: 0
2847328475
SunDesaturate: 0
2847428476
SkyDesaturate: 0
28475-
ClayColor: {x: 0.49019608, y: 0.59272254, z: 0.6392157}
28477+
ClayColor: {x: 0.2528302, y: 0.2528302, z: 0.2528302}
2847628478
GroundColor: {x: 0.1, y: 0.1, z: 0.1}
28477-
FireflyFrameCount: 0
28479+
FireflyFrameCount: 122
2847828480
FireflyStrength: 1
2847928481
FireflyOffset: 0
2848028482
OIDNFrameCount: 0
2848128483
UseOIDN: 0
28484+
DoSharpen: 0
28485+
Sharpness: 1
2848228486
BackgroundType: 0
2848328487
SceneBackgroundColor: {x: 0, y: 0, z: 0}
28484-
SkyboxTexture: {fileID: 0}
28488+
SkyboxTexture: {fileID: 2800000, guid: 2ca58e35a6f96ed46b850cc779cf28bf, type: 3}
2848528489
BackgroundIntensity: 1
2848628490
AtmoNumLayers: 7
2848728491
FramesSinceStart: 0
@@ -28503,7 +28507,7 @@ MonoBehaviour:
2850328507
LightEnergyScale: 1
2850428508
AlbedoAtlasSize: 0
2850528509
VideoPlayerObject: {fileID: 0}
28506-
VideoTexture: {fileID: 239337102}
28510+
VideoTexture: {fileID: 407770371}
2850728511
MaterialsChanged: []
2850828512
_Materials: []
2850928513
MyMeshesCompacted: []
@@ -28517,6 +28521,9 @@ MonoBehaviour:
2851728521
RenderTransforms: []
2851828522
BuildQue:
2851928523
- {fileID: 1770588100}
28524+
- {fileID: 0}
28525+
- {fileID: 0}
28526+
- {fileID: 0}
2852028527
AddQue: []
2852128528
RemoveQue: []
2852228529
UpdateQue: []
@@ -43053,8 +43060,7 @@ MonoBehaviour:
4305343060
NodeInitializerKernel: 6
4305443061
CompactedMeshData: 0
4305543062
InstanceReferences: 0
43056-
NeedsToUpdate: 0
43057-
Assets: {fileID: 1568839226}
43063+
NeedsToUpdate: 1
4305843064
FailureCount: 0
4305943065
TotalTriangles: 0
4306043066
IsSkinnedGroup: 0

TrueTrace/Editor/MasterMaterialEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ public void CreateGUI() {
295295
RoughnessMinMax.RegisterValueChangedCallback(evt => {RTO.RoughnessRemap[Selected] = evt.newValue;RTO.CallMaterialEdited(true);});
296296
RoughnessMinMax.style.width = 350;
297297

298-
Slider MetallicSlider = new Slider() {label = "Metallic: ", value = RTO.Metallic[Selected], highValue = 5.0f, lowValue = 0};
298+
Slider MetallicSlider = new Slider() {label = "Metallic: ", value = RTO.Metallic[Selected], highValue = 1.0f, lowValue = 0};
299299
MetallicSlider.RegisterValueChangedCallback(evt => {RTO.Metallic[Selected] = evt.newValue;RTO.CallMaterialEdited(true);});
300300
MetallicSlider.style.width = 350;
301301
MetallicSlider.showInputField = true;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#if UNITY_EDITOR
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using UnityEngine;
5+
using UnityEditor;
6+
using CommonVars;
7+
using UnityEditor.UIElements;
8+
using UnityEngine.UIElements;
9+
10+
namespace TrueTrace {
11+
[CustomEditor(typeof(ParentObject))]
12+
public class ParentObjectEditor : Editor
13+
{
14+
public override bool RequiresConstantRepaint() => false;
15+
public override VisualElement CreateInspectorGUI() {
16+
return new VisualElement();
17+
}
18+
}
19+
}
20+
#endif

0 commit comments

Comments
 (0)